xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char const *, char *);
void test(const char *description, int result) {
  printf("%s: [%s]\n", description, result ? "failed" : "succeeded");
  if (result) {
    exit(1);
  }
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%ecx
lea    0xed4(%rip),%rdx
lea    0xec6(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     116b <test+0x4b>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbx
mov    %esi,%ebx
mov    %rdi,%rsi
test   %ebx,%ebx
lea    0xee2(%rip),%rax
lea    0xed4(%rip),%rdx
cmove  %rax,%rdx
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
test   %ebx,%ebx
jne    114c <test+0x2c>
pop    %rbx
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%s: [%s]\0A\00"
@.str.1 = [7 x i8] c"failed\00"
@.str.2 = [10 x i8] c"succeeded\00"
define void @test(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %9)
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s: [%s]\0A\00"
@.str.1 = [7 x i8] c"failed\00"
@.str.2 = [10 x i8] c"succeeded\00"
define void @test(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = select i1 %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %4)
br i1 %3, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  printf("hello arm!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"hello arm!\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [11 x i8] c"hello arm!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
char *getlogin();
int nice(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, int);
int main(int argc, char *argv[]) {
  char *login_name = getlogin();
  int nzero = nice(0);
  printf("login_name = %s, nzero = %d\n", login_name ? login_name : "", nzero);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getlogin@plt>
mov    %rax,-0x18(%rbp)
xor    %edi,%edi
call   1040 <nice@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1173 <main+0x43>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1183 <main+0x53>
lea    0xea2(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1183 <main+0x53>
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <getlogin@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1040 <nice@plt>
test   %rbx,%rbx
lea    0xed0(%rip),%rsi
cmovne %rbx,%rsi
lea    0xea9(%rip),%rdi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"login_name = %s, nzero = %d\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* (...) @getlogin()
store i8* %8, i8** %6
%9 = call i32 @nice(i32 0)
store i32 %9, i32* %7
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i8*, i8** %6
br label %15
14: ; preds = %2
br label %15
15: ; preds = %14, %12
%16 = phi i8* [ %13, %12 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %14 ]
%17 = load i32, i32* %7
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %16, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"login_name = %s, nzero = %d\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @getlogin()
%4 = tail call i32 @nice(i32 0)
%5 = icmp eq i8* %3, null
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %4)
ret i32 0
}
/* Variables and functions */
double log(int);
int /*<<< orphan*/ printf(char *, double, double);
int main() {
  double b = 25.0;
  double a = 0.0;
  a = log(10);
  printf("a is %lf, b is %lf\n", a, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0xa,%edi
call   1040 <log@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
call   1040 <log@plt>
lea    0xed6(%rip),%rdi
movsd  0xec6(%rip),%xmm1
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"a is %lf, b is %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 2.500000e+01, double* %2
store double 0.000000e+00, double* %3
%4 = call double @log(i32 10)
store double %4, double* %3
%5 = load double, double* %3
%6 = load double, double* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %5, double %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"a is %lf, b is %lf\0A\00"
define i32 @main() {
%1 = tail call double @log(i32 10)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %1, double 2.500000e+01)
ret i32 0
}
adrreg0adr1_set(r0, r1, x0, x1, p0, p1) float r0, r1;
float *p0, *p1;
{ (p0[10000000]) = (*((float *)11111111)); }


x86 assembly (clang, -O0):
<adrreg0adr1_set>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm1,-0x30(%rbp)
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm1,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    $0xa98ac7,%eax
movss  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x2625a00(%rax)
02
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<adrreg0adr1_set>:
movss  0xa98ac7,%xmm0
movss  %xmm0,0x2625a00(%rdx)
02
ret

LLVM IR (-O0):
define i32 @adrreg0adr1_set(double %0, double %1, i32 %2, i32 %3, float* %4, float* %5) {
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = fptrunc double %0 to float
%15 = fptrunc double %1 to float
store float %14, float* %8
store float %15, float* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store float* %4, float** %12
store float* %5, float** %13
%16 = load float, float* inttoptr (i64 11111111 to float*)
%17 = load float*, float** %12
%18 = getelementptr inbounds float, float* %17, i64 10000000
store float %16, float* %18
%19 = load i32, i32* %7
ret i32 %19
}

LLVM IR (-O2):
define i32 @adrreg0adr1_set(double %0, double %1, i32 %2, i32 %3, float* nocapture writeonly %4, float* nocapture readnone %5) {
%7 = load float, float* inttoptr (i64 11111111 to float*)
%8 = getelementptr inbounds float, float* %4, i64 10000000
store float %7, float* %8
ret i32 undef
}
/* Variables and functions */
int getchar();
void in_quote(int c) {
  int d;
  while ((d = getchar()) != c)
    if (d == '\\')
      getchar();
}


x86 assembly (clang, -O0):
<in_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    -0x4(%rbp),%eax
je     1144 <in_quote+0x34>
cmpl   $0x5c,-0x8(%rbp)
jne    113f <in_quote+0x2f>
mov    $0x0,%al
call   1030 <getchar@plt>
jmp    111b <in_quote+0xb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_quote>:
push   %rbx
mov    %edi,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    %ebx,%eax
je     1139 <in_quote+0x29>
cmp    $0x5c,%eax
jne    1120 <in_quote+0x10>
xor    %eax,%eax
call   1030 <getchar@plt>
jmp    1120 <in_quote+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @in_quote(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
br label %4
4: ; preds = %13, %1
%5 = call i32 (...) @getchar()
store i32 %5, i32* %3
%6 = load i32, i32* %2
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 92
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (...) @getchar()
br label %13
13: ; preds = %11, %8
br label %4
14: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @in_quote(i32 %0) {
%2 = tail call i32 (...) @getchar()
%3 = icmp eq i32 %2, %0
br i1 %3, label %12, label %4
4: ; preds = %1, %9
%5 = phi i32 [ %10, %9 ], [ %2, %1 ]
%6 = icmp eq i32 %5, 92
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (...) @getchar()
br label %9
9: ; preds = %7, %4
%10 = tail call i32 (...) @getchar()
%11 = icmp eq i32 %10, %0
br i1 %11, label %12, label %4
12: ; preds = %9, %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ ngen(char *, char *, int);
int /*<<< orphan*/ sgen(char *, char *, char *);
void cgincbglob(char *i, char *s, int v) {
  ngen("%s\tcl,%d", "mov", v);
  sgen("%s\t%s,cl", i, s);
}


x86 assembly (clang, -O0):
<cgincbglob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edx
lea    0xec3(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1030 <ngen@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xeb5(%rip),%rdi
call   1040 <sgen@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgincbglob>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1030 <ngen@plt>
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sgen@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s\09cl,%d\00"
@.str.1 = [4 x i8] c"mov\00"
@.str.2 = [9 x i8] c"%s\09%s,cl\00"
define void @cgincbglob(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = call i32 @ngen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32 @sgen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s\09cl,%d\00"
@.str.1 = [4 x i8] c"mov\00"
@.str.2 = [9 x i8] c"%s\09%s,cl\00"
define void @cgincbglob(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @ngen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%5 = tail call i32 @sgen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ hv_generic(int, unsigned int);
void hv_free_crq(unsigned int unit) { hv_generic(0x100, unit); }


x86 assembly (clang, -O0):
<hv_free_crq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x100,%edi
call   1030 <hv_generic@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hv_free_crq>:
mov    %edi,%esi
mov    $0x100,%edi
jmp    1030 <hv_generic@plt>

LLVM IR (-O0):
define void @hv_free_crq(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @hv_generic(i32 256, i32 %3)
ret void
}

LLVM IR (-O2):
define void @hv_free_crq(i32 %0) {
%2 = tail call i32 @hv_generic(i32 256, i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ CreateBufferFile();
int deserializeData();
int ProcessBufferFile() {
  int ret = 0;
  while (0 == ret) {
    ret = deserializeData();
  }
  if (-200 == ret) {
    CreateBufferFile();
    ret = 0;
  }
  return ret;
}


x86 assembly (clang, -O0):
<ProcessBufferFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    1149 <ProcessBufferFile+0x29>
mov    $0x0,%al
call   1040 <deserializeData@plt>
mov    %eax,-0x4(%rbp)
jmp    112f <ProcessBufferFile+0xf>
mov    $0xffffff38,%eax
cmp    -0x4(%rbp),%eax
jne    1165 <ProcessBufferFile+0x45>
mov    $0x0,%al
call   1030 <CreateBufferFile@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcessBufferFile>:
push   %rbx
xor    %ebx,%ebx
test   %ebx,%ebx
jne    113d <ProcessBufferFile+0x1d>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <deserializeData@plt>
mov    %eax,%ebx
test   %ebx,%ebx
je     1130 <ProcessBufferFile+0x10>
cmp    $0xffffff38,%ebx
jne    114e <ProcessBufferFile+0x2e>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <CreateBufferFile@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ProcessBufferFile() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %5, %0
%3 = load i32, i32* %1
%4 = icmp eq i32 0, %3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = call i32 (...) @deserializeData()
store i32 %6, i32* %1
br label %2
7: ; preds = %2
%8 = load i32, i32* %1
%9 = icmp eq i32 -200, %8
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 (...) @CreateBufferFile()
store i32 0, i32* %1
br label %12
12: ; preds = %10, %7
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
define i32 @ProcessBufferFile() {
br label %1
1: ; preds = %3, %0
%2 = phi i32 [ 0, %0 ], [ %4, %3 ]
switch i32 %2, label %7 [
i32 0, label %3
i32 -200, label %5
]
3: ; preds = %1
%4 = tail call i32 (...) @deserializeData()
br label %1
5: ; preds = %1
%6 = tail call i32 (...) @CreateBufferFile()
br label %7
7: ; preds = %1, %5
%8 = phi i32 [ 0, %5 ], [ %2, %1 ]
ret i32 %8
}
/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, int, char const *);
char *substr(const char *s, int start, int stop) {
  char *v;
  asprintf(&v, "%.*s", stop - start + 1, &s[start]);
  return v;
}


x86 assembly (clang, -O0):
<substr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edx
sub    -0xc(%rbp),%edx
add    $0x1,%edx
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rax
add    %rax,%rcx
lea    -0x18(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <asprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substr>:
push   %rax
sub    %esi,%edx
add    $0x1,%edx
movslq %esi,%rcx
add    %rdi,%rcx
lea    0xedd(%rip),%rsi
mov    %rsp,%rdi
call   1030 <asprintf@plt>
mov    (%rsp),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%.*s\00"
define i8* @substr(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = sub nsw i32 %8, %9
%11 = add nsw i32 %10, 1
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %15)
%17 = load i8*, i8** %7
ret i8* %17
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.*s\00"
define i8* @substr(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = sub i32 1, %1
%7 = add i32 %6, %2
%8 = sext i32 %1 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %9)
%11 = load i8*, i8** %4
ret i8* %11
}
int hash(int key) { return key % 20; }


x86 assembly (clang, -O0):
<hash>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash>:
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @hash(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = srem i32 %3, 20
ret i32 %4
}

LLVM IR (-O2):
define i32 @hash(i32 %0) {
%2 = srem i32 %0, 20
ret i32 %2
}
/* Variables and functions */
float RAND_MAX;
float rand();
int SCE_Math_RandRange(int a, int b) {
  float r = rand() / RAND_MAX;
  r *= (b - a);
  r += a;
  return r + 0.5;
}


x86 assembly (clang, -O0):
<SCE_Math_RandRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    0x2ebc(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe97(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SCE_Math_RandRange>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    0x2ec3(%rip),%rax
divss  (%rax),%xmm0
sub    %ebp,%ebx
cvtsi2ss %ebx,%xmm1
cvtsi2ss %ebp,%xmm2
mulss  %xmm0,%xmm1
addss  %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
addsd  0xeb6(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
define i32 @SCE_Math_RandRange(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call float (...) @rand()
%7 = load float, float* @RAND_MAX
%8 = fdiv float %6, %7
store float %8, float* %5
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = sub nsw i32 %9, %10
%12 = sitofp i32 %11 to float
%13 = load float, float* %5
%14 = fmul float %13, %12
store float %14, float* %5
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to float
%17 = load float, float* %5
%18 = fadd float %17, %16
store float %18, float* %5
%19 = load float, float* %5
%20 = fpext float %19 to double
%21 = fadd double %20, 5.000000e-01
%22 = fptosi double %21 to i32
ret i32 %22
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
define i32 @SCE_Math_RandRange(i32 %0, i32 %1) {
%3 = tail call float (...) @rand()
%4 = load float, float* @RAND_MAX
%5 = fdiv float %3, %4
%6 = sub nsw i32 %1, %0
%7 = sitofp i32 %6 to float
%8 = fmul float %5, %7
%9 = sitofp i32 %0 to float
%10 = fadd float %8, %9
%11 = fpext float %10 to double
%12 = fadd double %11, 5.000000e-01
%13 = fptosi double %12 to i32
ret i32 %13
}
/* Variables and functions */
int /*<<< orphan*/ lapicinit();
int /*<<< orphan*/ mpmain();
int /*<<< orphan*/ seginit();
int /*<<< orphan*/ switchkvm();
void mpenter(void) {
  switchkvm();
  seginit();
  lapicinit();
  mpmain();
}


x86 assembly (clang, -O0):
<mpenter>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <switchkvm@plt>
mov    $0x0,%al
call   1060 <seginit@plt>
mov    $0x0,%al
call   1030 <lapicinit@plt>
mov    $0x0,%al
call   1050 <mpmain@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpenter>:
push   %rax
xor    %eax,%eax
call   1040 <switchkvm@plt>
xor    %eax,%eax
call   1060 <seginit@plt>
xor    %eax,%eax
call   1030 <lapicinit@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <mpmain@plt>

LLVM IR (-O0):
define void @mpenter() {
%1 = call i32 (...) @switchkvm()
%2 = call i32 (...) @seginit()
%3 = call i32 (...) @lapicinit()
%4 = call i32 (...) @mpmain()
ret void
}

LLVM IR (-O2):
define void @mpenter() {
%1 = tail call i32 (...) @switchkvm()
%2 = tail call i32 (...) @seginit()
%3 = tail call i32 (...) @lapicinit()
%4 = tail call i32 (...) @mpmain()
ret void
}
/* Type definitions */
struct sockaddr_in {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ inet_pton(int /*<<< orphan*/, char *, struct sockaddr_in **);
int /*<<< orphan*/ perror(char *);
int net_ip2addr(struct sockaddr_in *out_addr, char *ip) {
  if (inet_pton(AF_INET, ip, &out_addr) < 0) {
    perror("fail to ip convert addr");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<net_ip2addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <inet_pton@plt>
cmp    $0x0,%rax
jge    1168 <net_ip2addr+0x48>
lea    0xea9(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    116f <net_ip2addr+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<net_ip2addr>:
push   %rax
mov    %rdi,(%rsp)
mov    0x2ebc(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rdx
call   1030 <inet_pton@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1142 <net_ip2addr+0x22>
pop    %rcx
ret
lea    0xeb7(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@AF_INET = global i32 0
@.str = [24 x i8] c"fail to ip convert addr\00"
define i32 @net_ip2addr(%struct.sockaddr_in* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in*
%5 = alloca i8*
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %4
store i8* %1, i8** %5
%6 = load i32, i32* @AF_INET
%7 = load i8*, i8** %5
%8 = call i64 @inet_pton(i32 %6, i8* %7, %struct.sockaddr_in** %4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %13
12: ; preds = %2
store i32 0, i32* %3
br label %13
13: ; preds = %12, %10
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@AF_INET = global i32 0
@.str = [24 x i8] c"fail to ip convert addr\00"
define i32 @net_ip2addr(%struct.sockaddr_in* %0, i8* %1) {
%3 = alloca %struct.sockaddr_in*
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %3
%4 = load i32, i32* @AF_INET
%5 = call i64 @inet_pton(i32 %4, i8* %1, %struct.sockaddr_in** %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ -1, %7 ], [ 0, %2 ]
ret i32 %10
}
float dcn_bw_min2(const float arg1, const float arg2) {
  if (((arg1) != (arg1)))
    return arg2;
  if (((arg2) != (arg2)))
    return arg1;
  return arg1 < arg2 ? arg1 : arg2;
}


x86 assembly (clang, -O0):
<dcn_bw_min2>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jne    1128 <dcn_bw_min2+0x28>
jp     1128 <dcn_bw_min2+0x28>
jmp    1137 <dcn_bw_min2+0x37>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1196 <dcn_bw_min2+0x96>
movss  -0xc(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1151 <dcn_bw_min2+0x51>
jp     1151 <dcn_bw_min2+0x51>
jmp    1160 <dcn_bw_min2+0x60>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1196 <dcn_bw_min2+0x96>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1182 <dcn_bw_min2+0x82>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    118c <dcn_bw_min2+0x8c>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcn_bw_min2>:
ucomiss %xmm0,%xmm0
jp     1111 <dcn_bw_min2+0x11>
ucomiss %xmm1,%xmm1
jp     110e <dcn_bw_min2+0xe>
minss  %xmm1,%xmm0
movaps %xmm0,%xmm1
movaps %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @dcn_bw_min2(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
%6 = load float, float* %4
%7 = load float, float* %4
%8 = fcmp une float %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load float, float* %5
store float %10, float* %3
br label %27
11: ; preds = %2
%12 = load float, float* %5
%13 = load float, float* %5
%14 = fcmp une float %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load float, float* %4
store float %16, float* %3
br label %27
17: ; preds = %11
%18 = load float, float* %4
%19 = load float, float* %5
%20 = fcmp olt float %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load float, float* %4
br label %25
23: ; preds = %17
%24 = load float, float* %5
br label %25
25: ; preds = %23, %21
%26 = phi float [ %22, %21 ], [ %24, %23 ]
store float %26, float* %3
br label %27
27: ; preds = %25, %15, %9
%28 = load float, float* %3
ret float %28
}

LLVM IR (-O2):
define float @dcn_bw_min2(float %0, float %1) {
%3 = fcmp uno float %0, 0.000000e+00
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = fcmp uno float %1, 0.000000e+00
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = fcmp olt float %0, %1
%8 = select i1 %7, float %0, float %1
br label %9
9: ; preds = %4, %2, %6
%10 = phi float [ %8, %6 ], [ %1, %2 ], [ %0, %4 ]
ret float %10
}
/* Variables and functions */
int /*<<< orphan*/ f(int, ...);
main() {
  struct A {
    int j;
  } * p;
  struct B {
    void *p;
  };
  f(p->j);
  {
    struct A {
      int i;
    } * p;
    struct B b;
    f(p->i, b.p);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <f@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1030 <f@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <f@plt>
xor    %eax,%eax
call   1030 <f@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.A = type { i32 }
%struct.A.0 = type { i32 }
%struct.B = type { i8* }
define i32 @main() {
%1 = alloca %struct.A*
%2 = alloca %struct.A.0*
%3 = alloca %struct.B
%4 = load %struct.A*, %struct.A** %1
%5 = getelementptr inbounds %struct.A, %struct.A* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = call i32 (i32, ...) @f(i32 %6)
%8 = load %struct.A.0*, %struct.A.0** %2
%9 = getelementptr inbounds %struct.A.0, %struct.A.0* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.B, %struct.B* %3, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = call i32 (i32, ...) @f(i32 %10, i8* %12)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (i32, ...) @f(i32 undef)
%2 = tail call i32 (i32, ...) @f(i32 undef, i8* undef)
ret i32 0
}
int slt(int register2, int register3) {
  if (register2 < register3) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<slt>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1122 <slt+0x22>
movl   $0x1,-0x4(%rbp)
jmp    1129 <slt+0x29>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<slt>:
xor    %eax,%eax
cmp    %esi,%edi
setl   %al
ret

LLVM IR (-O0):
define i32 @slt(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %5
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %11
10: ; preds = %2
store i32 0, i32* %3
br label %11
11: ; preds = %10, %9
%12 = load i32, i32* %3
ret i32 %12
}

LLVM IR (-O2):
define i32 @slt(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, %1
%4 = zext i1 %3 to i32
ret i32 %4
}
void do_set(int argc, char *argv[], int start) {
  (void)argc;
  (void)argv;
  (void)start;
}


x86 assembly (clang, -O0):
<do_set>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_set>:
ret

LLVM IR (-O0):
define void @do_set(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = load i32, i32* %6
ret void
}

LLVM IR (-O2):
define void @do_set(i32 %0, i8** nocapture %1, i32 %2) {
ret void
}
/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
void haskExec(char *file) {
  char *exec = (char *)malloc(256 * sizeof(char));
  strcpy(exec, "ghc -o");
  strcpy(exec, file);
  strcpy(exec, " program && ./program > latesttest.txt");
}


x86 assembly (clang, -O0):
<haskExec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<haskExec>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xec5(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"ghc -o\00"
@.str.1 = [39 x i8] c" program && ./program > latesttest.txt\00"
define void @haskExec(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i64 @malloc(i32 256)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %3
%9 = load i8*, i8** %2
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = load i8*, i8** %3
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"ghc -o\00"
@.str.1 = [39 x i8] c" program && ./program > latesttest.txt\00"
define void @haskExec(i8* %0) {
%2 = tail call i64 @malloc(i32 256)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strcpy(i8* %3, i8* %0)
%6 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Variables and functions */
int rand();
int rollDice(int numRolls, int diceSides) {
  int diceRollCount = 0;
  int diceValue = 0;
  while (diceRollCount < numRolls) {
    diceValue += 1 + rand() % diceSides;
    diceRollCount++;
  }
  return diceValue;
}


x86 assembly (clang, -O0):
<rollDice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    115c <rollDice+0x4c>
mov    $0x0,%al
call   1030 <rand@plt>
cltd
idivl  -0x8(%rbp)
mov    %edx,%eax
add    $0x1,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112c <rollDice+0x1c>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rollDice>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    1137 <rollDice+0x27>
mov    %esi,%r14d
mov    %edi,%ebp
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %r14d
add    %edx,%ebx
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    1120 <rollDice+0x10>
jmp    1139 <rollDice+0x29>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rollDice(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %11, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = call i32 (...) @rand()
%13 = load i32, i32* %4
%14 = srem i32 %12, %13
%15 = add nsw i32 1, %14
%16 = load i32, i32* %6
%17 = add nsw i32 %16, %15
store i32 %17, i32* %6
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %7
20: ; preds = %7
%21 = load i32, i32* %6
ret i32 %21
}

LLVM IR (-O2):
define i32 @rollDice(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %13
4: ; preds = %2, %4
%5 = phi i32 [ %10, %4 ], [ 0, %2 ]
%6 = phi i32 [ %11, %4 ], [ 0, %2 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, %1
%9 = add i32 %5, 1
%10 = add i32 %9, %8
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %4
13: ; preds = %4, %2
%14 = phi i32 [ 0, %2 ], [ %10, %4 ]
ret i32 %14
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
uint8_t CS(int num) { return (num & 0x7) << 5; }


x86 assembly (clang, -O0):
<CS>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7,%eax
shl    $0x5,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CS>:
shl    $0x5,%edi
movzbl %dil,%eax
ret

LLVM IR (-O0):
define i32 @CS(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 7
%5 = shl i32 %4, 5
ret i32 %5
}

LLVM IR (-O2):
define i32 @CS(i32 %0) {
%2 = shl i32 %0, 5
%3 = and i32 %2, 224
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ test_endianness();
scalar_t__ test_endianness_vol();
main() {
  if (test_endianness() != test_endianness_vol())
    abort();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <test_endianness@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <test_endianness_vol@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
je     1178 <main+0x38>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <test_endianness@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <test_endianness_vol@plt>
cmp    %rax,%rbx
jne    115e <main+0x1e>
xor    %edi,%edi
call   1050 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @test_endianness()
%3 = call i64 (...) @test_endianness_vol()
%4 = icmp ne i64 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (...) @abort()
unreachable
7: ; preds = %0
%8 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 (...) @test_endianness()
%2 = tail call i64 (...) @test_endianness_vol()
%3 = icmp eq i64 %1, %2
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 (...) @abort()
unreachable
6: ; preds = %0
%7 = tail call i32 @exit(i32 0)
unreachable
}
long int labs(long int j) {
  if (j < 0)
    return (-j);
  else
    return (j);
}


x86 assembly (clang, -O0):
<labs>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1122 <labs+0x22>
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    112a <labs+0x2a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<labs>:
mov    %rdi,%rax
neg    %rax
cmovs  %rdi,%rax
ret

LLVM IR (-O0):
define i64 @labs(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i64, i64* %3
%8 = sub nsw i64 0, %7
store i64 %8, i64* %2
br label %11
9: ; preds = %1
%10 = load i64, i64* %3
store i64 %10, i64* %2
br label %11
11: ; preds = %9, %6
%12 = load i64, i64* %2
ret i64 %12
}

LLVM IR (-O2):
define i64 @labs(i64 %0) {
%2 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
ret i64 %2
}
/* Variables and functions */
int /*<<< orphan*/ lookNarray(char *, unsigned int);
void lookcomplex4array(char *x, int n) {
  lookNarray((char *)x, (unsigned int)(n * 4));
}


x86 assembly (clang, -O0):
<lookcomplex4array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x2,%esi
call   1030 <lookNarray@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookcomplex4array>:
shl    $0x2,%esi
jmp    1030 <lookNarray@plt>

LLVM IR (-O0):
define void @lookcomplex4array(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = load i32, i32* %4
%7 = mul nsw i32 %6, 4
%8 = call i32 @lookNarray(i8* %5, i32 %7)
ret void
}

LLVM IR (-O2):
define void @lookcomplex4array(i8* %0, i32 %1) {
%3 = shl nsw i32 %1, 2
%4 = tail call i32 @lookNarray(i8* %0, i32 %3)
ret void
}
void XwcTextPropertyToTextList() {}


x86 assembly (clang, -O0):
<XwcTextPropertyToTextList>:
push   %rbp
mov    %rsp,%rbp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XwcTextPropertyToTextList>:
ret

LLVM IR (-O0):
define void @XwcTextPropertyToTextList() {
ret void
}

LLVM IR (-O2):
define void @XwcTextPropertyToTextList() {
ret void
}
void swap(int *px, int *py) {
  int temp = *px;
  *px = *py;
  *py = temp;
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
mov    (%rdi),%eax
mov    (%rsi),%ecx
mov    %ecx,(%rdi)
mov    %eax,(%rsi)
ret

LLVM IR (-O0):
define void @swap(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %6
store i32 %7, i32* %5
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
%10 = load i32*, i32** %3
store i32 %9, i32* %10
%11 = load i32, i32* %5
%12 = load i32*, i32** %4
store i32 %11, i32* %12
ret void
}

LLVM IR (-O2):
define void @swap(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %0
%4 = load i32, i32* %1
store i32 %4, i32* %0
store i32 %3, i32* %1
ret void
}
/* Variables and functions */
char *U_WMRCORENONE_set(char *);
char *U_WMR3C_set(void) { return U_WMRCORENONE_set("U_WMR3C"); }


x86 assembly (clang, -O0):
<U_WMR3C_set>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <U_WMRCORENONE_set@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<U_WMR3C_set>:
lea    0xee9(%rip),%rdi
jmp    1030 <U_WMRCORENONE_set@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"U_WMR3C\00"
define i8* @U_WMR3C_set() {
%1 = call i8* @U_WMRCORENONE_set(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i8* %1
}

LLVM IR (-O2):
@.str = [8 x i8] c"U_WMR3C\00"
define i8* @U_WMR3C_set() {
%1 = tail call i8* @U_WMRCORENONE_set(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i8* %1
}
int strst(const char *str, const char *key) {
  do {
    if (*str != *key)
      return 1;
  } while (*++str && *++key);
  return 0;
}


x86 assembly (clang, -O0):
<strst>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     112e <strst+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    1182 <strst+0x82>
jmp    1133 <strst+0x33>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1170 <strst+0x70>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    110c <strst+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strst>:
mov    (%rdi),%r8b
mov    (%rsi),%dl
mov    $0x1,%ecx
xor    %eax,%eax
nopl   0x0(%rax)
cmp    %dl,%r8b
jne    112c <strst+0x2c>
movzbl (%rdi,%rcx,1),%r8d
test   %r8b,%r8b
je     112b <strst+0x2b>
movzbl (%rsi,%rcx,1),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    1110 <strst+0x10>
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @strst(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %28, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %9, %12
br i1 %13, label %14, label %15
14: ; preds = %6
store i32 1, i32* %3
br label %31
15: ; preds = %6
br label %16
16: ; preds = %15
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %22, %16
%29 = phi i1 [ false, %16 ], [ %27, %22 ]
br i1 %29, label %6, label %30
30: ; preds = %28
store i32 0, i32* %3
br label %31
31: ; preds = %30, %14
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @strst(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = load i8, i8* %1
br label %5
5: ; preds = %15, %2
%6 = phi i8 [ %4, %2 ], [ %17, %15 ]
%7 = phi i8 [ %3, %2 ], [ %13, %15 ]
%8 = phi i8* [ %0, %2 ], [ %12, %15 ]
%9 = phi i8* [ %1, %2 ], [ %16, %15 ]
%10 = icmp eq i8 %7, %6
br i1 %10, label %11, label %19
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %9, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %15, %11, %5
%20 = phi i32 [ 1, %5 ], [ 0, %11 ], [ 0, %15 ]
ret i32 %20
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("Hello world\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Hello world\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [12 x i8] c"Hello world\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
void OSDDummyReset(void) {}


x86 assembly (clang, -O0):
<OSDDummyReset>:
push   %rbp
mov    %rsp,%rbp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OSDDummyReset>:
ret

LLVM IR (-O0):
define void @OSDDummyReset() {
ret void
}

LLVM IR (-O2):
define void @OSDDummyReset() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, double);
void sprintf_exact(double x) {
  char buf[64];
  snprintf(buf, 64, "%a", x);
}


x86 assembly (clang, -O0):
<sprintf_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
mov    $0x40,%esi
lea    0xece(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprintf_exact>:
sub    $0x48,%rsp
lea    0xee5(%rip),%rdx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1030 <snprintf@plt>
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%a\00"
define void @sprintf_exact(double %0) {
%2 = alloca double
%3 = alloca [64 x i8]
store double %0, double* %2
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = load double, double* %2
%6 = call i32 @snprintf(i8* %4, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %5)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%a\00"
define void @sprintf_exact(double %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %0)
ret void
}
int fun970() { return 970; }


x86 assembly (clang, -O0):
<fun970>:
push   %rbp
mov    %rsp,%rbp
mov    $0x3ca,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun970>:
mov    $0x3ca,%eax
ret

LLVM IR (-O0):
define i32 @fun970() {
ret i32 970
}

LLVM IR (-O2):
define i32 @fun970() {
ret i32 970
}
/* Type definitions */
typedef int /*<<< orphan*/ X509;

/* Variables and functions */
int /*<<< orphan*/ EVP_sha1();
scalar_t__ X509_digest(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       unsigned char *, unsigned int *);
int ssl_x509_fingerprint_sha1(X509 *crt, unsigned char *fpr) {
  unsigned int sz = 20;
  return X509_digest(crt, EVP_sha1(), fpr, &sz) ? 0 : -1;
}


x86 assembly (clang, -O0):
<ssl_x509_fingerprint_sha1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x14,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <EVP_sha1@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1040 <X509_digest@plt>
mov    %rax,%rdx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_x509_fingerprint_sha1>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x14,0x4(%rsp)
xor    %eax,%eax
call   1030 <EVP_sha1@plt>
lea    0x4(%rsp),%rcx
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1040 <X509_digest@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @ssl_x509_fingerprint_sha1(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 20, i32* %5
%6 = load i32*, i32** %3
%7 = call i32 (...) @EVP_sha1()
%8 = load i8*, i8** %4
%9 = call i64 @X509_digest(i32* %6, i32 %7, i8* %8, i32* %5)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i32 0, i32 -1
ret i32 %12
}

LLVM IR (-O2):
define i32 @ssl_x509_fingerprint_sha1(i32* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 20, i32* %3
%5 = tail call i32 (...) @EVP_sha1()
%6 = call i64 @X509_digest(i32* %0, i32 %5, i8* %1, i32* %3)
%7 = icmp eq i64 %6, 0
%8 = sext i1 %7 to i32
ret i32 %8
}