xunge/DecIR huggingface dataset:
long long int gcd(long long int num1, long long int num2) {
  while (num1 != num2) {
    if (num1 > num2)
      num1 -= num2;
    else
      num2 -= num1;
  }
  return num1;
}


x86 assembly (clang, -O0):
<gcd>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1150 <gcd+0x50>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    113c <gcd+0x3c>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    114b <gcd+0x4b>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    110c <gcd+0xc>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcd>:
mov    %rdi,%rax
cmp    %rsi,%rdi
je     112e <gcd+0x2e>
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
cmp    %rax,%rsi
mov    $0x0,%edx
cmovl  %rsi,%rdx
mov    %rax,%rdi
cmovl  %rcx,%rdi
sub    %rdx,%rax
sub    %rdi,%rsi
cmp    %rsi,%rax
jne    1110 <gcd+0x10>
ret

LLVM IR (-O0):
define i64 @gcd(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
br label %5
5: ; preds = %21, %2
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i64, i64* %3
%11 = load i64, i64* %4
%12 = icmp sgt i64 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i64, i64* %4
%15 = load i64, i64* %3
%16 = sub nsw i64 %15, %14
store i64 %16, i64* %3
br label %21
17: ; preds = %9
%18 = load i64, i64* %3
%19 = load i64, i64* %4
%20 = sub nsw i64 %19, %18
store i64 %20, i64* %4
br label %21
21: ; preds = %17, %13
br label %5
22: ; preds = %5
%23 = load i64, i64* %3
ret i64 %23
}

LLVM IR (-O2):
define i64 @gcd(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, %1
br i1 %3, label %13, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %11, %4 ], [ %1, %2 ]
%6 = phi i64 [ %9, %4 ], [ %0, %2 ]
%7 = icmp slt i64 %5, %6
%8 = select i1 %7, i64 %5, i64 0
%9 = sub nsw i64 %6, %8
%10 = select i1 %7, i64 0, i64 %6
%11 = sub nsw i64 %5, %10
%12 = icmp eq i64 %9, %11
br i1 %12, label %13, label %4
13: ; preds = %4, %2
%14 = phi i64 [ %0, %2 ], [ %9, %4 ]
ret i64 %14
}
/* Variables and functions */
int /*<<< orphan*/ collections_tests();
void util_tests() { collections_tests(); }


x86 assembly (clang, -O0):
<util_tests>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <collections_tests@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_tests>:
xor    %eax,%eax
jmp    1030 <collections_tests@plt>

LLVM IR (-O0):
define void @util_tests() {
%1 = call i32 (...) @collections_tests()
ret void
}

LLVM IR (-O2):
define void @util_tests() {
%1 = tail call i32 (...) @collections_tests()
ret void
}
void foo(int i) {
  switch (i) {
  case 1:
    return;
  case 2:
    break;
  }
  int x = 0;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     112c <foo+0x2c>
jmp    111b <foo+0x1b>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1131 <foo+0x31>
jmp    1136 <foo+0x36>
jmp    113d <foo+0x3d>
jmp    1136 <foo+0x36>
movl   $0x0,-0x8(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %7 [
i32 1, label %5
i32 2, label %6
]
5: ; preds = %1
br label %8
6: ; preds = %1
br label %7
7: ; preds = %1, %6
store i32 0, i32* %3
br label %8
8: ; preds = %7, %5
ret void
}

LLVM IR (-O2):
define void @foo(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
void *malloc_err(size_t size) {
  char *p;
  p = (char *)malloc(size);
  if (p == NULL) {
    fprintf(stderr, "Out of memory!\n");
    exit(1);
  }
  return (void *)p;
}


x86 assembly (clang, -O0):
<malloc_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1173 <malloc_err+0x43>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<malloc_err>:
push   %rax
call   1040 <malloc@plt>
test   %rax,%rax
je     113d <malloc_err+0xd>
pop    %rcx
ret
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory!\0A\00"
define i8* @malloc_err(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i8*, i8** %3
ret i8* %14
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory!\0A\00"
define i8* @malloc_err(i64 %0) {
%2 = tail call i64 @malloc(i64 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %1
%9 = inttoptr i64 %2 to i8*
ret i8* %9
}
/* Variables and functions */
int floor(float);
float numeroArrotondatoACentesimi(float x) { return floor(x * 100 + .5) / 100; }


x86 assembly (clang, -O0):
<numeroArrotondatoACentesimi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xee3(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeca(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <floor@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numeroArrotondatoACentesimi>:
push   %rax
mulss  0xee7(%rip),%xmm0
addss  0xee3(%rip),%xmm0
call   1030 <floor@plt>
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @numeroArrotondatoACentesimi(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fmul float %3, 1.000000e+02
%5 = fpext float %4 to double
%6 = fadd double %5, 5.000000e-01
%7 = fptrunc double %6 to float
%8 = call i32 @floor(float %7)
%9 = sdiv i32 %8, 100
%10 = sitofp i32 %9 to float
ret float %10
}

LLVM IR (-O2):
define float @numeroArrotondatoACentesimi(float %0) {
%2 = fmul float %0, 1.000000e+02
%3 = fadd float %2, 5.000000e-01
%4 = tail call i32 @floor(float %3)
%5 = sdiv i32 %4, 100
%6 = sitofp i32 %5 to float
ret float %6
}
cbuf32(f, n) int f, n;
{ cbuf(f, n, 32); }


x86 assembly (clang, -O0):
<cbuf32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x20,%edx
mov    $0x0,%al
call   1030 <cbuf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbuf32>:
mov    $0x20,%edx
xor    %eax,%eax
jmp    1030 <cbuf@plt>

LLVM IR (-O0):
define i32 @cbuf32(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 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @cbuf to i32 (i32, i32, i32, ...)*)(i32 %6, i32 %7, i32 32)
%9 = load i32, i32* %3
ret i32 %9
}

LLVM IR (-O2):
define i32 @cbuf32(i32 %0, i32 %1) {
%3 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @cbuf to i32 (i32, i32, i32, ...)*)(i32 %0, i32 %1, i32 32)
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ striaF(int);
void striaF2(int x) { striaF(x); }


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

x86 assembly (clang, -O2):
<striaF2>:
jmp    1030 <striaF@plt>

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

LLVM IR (-O2):
define void @striaF2(i32 %0) {
%2 = tail call i32 @striaF(i32 %0)
ret void
}
void RTLogSetGroupLimit(void) {}


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

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

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

LLVM IR (-O2):
define void @RTLogSetGroupLimit() {
ret void
}
void quicksort_omp_tasks(double *v, int low, int high) {}


x86 assembly (clang, -O0):
<quicksort_omp_tasks>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @quicksort_omp_tasks(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
ret void
}

LLVM IR (-O2):
define void @quicksort_omp_tasks(double* nocapture %0, i32 %1, i32 %2) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void printLine() {
  printf("---------------------------------------------------------------------"
         "\n");
}


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

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

LLVM IR (-O0):
@.str = [71 x i8] c"---------------------------------------------------------------------\0A\00"
define void @printLine() {
%1 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [70 x i8] c"---------------------------------------------------------------------\00"
define void @printLine() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
ret void
}
void call(unsigned long addr, unsigned long bist) {
  asm volatile("jmp *%0\n\t" : : "r"(addr), "a"(bist));
}


x86 assembly (clang, -O0):
<call>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
jmp    *%rcx
pop    %rbp
ret

x86 assembly (clang, -O2):
<call>:
mov    %rsi,%rax
jmp    *%rdi
ret

LLVM IR (-O0):
define void @call(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = load i64, i64* %4
ret void
}

LLVM IR (-O2):
define void @call(i64 %0, i64 %1) {
tail call void asm sideeffect "jmp *$0\0A\09", "r,{ax},~{dirflag},~{fpsr},~{flags}"(i64 %0, i64 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ free(void *);
void test24_free(void *p) { free(p); }


x86 assembly (clang, -O0):
<test24_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test24_free>:
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @test24_free(i8* nocapture %0) {
%2 = tail call i32 @free(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void fixedArray() {
  char fixedArray[6] = "hello";
  printf("%s\n", fixedArray);
}


x86 assembly (clang, -O0):
<fixedArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xee2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xedc(%rip),%ax
mov    %ax,-0x2(%rbp)
lea    -0x6(%rbp),%rsi
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixedArray>:
push   %rax
movw   $0x6f,0x4(%rsp)
movl   $0x6c6c6568,(%rsp)
lea    0xee0(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@__const.fixedArray.fixedArray = [6 x i8] c"hello\00"
@.str = [4 x i8] c"%s\0A\00"
define void @fixedArray() {
%1 = alloca [6 x i8]
%2 = bitcast [6 x i8]* %1 to i8*
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}

LLVM IR (-O2):
@__const.fixedArray.fixedArray = [6 x i8] c"hello\00"
@.str = [4 x i8] c"%s\0A\00"
define void @fixedArray() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ free(unsigned char **);
int /*<<< orphan*/ freeCharVector(unsigned char *);
void freeCharMatrix(unsigned char **matrix, int rows) {
  int i;
  for (i = 0; i < rows; i++)
    freeCharVector(matrix[i]);
  free(matrix);
}


x86 assembly (clang, -O0):
<freeCharMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1161 <freeCharMatrix+0x41>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <freeCharVector@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <freeCharMatrix+0x16>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeCharMatrix>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
jle    1152 <freeCharMatrix+0x32>
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1040 <freeCharVector@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <freeCharMatrix+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @freeCharMatrix(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %17, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i8**, i8*** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @freeCharVector(i8* %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %6
20: ; preds = %6
%21 = load i8**, i8*** %3
%22 = call i32 @free(i8** %21)
ret void
}

LLVM IR (-O2):
define void @freeCharMatrix(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %11, %6 ]
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @freeCharVector(i8* %9)
%11 = add nuw nsw i64 %7, 1
%12 = icmp eq i64 %11, %5
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = tail call i32 @free(i8** %0)
ret void
}
int strcnt(const char *str, char ch) {
  int result = 0;
  for (char *iter = (char *)str; *iter; iter++)
    if (*iter == ch)
      result++;
  return result;
}


x86 assembly (clang, -O0):
<strcnt>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     115c <strcnt+0x5c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    1146 <strcnt+0x46>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114b <strcnt+0x4b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    111d <strcnt+0x1d>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcnt>:
mov    (%rdi),%cl
test   %cl,%cl
je     1126 <strcnt+0x26>
add    $0x1,%rdi
xor    %eax,%eax
nopl   0x0(%rax)
xor    %edx,%edx
cmp    %sil,%cl
sete   %dl
add    %edx,%eax
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
jne    1110 <strcnt+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @strcnt(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %7, %2
%6 = phi i32 [ 0, %2 ], [ %13, %7 ]
ret i32 %6
7: ; preds = %2, %7
%8 = phi i8 [ %15, %7 ], [ %3, %2 ]
%9 = phi i8* [ %14, %7 ], [ %0, %2 ]
%10 = phi i32 [ %13, %7 ], [ 0, %2 ]
%11 = icmp eq i8 %8, %1
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %10, %12
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %5, label %7
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
void vulnerable(void) {
  char name[256];
  printf("buffer is at %p\n", name);
  printf("Hello, what is your name?\n");
  scanf("%s", name);
  printf("Welcome %s\n", name);
}


x86 assembly (clang, -O0):
<vulnerable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    -0x100(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x100(%rbp),%rsi
lea    0xed0(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x100(%rbp),%rsi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vulnerable>:
push   %rbx
sub    $0x100,%rsp
lea    0xec1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"buffer is at %p\0A\00"
@.str.1 = [27 x i8] c"Hello, what is your name?\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [12 x i8] c"Welcome %s\0A\00"
define void @vulnerable() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"buffer is at %p\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [12 x i8] c"Welcome %s\0A\00"
@str = [26 x i8] c"Hello, what is your name?\00"
define void @vulnerable() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ SA1Immediate8(int);
int /*<<< orphan*/ SBC8(int /*<<< orphan*/);
void OpE9M1(void) { SBC8(SA1Immediate8(1)); }


x86 assembly (clang, -O0):
<OpE9M1>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%edi
call   1030 <SA1Immediate8@plt>
mov    %eax,%edi
call   1040 <SBC8@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<OpE9M1>:
push   %rax
mov    $0x1,%edi
call   1030 <SA1Immediate8@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <SBC8@plt>

LLVM IR (-O0):
define void @OpE9M1() {
%1 = call i32 @SA1Immediate8(i32 1)
%2 = call i32 @SBC8(i32 %1)
ret void
}

LLVM IR (-O2):
define void @OpE9M1() {
%1 = tail call i32 @SA1Immediate8(i32 1)
%2 = tail call i32 @SBC8(i32 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ indigoFree(int);
int indigoSaveCml(int, int);
int indigoWriteFile(char const *);
__attribute__((visibility("default"))) int
indigoSaveCmlToFile(int molecule, const char *filename) {
  int f = indigoWriteFile(filename);
  int res;
  if (f == -1)
    return -1;
  res = indigoSaveCml(molecule, f);
  indigoFree(f);
  return res;
}


x86 assembly (clang, -O0):
<indigoSaveCmlToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <indigoWriteFile@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1161 <indigoSaveCmlToFile+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    117d <indigoSaveCmlToFile+0x4d>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <indigoSaveCml@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <indigoFree@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<indigoSaveCmlToFile>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <indigoWriteFile@plt>
cmp    $0xffffffff,%eax
je     115a <indigoSaveCmlToFile+0x2a>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <indigoSaveCml@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <indigoFree@plt>
mov    %ebp,%eax
jmp    115f <indigoSaveCmlToFile+0x2f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @indigoSaveCmlToFile(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @indigoWriteFile(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %20
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i32, i32* %6
%16 = call i32 @indigoSaveCml(i32 %14, i32 %15)
store i32 %16, i32* %7
%17 = load i32, i32* %6
%18 = call i32 @indigoFree(i32 %17)
%19 = load i32, i32* %7
store i32 %19, i32* %3
br label %20
20: ; preds = %13, %12
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
define i32 @indigoSaveCmlToFile(i32 %0, i8* %1) {
%3 = tail call i32 @indigoWriteFile(i8* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @indigoSaveCml(i32 %0, i32 %3)
%7 = tail call i32 @indigoFree(i32 %3)
br label %8
8: ; preds = %2, %5
%9 = phi i32 [ %6, %5 ], [ -1, %2 ]
ret i32 %9
}
void pcnt_init(void) {}


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

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

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

LLVM IR (-O2):
define void @pcnt_init() {
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int service_postgres_init(char *ip, int sp, unsigned char options,
                          char *miscptr, FILE *fp, int port, char *hostname) {
  return 0;
}


x86 assembly (clang, -O0):
<service_postgres_init>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    0x10(%rbp),%rdx
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<service_postgres_init>:
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @service_postgres_init(i8* %0, i32 %1, i8 zeroext %2, i8* %3, i32* %4, i32 %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i8*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8 %2, i8* %10
store i8* %3, i8** %11
store i32* %4, i32** %12
store i32 %5, i32* %13
store i8* %6, i8** %14
ret i32 0
}

LLVM IR (-O2):
define i32 @service_postgres_init(i8* nocapture readnone %0, i32 %1, i8 zeroext %2, i8* nocapture readnone %3, i32* nocapture readnone %4, i32 %5, i8* nocapture readnone %6) {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
void show_error(char *error_text) {
  printf("%s\n", error_text);
  printf("...now exiting to system...\n");
  exit(1);
}


x86 assembly (clang, -O0):
<show_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<show_error>:
push   %rax
call   1030 <puts@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [29 x i8] c"...now exiting to system...\0A\00"
define void @show_error(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@str = [28 x i8] c"...now exiting to system...\00"
define void @show_error(i8* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) %0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @exit(i32 1)
unreachable
}
unsigned int pc2int(unsigned int switchtype, unsigned char *p) {
  if (switchtype == (1 << 1)) {
    return p[0] | (p[1] << 8) | (p[2] << 16);
  } else {
    return (p[0] | (p[1] << 8)) & 0x3fff;
  }
}


x86 assembly (clang, -O0):
<pc2int>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    113e <pc2int+0x3e>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    115a <pc2int+0x5a>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
and    $0x3fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pc2int>:
movzbl 0x1(%rsi),%ecx
shl    $0x8,%ecx
movzbl (%rsi),%eax
cmp    $0x2,%edi
jne    111b <pc2int+0x1b>
or     %eax,%ecx
movzbl 0x2(%rsi),%eax
shl    $0x10,%eax
or     %ecx,%eax
ret
and    $0x3f00,%ecx
or     %eax,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @pc2int(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %25
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = shl i32 %16, 8
%18 = or i32 %12, %17
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl i32 %22, 16
%24 = or i32 %18, %23
store i32 %24, i32* %3
br label %37
25: ; preds = %2
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl i32 %33, 8
%35 = or i32 %29, %34
%36 = and i32 %35, 16383
store i32 %36, i32* %3
br label %37
37: ; preds = %25, %8
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @pc2int(i32 %0, i8* nocapture %1) {
%3 = icmp eq i32 %0, 2
%4 = load i8, i8* %1
%5 = zext i8 %4 to i32
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = shl nuw nsw i32 %8, 8
br i1 %3, label %10, label %17
10: ; preds = %2
%11 = or i32 %9, %5
%12 = getelementptr inbounds i8, i8* %1, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 16
%16 = or i32 %11, %15
br label %20
17: ; preds = %2
%18 = and i32 %9, 16128
%19 = or i32 %18, %5
br label %20
20: ; preds = %17, %10
%21 = phi i32 [ %16, %10 ], [ %19, %17 ]
ret i32 %21
}
const char *gai_strerror(int errcode) { return "getaddrinfo error"; }


x86 assembly (clang, -O0):
<gai_strerror>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    0xef2(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gai_strerror>:
lea    0xef9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [18 x i8] c"getaddrinfo error\00"
define i8* @gai_strerror(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [18 x i8] c"getaddrinfo error\00"
define i8* @gai_strerror(i32 %0) {
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0)
}
void X509_NAME_ENTRY_new(void) {}


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

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

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

LLVM IR (-O2):
define void @X509_NAME_ENTRY_new() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ triangles_in_the_term(int, int);
int main(void) {
  triangles_in_the_term(10, 3);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
mov    $0x3,%esi
call   1030 <triangles_in_the_term@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
mov    $0x3,%esi
call   1030 <triangles_in_the_term@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @triangles_in_the_term(i32 10, i32 3)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @triangles_in_the_term(i32 10, i32 3)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_version() {
  printf("\n%s\n", "multicore-hashjoins 0.1");
  printf("Copyright (c) 2012, ETH Zurich, Systems Group.\n");
  printf("http://www.systems.ethz.ch/projects/paralleljoins\n\n");
}


x86 assembly (clang, -O0):
<print_version>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee3(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_version>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0xed6(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf03(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [24 x i8] c"multicore-hashjoins 0.1\00"
@.str.2 = [48 x i8] c"Copyright (c) 2012, ETH Zurich, Systems Group.\0A\00"
@.str.3 = [52 x i8] c"http://www.systems.ethz.ch/projects/paralleljoins\0A\0A\00"
define void @print_version() {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [24 x i8] c"multicore-hashjoins 0.1\00"
@str = [47 x i8] c"Copyright (c) 2012, ETH Zurich, Systems Group.\00"
@str.4 = [51 x i8] c"http://www.systems.ethz.ch/projects/paralleljoins\0A\00"
define void @print_version() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.4, i64 0, i64 0))
ret void
}
/* Variables and functions */
int mkdir(char const *, int);
int makedir(const char *dir) { return mkdir(dir, 0700); }


x86 assembly (clang, -O0):
<makedir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makedir>:
mov    $0x1c0,%esi
jmp    1030 <mkdir@plt>

LLVM IR (-O0):
define i32 @makedir(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @mkdir(i8* %3, i32 448)
ret i32 %4
}

LLVM IR (-O2):
define i32 @makedir(i8* nocapture %0) {
%2 = tail call i32 @mkdir(i8* %0, i32 448)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ pump_ex(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ restore_stdin();
int /*<<< orphan*/ watch_sigwinch_cleanup();
void pump_stdout_blocking(int infd) {
  pump_ex(infd, STDOUT_FILENO, 0);
  restore_stdin();
  watch_sigwinch_cleanup();
}


x86 assembly (clang, -O0):
<pump_stdout_blocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2eab(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <pump_ex@plt>
mov    $0x0,%al
call   1050 <restore_stdin@plt>
mov    $0x0,%al
call   1040 <watch_sigwinch_cleanup@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pump_stdout_blocking>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <pump_ex@plt>
xor    %eax,%eax
call   1050 <restore_stdin@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <watch_sigwinch_cleanup@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
define void @pump_stdout_blocking(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @STDOUT_FILENO
%5 = call i32 @pump_ex(i32 %3, i32 %4, i32 0)
%6 = call i32 (...) @restore_stdin()
%7 = call i32 (...) @watch_sigwinch_cleanup()
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
define void @pump_stdout_blocking(i32 %0) {
%2 = load i32, i32* @STDOUT_FILENO
%3 = tail call i32 @pump_ex(i32 %0, i32 %2, i32 0)
%4 = tail call i32 (...) @restore_stdin()
%5 = tail call i32 (...) @watch_sigwinch_cleanup()
ret void
}
void free(void *p) {}


x86 assembly (clang, -O0):
<free>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @free(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
ret void
}

LLVM IR (-O2):
define void @free(i8* nocapture %0) {
ret void
}
void signal_ignore_handler(int signal) { (void)signal; }


x86 assembly (clang, -O0):
<signal_ignore_handler>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @signal_ignore_handler(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ adb_all_keys_up();
int /*<<< orphan*/ clear_fatal_logs();
int x_show_alert(int is_fatal, const char *str) {
  adb_all_keys_up();
  clear_fatal_logs();
  return 0;
}


x86 assembly (clang, -O0):
<x_show_alert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <adb_all_keys_up@plt>
mov    $0x0,%al
call   1040 <clear_fatal_logs@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x_show_alert>:
push   %rax
xor    %eax,%eax
call   1030 <adb_all_keys_up@plt>
xor    %eax,%eax
call   1040 <clear_fatal_logs@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @x_show_alert(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = call i32 (...) @adb_all_keys_up()
%6 = call i32 (...) @clear_fatal_logs()
ret i32 0
}

LLVM IR (-O2):
define i32 @x_show_alert(i32 %0, i8* nocapture readnone %1) {
%3 = tail call i32 (...) @adb_all_keys_up()
%4 = tail call i32 (...) @clear_fatal_logs()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void help() {
  printf(
      "Usage: bin2asm [OPTION...] FILE\n\n"
      "  --offset=NUM                    Skip NUM bytes of input\n"
      "  --length=NUM                    Process at most NUM bytes of input\n"
      "  --output=FILE                   Write output to FILE\n"
      "  --help                          Give this help list\n"
      "  --usage                         Give a short usage message\n"
      "  --version                       Print program version\n");
  exit(0);
}


x86 assembly (clang, -O0):
<help>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<help>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [387 x i8] c"Usage: bin2asm [OPTION...] FILE\0A\0A --offset=NUM Skip NUM bytes of input\0A --length=NUM Process at most NUM bytes of input\0A --output=FILE Write output to FILE\0A --help Give this help list\0A --usage Give a short usage message\0A --version Print program version\0A\00"
define void @help() {
%1 = call i32 @printf(i8* getelementptr inbounds ([387 x i8], [387 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [386 x i8] c"Usage: bin2asm [OPTION...] FILE\0A\0A --offset=NUM Skip NUM bytes of input\0A --length=NUM Process at most NUM bytes of input\0A --output=FILE Write output to FILE\0A --help Give this help list\0A --usage Give a short usage message\0A --version Print program version\00"
define void @help() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([386 x i8], [386 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @exit(i32 0)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ return_int5();
int /*<<< orphan*/ take_int5(int /*<<< orphan*/);
void no_lifetime_markers() { take_int5(return_int5()); }


x86 assembly (clang, -O0):
<no_lifetime_markers>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <return_int5@plt>
mov    %eax,%edi
call   1030 <take_int5@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<no_lifetime_markers>:
push   %rax
xor    %eax,%eax
call   1040 <return_int5@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <take_int5@plt>

LLVM IR (-O0):
define void @no_lifetime_markers() {
%1 = call i32 (...) @return_int5()
%2 = call i32 @take_int5(i32 %1)
ret void
}

LLVM IR (-O2):
define void @no_lifetime_markers() {
%1 = tail call i32 (...) @return_int5()
%2 = tail call i32 @take_int5(i32 %1)
ret void
}
/* Variables and functions */
void *malloc(size_t);
void *memcpy(void *, void *, size_t);
void *_yada_memdup(void *src, size_t len) {
  void *buf;
  if (!(buf = malloc(len)))
    return (0);
  return (memcpy(buf, src, len));
}


x86 assembly (clang, -O0):
<_yada_memdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1154 <_yada_memdup+0x34>
movq   $0x0,-0x8(%rbp)
jmp    1169 <_yada_memdup+0x49>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <memcpy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_yada_memdup>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1149 <_yada_memdup+0x29>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @_yada_memdup(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
%7 = load i64, i64* %5
%8 = call i8* @malloc(i64 %7)
store i8* %8, i8** %6
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
store i8* null, i8** %3
br label %16
11: ; preds = %2
%12 = load i8*, i8** %6
%13 = load i8*, i8** %4
%14 = load i64, i64* %5
%15 = call i8* @memcpy(i8* %12, i8* %13, i64 %14)
store i8* %15, i8** %3
br label %16
16: ; preds = %11, %10
%17 = load i8*, i8** %3
ret i8* %17
}

LLVM IR (-O2):
define noalias i8* @_yada_memdup(i8* nocapture %0, i64 %1) {
%3 = tail call i8* @malloc(i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %6, label %5
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %0, i64 %1, i1 false)
br label %6
6: ; preds = %2, %5
ret i8* %3
}
void null_terminate(char *line, char chr) {
  char *c;
  for (c = line; *c != (char)0; c++)
    if (*c == chr) {
      *c = (char)0;
      break;
    }
}


x86 assembly (clang, -O0):
<null_terminate>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     115b <null_terminate+0x5b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    1145 <null_terminate+0x45>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    115b <null_terminate+0x5b>
jmp    114a <null_terminate+0x4a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1116 <null_terminate+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<null_terminate>:
mov    (%rdi),%al
test   %al,%al
je     1120 <null_terminate+0x20>
add    $0x1,%rdi
nopw   0x0(%rax,%rax,1)
cmp    %sil,%al
je     1121 <null_terminate+0x21>
movzbl (%rdi),%eax
add    $0x1,%rdi
test   %al,%al
jne    1110 <null_terminate+0x10>
ret
movb   $0x0,-0x1(%rdi)
ret

LLVM IR (-O0):
define void @null_terminate(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
store i8* %0, i8** %3
store i8 %1, i8* %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
br label %7
7: ; preds = %22, %2
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %7
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = load i8*, i8** %5
store i8 0, i8* %20
br label %25
21: ; preds = %12
br label %22
22: ; preds = %21
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
br label %7
25: ; preds = %19, %7
ret void
}

LLVM IR (-O2):
define void @null_terminate(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %10
%6 = phi i8 [ %12, %10 ], [ %3, %2 ]
%7 = phi i8* [ %11, %10 ], [ %0, %2 ]
%8 = icmp eq i8 %6, %1
br i1 %8, label %9, label %10
9: ; preds = %5
store i8 0, i8* %7
br label %14
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %10, %2, %9
ret void
}
/* Type definitions */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
uint8_t tlm_encode_wspr_vbat(uint16_t voltage) {
  if (voltage < 3500) {
    return 0;
  }
  if (voltage > 4999) {
    return 14;
  }
  return (voltage / 100) - 35;
}


x86 assembly (clang, -O0):
<tlm_encode_wspr_vbat>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xdac,-0x8(%rbp)
jge    1120 <tlm_encode_wspr_vbat+0x20>
movl   $0x0,-0x4(%rbp)
jmp    114a <tlm_encode_wspr_vbat+0x4a>
cmpl   $0x1387,-0x8(%rbp)
jle    1139 <tlm_encode_wspr_vbat+0x39>
movl   $0xe,-0x4(%rbp)
jmp    114a <tlm_encode_wspr_vbat+0x4a>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
sub    $0x23,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tlm_encode_wspr_vbat>:
xor    %eax,%eax
cmp    $0xdac,%edi
jl     1129 <tlm_encode_wspr_vbat+0x29>
mov    $0xe,%eax
cmp    $0x1387,%edi
ja     1129 <tlm_encode_wspr_vbat+0x29>
movzwl %di,%eax
shr    $0x2,%eax
imul   $0x147b,%eax,%eax
shr    $0x11,%eax
add    $0xffffffdd,%eax
ret

LLVM IR (-O0):
define i32 @tlm_encode_wspr_vbat(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 3500
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %15
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 4999
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 14, i32* %2
br label %15
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 100
%14 = sub nsw i32 %13, 35
store i32 %14, i32* %2
br label %15
15: ; preds = %11, %10, %6
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @tlm_encode_wspr_vbat(i32 %0) {
%2 = icmp slt i32 %0, 3500
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = icmp ugt i32 %0, 4999
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = trunc i32 %0 to i16
%7 = udiv i16 %6, 100
%8 = zext i16 %7 to i32
%9 = add nsw i32 %8, -35
br label %10
10: ; preds = %3, %1, %5
%11 = phi i32 [ %9, %5 ], [ 0, %1 ], [ 14, %3 ]
ret i32 %11
}