Skip to content

Instantly share code, notes, and snippets.

@pgoodman
Last active October 10, 2019 19:24
Show Gist options
  • Save pgoodman/e564994e43b5268cd17930594c4c4a1f to your computer and use it in GitHub Desktop.
Save pgoodman/e564994e43b5268cd17930594c4c4a1f to your computer and use it in GitHub Desktop.
remill-lift-7.0 --ir_out /dev/stdout --bytes 89F80FB74C241881F9008000000F95C1D3E0C3 --slice_inputs RSP,EDI --slice_outputs EAX
0: 89 f8 mov eax,edi
2: 0f b7 4c 24 18 movzx ecx,WORD PTR [rsp+0x18]
7: 81 f9 00 80 00 00 cmp ecx,0x8000
d: 0f 95 c1 setne cl
10: d3 e0 shl eax,cl
12: c3 ret
; Function Attrs: noduplicate noinline nounwind optnone readnone
declare zeroext i16 @__remill_read_memory_16(%struct.Memory*, i64) local_unnamed_addr #0
; Function Attrs: noduplicate noinline nounwind optnone readnone
declare i64 @__remill_read_memory_64(%struct.Memory*, i64) local_unnamed_addr #0
; Function Attrs: noduplicate noinline nounwind optnone
declare %struct.Memory* @__remill_function_return(%struct.State* dereferenceable(3376), i64, %struct.Memory*) local_unnamed_addr #1
; Function Attrs: nounwind ssp
define %struct.Memory* @slice(%struct.Memory*, i64 %RSP, i32 %EDI, i32* nocapture %EAX_output) local_unnamed_addr #2 {
sub_0.exit:
%1 = add i64 %RSP, 24
%2 = tail call zeroext i16 @__remill_read_memory_16(%struct.Memory* %0, i64 %1) #3
%3 = icmp ne i16 %2, -32768
%4 = zext i1 %3 to i32
%spec.select = shl i32 %EDI, %4
%5 = tail call i64 @__remill_read_memory_64(%struct.Memory* %0, i64 %RSP) #3
%6 = tail call %struct.Memory* @__remill_function_return(%struct.State* nonnull undef, i64 %5, %struct.Memory* %0) #4, !noalias !0
store i32 %spec.select, i32* %EAX_output, align 4
ret %struct.Memory* %6
}
; Function Attrs: alwaysinline inlinehint nounwind ssp
define internal %struct.Memory* @sub_0(%struct.State* noalias dereferenceable(3376), i64, %struct.Memory* noalias) local_unnamed_addr #0 {
%4 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 6, i32 33, i32 0, i32 0
%5 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 6, i32 5, i32 0
%6 = bitcast %union.anon* %5 to i8*
%7 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 6, i32 11, i32 0
%8 = bitcast %union.anon* %7 to i32*
%9 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 6, i32 1, i32 0, i32 0
%10 = getelementptr inbounds %union.anon, %union.anon* %5, i64 0, i32 0
%11 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 6, i32 13, i32 0, i32 0
%12 = load i32, i32* %8, align 4
%13 = zext i32 %12 to i64
store i64 %13, i64* %9, align 8
%14 = load i64, i64* %11, align 8
%15 = add i64 %14, 24
%16 = tail call zeroext i16 @__remill_read_memory_16(%struct.Memory* %2, i64 %15) #4
%17 = zext i16 %16 to i64
store i64 %17, i64* %10, align 8
%18 = zext i16 %16 to i32
%19 = add nsw i32 %18, -32768
%20 = lshr i16 %16, 15
%21 = trunc i16 %20 to i8
%22 = xor i8 %21, 1
%23 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 2, i32 1
store i8 %22, i8* %23, align 1
%24 = and i16 %16, 255
%25 = zext i16 %24 to i32
%26 = tail call i32 @llvm.ctpop.i32(i32 %25) #5
%27 = trunc i32 %26 to i8
%28 = and i8 %27, 1
%29 = xor i8 %28, 1
%30 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 2, i32 3
store i8 %29, i8* %30, align 1
%31 = xor i32 %19, %18
%32 = lshr i32 %31, 4
%33 = trunc i32 %32 to i8
%34 = and i8 %33, 1
%35 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 2, i32 5
store i8 %34, i8* %35, align 1
%36 = icmp eq i32 %19, 0
%37 = zext i1 %36 to i8
%38 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 2, i32 7
store i8 %37, i8* %38, align 1
%39 = lshr i32 %19, 31
%40 = trunc i32 %39 to i8
%41 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 2, i32 9
store i8 %40, i8* %41, align 1
%42 = getelementptr inbounds %struct.State, %struct.State* %0, i64 0, i32 2, i32 13
store i8 0, i8* %42, align 1
%43 = xor i1 %36, true
%44 = zext i1 %43 to i8
store i8 %44, i8* %6, align 1
br i1 %36, label %_ZN12_GLOBAL__N_13SHLI3RnWIyE2RnIjES4_EEP6MemoryS6_R5StateT_T0_T1_.exit, label %45
; <label>:45: ; preds = %3
%46 = shl nuw nsw i64 %13, 1
%47 = trunc i64 %46 to i32
%48 = xor i32 %12, %47
%49 = and i64 %46, 4294967294
store i64 %49, i64* %9, align 8
%50 = lshr i32 %12, 31
%51 = trunc i32 %50 to i8
store i8 %51, i8* %23, align 1
%52 = and i32 %47, 254
%53 = tail call i32 @llvm.ctpop.i32(i32 %52) #5
%54 = trunc i32 %53 to i8
%55 = and i8 %54, 1
%56 = xor i8 %55, 1
store i8 %56, i8* %30, align 1
store i8 0, i8* %35, align 1
%57 = icmp eq i32 %47, 0
%58 = zext i1 %57 to i8
store i8 %58, i8* %38, align 1
%59 = lshr i32 %12, 30
%60 = trunc i32 %59 to i8
%61 = and i8 %60, 1
store i8 %61, i8* %41, align 1
%62 = lshr i32 %48, 31
%63 = trunc i32 %62 to i8
store i8 %63, i8* %42, align 1
br label %_ZN12_GLOBAL__N_13SHLI3RnWIyE2RnIjES4_EEP6MemoryS6_R5StateT_T0_T1_.exit
_ZN12_GLOBAL__N_13SHLI3RnWIyE2RnIjES4_EEP6MemoryS6_R5StateT_T0_T1_.exit: ; preds = %3, %45
%64 = tail call i64 @__remill_read_memory_64(%struct.Memory* %2, i64 %14) #4
store i64 %64, i64* %4, align 8
%65 = add i64 %14, 8
store i64 %65, i64* %11, align 8
%66 = tail call %struct.Memory* @__remill_function_return(%struct.State* nonnull %0, i64 %64, %struct.Memory* %2)
ret %struct.Memory* %66
}
; Function Attrs: noduplicate noinline nounwind optnone readnone
declare zeroext i16 @__remill_read_memory_16(%struct.Memory*, i64) #1
; Function Attrs: nounwind readnone speculatable
declare i32 @llvm.ctpop.i32(i32) #2
; Function Attrs: noduplicate noinline nounwind optnone readnone
declare i64 @__remill_read_memory_64(%struct.Memory*, i64) #1
; Function Attrs: noduplicate noinline nounwind optnone
declare %struct.Memory* @__remill_function_return(%struct.State* dereferenceable(3376), i64, %struct.Memory*) #3
define %struct.Memory* @slice(%struct.Memory*, i64 %RSP, i32 %EDI, i32* %EAX_output) {
%2 = alloca %struct.State
%3 = getelementptr inbounds %struct.State, %struct.State* %2, i32 0, i32 6, i32 33, i32 0, i32 0
store i64 0, i64* %3
%4 = getelementptr inbounds %struct.State, %struct.State* %2, i32 0, i32 6, i32 13, i32 0, i32 0
store i64 %RSP, i64* %4
%5 = getelementptr inbounds %struct.State, %struct.State* %2, i32 0, i32 6, i32 11, i32 0, i32 0
%6 = bitcast i64* %5 to i32*
store i32 %EDI, i32* %6
%7 = call %struct.Memory* @sub_0(%struct.State* %2, i64 0, %struct.Memory* %0)
%8 = getelementptr inbounds %struct.State, %struct.State* %2, i32 0, i32 6, i32 1, i32 0, i32 0
%9 = bitcast i64* %8 to i32*
%10 = load i32, i32* %9
store i32 %10, i32* %EAX_output
ret %struct.Memory* %7
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment