xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int a[12] = {1, 3, 5, 4, 7, 2, 99, 16, 45, 67, 89, 45};
  int i;
  int total = 0;
  for (i = 0; i < 12; i++) {
    total += a[i];
  }
  printf("Total of array element values is %d\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0xc,-0x44(%rbp)
jge    1178 <main+0x58>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1152 <main+0x32>
mov    -0x48(%rbp),%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.main.a = [12 x i32] [i32 1, i32 3, i32 5, i32 4, i32 7, i32 2, i32 99, i32 16, i32 45, i32 67, i32 89, i32 45]
@.str = [37 x i8] c"Total of array element values is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [12 x i32]* %2 to i8*
store i32 0, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 12
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = load i32, i32* %4
%15 = add nsw i32 %14, %13
store i32 %15, i32* %4
br label %16
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %6
19: ; preds = %6
%20 = load i32, i32* %4
%21 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Total of array element values is %d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 383)
ret i32 0
}
void *mem_malloc(unsigned long size, char pool_class) {
  void *tmp = malloc(size + sizeof(unsigned long));
  ((unsigned long *)tmp)[0] = size;
  return ((char *)tmp + sizeof(unsigned long));
}


x86 assembly (clang, -O0):
<mem_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_malloc>:
push   %rbx
mov    %rdi,%rbx
add    $0x8,%rdi
call   1030 <malloc@plt>
mov    %rbx,(%rax)
add    $0x8,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @mem_malloc(i64 %0, i8 signext %1) {
%3 = alloca i64
%4 = alloca i8
%5 = alloca i8*
store i64 %0, i64* %3
store i8 %1, i8* %4
%6 = load i64, i64* %3
%7 = add i64 %6, 8
%8 = call i8* @malloc(i64 %7)
store i8* %8, i8** %5
%9 = load i64, i64* %3
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i64*
%12 = getelementptr inbounds i64, i64* %11, i64 0
store i64 %9, i64* %12
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 8
ret i8* %14
}

LLVM IR (-O2):
define noalias i8* @mem_malloc(i64 %0, i8 signext %1) {
%3 = add i64 %0, 8
%4 = tail call i8* @malloc(i64 %3)
%5 = bitcast i8* %4 to i64*
store i64 %0, i64* %5
%6 = getelementptr inbounds i8, i8* %4, i64 8
ret i8* %6
}
void SetMICR(unsigned long global, unsigned long local) {
  *(unsigned long *)(0x100000) = global;
  *(unsigned long *)(0x100004) = local;
}


x86 assembly (clang, -O0):
<SetMICR>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
mov    $0x100000,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    $0x100004,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetMICR>:
mov    %rdi,0x100000
mov    %rsi,0x100004
ret

LLVM IR (-O0):
define void @SetMICR(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
store i64 %5, i64* inttoptr (i64 1048576 to i64*)
%6 = load i64, i64* %4
store i64 %6, i64* inttoptr (i64 1048580 to i64*)
ret void
}

LLVM IR (-O2):
define void @SetMICR(i64 %0, i64 %1) {
store i64 %0, i64* inttoptr (i64 1048576 to i64*)
store i64 %1, i64* inttoptr (i64 1048580 to i64*)
ret void
}
void os_blink_on(void) { *(volatile unsigned int *)0x20200028 = 1 << 16; }


x86 assembly (clang, -O0):
<os_blink_on>:
push   %rbp
mov    %rsp,%rbp
mov    $0x20200028,%eax
movl   $0x10000,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_blink_on>:
movl   $0x10000,0x20200028
ret

LLVM IR (-O0):
define void @os_blink_on() {
store volatile i32 65536, i32* inttoptr (i64 538968104 to i32*)
ret void
}

LLVM IR (-O2):
define void @os_blink_on() {
store volatile i32 65536, i32* inttoptr (i64 538968104 to i32*)
ret void
}
/* Variables and functions */
int _ada_use_c2phc4c(int, int *, int *, double *, int /*<<< orphan*/);
int clear_multprec_homotopy(void) {
  int *a, *b, fail;
  double *c;
  fail = _ada_use_c2phc4c(524, a, b, c, 0);
  return fail;
}


x86 assembly (clang, -O0):
<clear_multprec_homotopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x20c,%edi
xor    %r8d,%r8d
call   1030 <_ada_use_c2phc4c@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_multprec_homotopy>:
mov    $0x20c,%edi
xor    %r8d,%r8d
jmp    1030 <_ada_use_c2phc4c@plt>

LLVM IR (-O0):
define i32 @clear_multprec_homotopy() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32
%4 = alloca double*
%5 = load i32*, i32** %1
%6 = load i32*, i32** %2
%7 = load double*, double** %4
%8 = call i32 @_ada_use_c2phc4c(i32 524, i32* %5, i32* %6, double* %7, i32 0)
store i32 %8, i32* %3
%9 = load i32, i32* %3
ret i32 %9
}

LLVM IR (-O2):
define i32 @clear_multprec_homotopy() {
%1 = tail call i32 @_ada_use_c2phc4c(i32 524, i32* undef, i32* undef, double* undef, i32 0)
ret i32 %1
}
int f(long long a, int b) {
  int c = a;
  return c + b;
}


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

x86 assembly (clang, -O2):
<f>:
lea    (%rdi,%rsi,1),%eax
ret

LLVM IR (-O0):
define i32 @f(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
%6 = load i64, i64* %3
%7 = trunc i64 %6 to i32
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = add nsw i32 %8, %9
ret i32 %10
}

LLVM IR (-O2):
define i32 @f(i64 %0, i32 %1) {
%3 = trunc i64 %0 to i32
%4 = add nsw i32 %3, %1
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *);
void talesprint(const char *s) { printf("%s", s); }


x86 assembly (clang, -O0):
<talesprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<talesprint>:
mov    %rdi,%rsi
lea    0xee6(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @talesprint(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @talesprint(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
void sws_convertPalette8ToPacked24() {}


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

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

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

LLVM IR (-O2):
define void @sws_convertPalette8ToPacked24() {
ret void
}
int mod(int a, int b) {
  int r = a % b;
  return r >= 0 ? r : r + b;
}


x86 assembly (clang, -O0):
<mod>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1129 <mod+0x29>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1132 <mod+0x32>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod>:
mov    %edi,%eax
cltd
idiv   %esi
mov    %edx,%eax
sar    $0x1f,%eax
and    %esi,%eax
add    %edx,%eax
ret

LLVM IR (-O0):
define i32 @mod(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* %4
%8 = srem i32 %6, %7
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* %5
br label %17
13: ; preds = %2
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = add nsw i32 %14, %15
br label %17
17: ; preds = %13, %11
%18 = phi i32 [ %12, %11 ], [ %16, %13 ]
ret i32 %18
}

LLVM IR (-O2):
define i32 @mod(i32 %0, i32 %1) {
%3 = srem i32 %0, %1
%4 = icmp slt i32 %3, 0
%5 = select i1 %4, i32 %1, i32 0
%6 = add nsw i32 %5, %3
ret i32 %6
}
/* Type definitions */
typedef int uint64_t;

/* Variables and functions */
int bpf_rand_mask(int);
uint64_t bpf_rand_u8(int shift) { return bpf_rand_mask((0xffULL)) << shift; }


x86 assembly (clang, -O0):
<bpf_rand_u8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0xff,%edi
call   1030 <bpf_rand_mask@plt>
mov    -0x4(%rbp),%ecx
shl    %cl,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_rand_u8>:
push   %rbx
mov    %edi,%ebx
mov    $0xff,%edi
call   1030 <bpf_rand_mask@plt>
mov    %ebx,%ecx
shl    %cl,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @bpf_rand_u8(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @bpf_rand_mask(i32 255)
%4 = load i32, i32* %2
%5 = shl i32 %3, %4
ret i32 %5
}

LLVM IR (-O2):
define i32 @bpf_rand_u8(i32 %0) {
%2 = tail call i32 @bpf_rand_mask(i32 255)
%3 = shl i32 %2, %0
ret i32 %3
}
double sqr(double v) {
  return v * v;
  __builtin_unreachable();
}


x86 assembly (clang, -O0):
<sqr>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqr>:
mulsd  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @sqr(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = load double, double* %2
%5 = fmul double %3, %4
ret double %5
}

LLVM IR (-O2):
define double @sqr(double %0) {
%2 = fmul double %0, %0
ret double %2
}
int divisao(int dividendo, int divisor, int *resto) {
  *resto = dividendo / divisor;
  return 0;
}


x86 assembly (clang, -O0):
<divisao>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<divisao>:
mov    %rdx,%rcx
mov    %edi,%eax
cltd
idiv   %esi
mov    %eax,(%rcx)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @divisao(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = sdiv i32 %0, %1
store i32 %4, i32* %2
ret i32 0
}
short STEST907(long v) { return v + 3; }


x86 assembly (clang, -O0):
<STEST907>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x3,%rax
cwtl
pop    %rbp
ret

x86 assembly (clang, -O2):
<STEST907>:
lea    0x3(%rdi),%eax
ret

LLVM IR (-O0):
define signext i16 @STEST907(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = add nsw i64 %3, 3
%5 = trunc i64 %4 to i16
ret i16 %5
}

LLVM IR (-O2):
define signext i16 @STEST907(i64 %0) {
%2 = trunc i64 %0 to i16
%3 = add i16 %2, 3
ret i16 %3
}
/* Type definitions */
typedef int uint64_t;

/* Variables and functions */
uint64_t backf64_t(uint64_t number) {
  if (number >> 63)
    return number ^ 0x8000000000000000;
  return number ^ 0xffffffffffffffff;
}


x86 assembly (clang, -O0):
<backf64_t>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3f,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
je     1133 <backf64_t+0x33>
movslq -0x8(%rbp),%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    113e <backf64_t+0x3e>
movslq -0x8(%rbp),%rax
xor    $0xffffffffffffffff,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<backf64_t>:
mov    %edi,%eax
not    %eax
ret

LLVM IR (-O0):
define i32 @backf64_t(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = ashr i32 %4, 63
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = xor i64 %9, -9223372036854775808
%11 = trunc i64 %10 to i32
store i32 %11, i32* %2
br label %17
12: ; preds = %1
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = xor i64 %14, -1
%16 = trunc i64 %15 to i32
store i32 %16, i32* %2
br label %17
17: ; preds = %12, %7
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @backf64_t(i32 %0) {
%2 = xor i32 %0, -1
ret i32 %2
}
int get_pos_interval(float z, float dz) {
  int interval = (int)(z / dz);
  return interval;
}


x86 assembly (clang, -O0):
<get_pos_interval>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pos_interval>:
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
ret

LLVM IR (-O0):
define i32 @get_pos_interval(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store float %0, float* %3
store float %1, float* %4
%6 = load float, float* %3
%7 = load float, float* %4
%8 = fdiv float %6, %7
%9 = fptosi float %8 to i32
store i32 %9, i32* %5
%10 = load i32, i32* %5
ret i32 %10
}

LLVM IR (-O2):
define i32 @get_pos_interval(float %0, float %1) {
%3 = fdiv float %0, %1
%4 = fptosi float %3 to i32
ret i32 %4
}
int abs_diff(int i, int j) {
  int k = i - j;
  if (k < 0)
    k -= k;
  return k;
}


x86 assembly (clang, -O0):
<abs_diff>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1128 <abs_diff+0x28>
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<abs_diff>:
xor    %eax,%eax
sub    %esi,%edi
cmovns %edi,%eax
ret

LLVM IR (-O0):
define i32 @abs_diff(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* %4
%8 = sub nsw i32 %6, %7
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %5
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, %12
store i32 %14, i32* %5
br label %15
15: ; preds = %11, %2
%16 = load i32, i32* %5
ret i32 %16
}

LLVM IR (-O2):
define i32 @abs_diff(i32 %0, i32 %1) {
%3 = sub nsw i32 %0, %1
%4 = icmp sgt i32 %3, 0
%5 = select i1 %4, i32 %3, i32 0
ret i32 %5
}
/* Type definitions */
struct slot {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ slot_skip_update(struct slot *);
void slot_read(struct slot *s) { slot_skip_update(s); }


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

x86 assembly (clang, -O2):
<slot_read>:
jmp    1030 <slot_skip_update@plt>

LLVM IR (-O0):
%struct.slot = type { i32 }
define void @slot_read(%struct.slot* %0) {
%2 = alloca %struct.slot*
store %struct.slot* %0, %struct.slot** %2
%3 = load %struct.slot*, %struct.slot** %2
%4 = call i32 @slot_skip_update(%struct.slot* %3)
ret void
}

LLVM IR (-O2):
%struct.slot = type { i32 }
define void @slot_read(%struct.slot* %0) {
%2 = tail call i32 @slot_skip_update(%struct.slot* %0)
ret void
}
unsigned char binary_search(const char *in_buf, unsigned int in_buf_len,
                            const char *in_seq, unsigned int in_seq_len,
                            unsigned int *out_pos) {
  return 0;
}


x86 assembly (clang, -O0):
<binary_search>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
xor    %eax,%eax
movzbl %al,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define zeroext i8 @binary_search(i8* %0, i32 %1, i8* %2, i32 %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
ret i8 0
}

LLVM IR (-O2):
define zeroext i8 @binary_search(i8* nocapture readnone %0, i32 %1, i8* nocapture readnone %2, i32 %3, i32* nocapture readnone %4) {
ret i8 0
}
/* Type definitions */
struct sk_buff {
  int dummy;
};
struct net_device {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ LOG_MSG(char *);
int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) {
  LOG_MSG("rtl8169_start_xmit is called\n");
  return 0;
}


x86 assembly (clang, -O0):
<rtl8169_start_xmit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
call   1030 <LOG_MSG@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.sk_buff = type { i32 }
%struct.net_device = type { i32 }
@.str = [30 x i8] c"rtl8169_start_xmit is called\0A\00"
define i32 @rtl8169_start_xmit(%struct.sk_buff* %0, %struct.net_device* %1) {
%3 = alloca %struct.sk_buff*
%4 = alloca %struct.net_device*
store %struct.sk_buff* %0, %struct.sk_buff** %3
store %struct.net_device* %1, %struct.net_device** %4
%5 = call i32 @LOG_MSG(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.sk_buff = type { i32 }
%struct.net_device = type { i32 }
@.str = [30 x i8] c"rtl8169_start_xmit is called\0A\00"
define i32 @rtl8169_start_xmit(%struct.sk_buff* nocapture readnone %0, %struct.net_device* nocapture readnone %1) {
%3 = tail call i32 @LOG_MSG(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
int main() {
  char *s = "hello\0";
  for (; *s = '\0'; s++)
    printf("%s", *s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
test   $0x1,%al
jne    1140 <main+0x30>
jmp    1166 <main+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112a <main+0x1a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [7 x i8] c"hello\00\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
br label %3
3: ; preds = %10, %0
%4 = load i8*, i8** %2
store i8 0, i8* %4
br i1 false, label %5, label %13
5: ; preds = %3
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %2
br label %3
13: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int skill_get_inf(int);
int guild_skill_get_inf(int id) { return skill_get_inf(id); }


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

x86 assembly (clang, -O2):
<guild_skill_get_inf>:
jmp    1030 <skill_get_inf@plt>

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

LLVM IR (-O2):
define i32 @guild_skill_get_inf(i32 %0) {
%2 = tail call i32 @skill_get_inf(i32 %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int load_lm32_main(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Use: \"%s <filename>\"\n", argv[0]);
  }
  return load_lm32_main(argv[1]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115c <main+0x3c>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xea9(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <load_lm32_main@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1141 <main+0x21>
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xec4(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x8(%rbx),%rdi
pop    %rbx
jmp    1030 <load_lm32_main@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Use: \22%s <filename>\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %8, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @load_lm32_main(i8* %17)
ret i32 %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Use: \22%s <filename>\22\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %4, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @load_lm32_main(i8* %10)
ret i32 %11
}
/* Type definitions */
struct rbtree_node {
  int dummy;
};

/* Variables and functions */
struct rbtree_node *__rbtree_end(struct rbtree_node *, int);
struct rbtree_node *rbtree_last(struct rbtree_node *tree) {
  return __rbtree_end(tree, 1);
}


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

x86 assembly (clang, -O2):
<rbtree_last>:
mov    $0x1,%esi
jmp    1030 <__rbtree_end@plt>

LLVM IR (-O0):
%struct.rbtree_node = type { i32 }
define %struct.rbtree_node* @rbtree_last(%struct.rbtree_node* %0) {
%2 = alloca %struct.rbtree_node*
store %struct.rbtree_node* %0, %struct.rbtree_node** %2
%3 = load %struct.rbtree_node*, %struct.rbtree_node** %2
%4 = call %struct.rbtree_node* @__rbtree_end(%struct.rbtree_node* %3, i32 1)
ret %struct.rbtree_node* %4
}

LLVM IR (-O2):
%struct.rbtree_node = type { i32 }
define %struct.rbtree_node* @rbtree_last(%struct.rbtree_node* %0) {
%2 = tail call %struct.rbtree_node* @__rbtree_end(%struct.rbtree_node* %0, i32 1)
ret %struct.rbtree_node* %2
}
/* Variables and functions */
int PAPI_read(int, long long *);
void papif_read_(int *EventSet, long long *values, int *check) {
  *check = PAPI_read(*EventSet, values);
}


x86 assembly (clang, -O0):
<papif_read_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1030 <PAPI_read@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<papif_read_>:
push   %rbx
mov    %rdx,%rbx
mov    (%rdi),%edi
call   1030 <PAPI_read@plt>
mov    %eax,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @papif_read_(i32* %0, i64* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i64*
%6 = alloca i32*
store i32* %0, i32** %4
store i64* %1, i64** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = load i64*, i64** %5
%10 = call i32 @PAPI_read(i32 %8, i64* %9)
%11 = load i32*, i32** %6
store i32 %10, i32* %11
ret void
}

LLVM IR (-O2):
define void @papif_read_(i32* nocapture %0, i64* %1, i32* nocapture writeonly %2) {
%4 = load i32, i32* %0
%5 = tail call i32 @PAPI_read(i32 %4, i64* %1)
store i32 %5, i32* %2
ret void
}
int gk20a_init_therm_reset_enable_hw(struct gk20a *g) { return 0; }


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

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

LLVM IR (-O0):
%struct.gk20a = type opaque
define i32 @gk20a_init_therm_reset_enable_hw(%struct.gk20a* %0) {
%2 = alloca %struct.gk20a*
store %struct.gk20a* %0, %struct.gk20a** %2
ret i32 0
}

LLVM IR (-O2):
%struct.gk20a = type opaque
define i32 @gk20a_init_therm_reset_enable_hw(%struct.gk20a* nocapture readnone %0) {
ret i32 0
}
/* Variables and functions */
int char2byte(char);
char *strtok(int /*<<< orphan*/ *, char *);
unsigned short parse_SKP() {
  unsigned short instruction = 0xE09E;
  char *arg;
  arg = strtok(NULL, " ,");
  if (arg[0] != 'V') {
    return 0xFFFF;
  }
  instruction |= (char2byte(arg[1]) & 0x0F) << 8;
  return instruction;
}


x86 assembly (clang, -O0):
<parse_SKP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movw   $0xe09e,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xec7(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x56,%eax
je     115d <parse_SKP+0x3d>
movw   $0xffff,-0x2(%rbp)
jmp    1184 <parse_SKP+0x64>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <char2byte@plt>
mov    %eax,%ecx
and    $0xf,%ecx
shl    $0x8,%ecx
movzwl -0x4(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4(%rbp)
mov    -0x4(%rbp),%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_SKP>:
push   %rax
lea    0xed8(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    $0xffff,%ax
cmpb   $0x56,(%rcx)
jne    114f <parse_SKP+0x2f>
movsbl 0x1(%rcx),%edi
call   1030 <char2byte@plt>
and    $0xf,%eax
shl    $0x8,%eax
or     $0xe09e,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c" ,\00"
define zeroext i16 @parse_SKP() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i8*
store i16 -8034, i16* %2
%4 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 86
br i1 %9, label %10, label %11
10: ; preds = %0
store i16 -1, i16* %1
br label %23
11: ; preds = %0
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = call i32 @char2byte(i8 signext %14)
%16 = and i32 %15, 15
%17 = shl i32 %16, 8
%18 = load i16, i16* %2
%19 = zext i16 %18 to i32
%20 = or i32 %19, %17
%21 = trunc i32 %20 to i16
store i16 %21, i16* %2
%22 = load i16, i16* %2
store i16 %22, i16* %1
br label %23
23: ; preds = %11, %10
%24 = load i16, i16* %1
ret i16 %24
}

LLVM IR (-O2):
@.str = [3 x i8] c" ,\00"
define zeroext i16 @parse_SKP() {
%1 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%2 = load i8, i8* %1
%3 = icmp eq i8 %2, 86
br i1 %3, label %4, label %12
4: ; preds = %0
%5 = getelementptr inbounds i8, i8* %1, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @char2byte(i8 signext %6)
%8 = trunc i32 %7 to i16
%9 = shl i16 %8, 8
%10 = and i16 %9, 3840
%11 = or i16 %10, -8034
br label %12
12: ; preds = %0, %4
%13 = phi i16 [ %11, %4 ], [ -1, %0 ]
ret i16 %13
}
/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
struct drm_gem_close {
  int /*<<< orphan*/ handle;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ DRM_IOCTL_GEM_CLOSE;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct drm_gem_close *);
void close_handle(int vgem_fd, uint32_t handle) {
  struct drm_gem_close close = {0};
  close.handle = handle;
  ioctl(vgem_fd, DRM_IOCTL_GEM_CLOSE, &close);
}


x86 assembly (clang, -O0):
<close_handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <ioctl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_handle>:
push   %rax
movq   $0x0,(%rsp)
mov    %esi,(%rsp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1030 <ioctl@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.drm_gem_close = type { i32, i32 }
@DRM_IOCTL_GEM_CLOSE = global i32 0
define void @close_handle(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.drm_gem_close
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = bitcast %struct.drm_gem_close* %5 to i8*
%7 = load i32, i32* %4
%8 = getelementptr inbounds %struct.drm_gem_close, %struct.drm_gem_close* %5, i32 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* %3
%10 = load i32, i32* @DRM_IOCTL_GEM_CLOSE
%11 = call i32 @ioctl(i32 %9, i32 %10, %struct.drm_gem_close* %5)
ret void
}

LLVM IR (-O2):
%struct.drm_gem_close = type { i32, i32 }
@DRM_IOCTL_GEM_CLOSE = global i32 0
define void @close_handle(i32 %0, i32 %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to %struct.drm_gem_close*
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = bitcast i64* %3 to i32*
store i32 %1, i32* %6
%7 = load i32, i32* @DRM_IOCTL_GEM_CLOSE
%8 = call i32 @ioctl(i32 %0, i32 %7, %struct.drm_gem_close* %4)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int error(char *message) {
  fprintf(stderr, "ERROR: %s\n", message);
  exit(2);
}


x86 assembly (clang, -O0):
<error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xec0(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<error>:
push   %rax
mov    %rdi,%rdx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
define i32 @error(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @exit(i32 2)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
define i32 @error(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @exit(i32 2)
unreachable
}
void endhostent() {}


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

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

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

LLVM IR (-O2):
define void @endhostent() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ test_modulo();
int /*<<< orphan*/ test_rolling();
int /*<<< orphan*/ test_simple_word();
int /*<<< orphan*/ test_single_char();
int main() {
  test_single_char();
  test_simple_word();
  test_modulo();
  test_rolling();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <test_single_char@plt>
mov    $0x0,%al
call   1060 <test_simple_word@plt>
mov    $0x0,%al
call   1050 <test_modulo@plt>
mov    $0x0,%al
call   1030 <test_rolling@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <test_single_char@plt>
xor    %eax,%eax
call   1060 <test_simple_word@plt>
xor    %eax,%eax
call   1050 <test_modulo@plt>
xor    %eax,%eax
call   1030 <test_rolling@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @test_single_char()
%3 = call i32 (...) @test_simple_word()
%4 = call i32 (...) @test_modulo()
%5 = call i32 (...) @test_rolling()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @test_single_char()
%2 = tail call i32 (...) @test_simple_word()
%3 = tail call i32 (...) @test_modulo()
%4 = tail call i32 (...) @test_rolling()
ret i32 0
}
/* Type definitions */
struct user_regs_struct {
  long rip;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ PTRACE_GETREGS;
int /*<<< orphan*/ ptrace(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, struct user_regs_struct *);
long get_child_eip(pid_t pid) {
  struct user_regs_struct regs;
  ptrace(PTRACE_GETREGS, pid, 0, &regs);
  return regs.rip;
}


x86 assembly (clang, -O0):
<get_child_eip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
xor    %edx,%edx
lea    -0x10(%rbp),%rcx
call   1030 <ptrace@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_child_eip>:
push   %rax
mov    %edi,%esi
mov    0x2ec6(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rcx
xor    %edx,%edx
call   1030 <ptrace@plt>
mov    (%rsp),%rax
pop    %rcx
ret

LLVM IR (-O0):
%struct.user_regs_struct = type { i64 }
@PTRACE_GETREGS = global i32 0
define i64 @get_child_eip(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.user_regs_struct
store i32 %0, i32* %2
%4 = load i32, i32* @PTRACE_GETREGS
%5 = load i32, i32* %2
%6 = call i32 @ptrace(i32 %4, i32 %5, i32 0, %struct.user_regs_struct* %3)
%7 = getelementptr inbounds %struct.user_regs_struct, %struct.user_regs_struct* %3, i32 0, i32 0
%8 = load i64, i64* %7
ret i64 %8
}

LLVM IR (-O2):
%struct.user_regs_struct = type { i64 }
@PTRACE_GETREGS = global i32 0
define i64 @get_child_eip(i32 %0) {
%2 = alloca %struct.user_regs_struct
%3 = bitcast %struct.user_regs_struct* %2 to i8*
%4 = load i32, i32* @PTRACE_GETREGS
%5 = call i32 @ptrace(i32 %4, i32 %0, i32 0, %struct.user_regs_struct* %2)
%6 = getelementptr inbounds %struct.user_regs_struct, %struct.user_regs_struct* %2, i64 0, i32 0
%7 = load i64, i64* %6
ret i64 %7
}
/* Variables and functions */
int INT_MIN;
signed int ov_idiv(signed int a, signed int b, int *ov) {
  if ((b == 0) || ((a == INT_MIN) && (b == -1))) {
    *ov = 1;
    if (b == 0)
      return 0;
    else
      return a;
  }
  return a / b;
}


x86 assembly (clang, -O0):
<ov_idiv>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1134 <ov_idiv+0x34>
mov    -0x8(%rbp),%eax
mov    0x2ec6(%rip),%rcx
cmp    (%rcx),%eax
jne    115f <ov_idiv+0x5f>
cmpl   $0xffffffff,-0xc(%rbp)
jne    115f <ov_idiv+0x5f>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
cmpl   $0x0,-0xc(%rbp)
jne    1154 <ov_idiv+0x54>
movl   $0x0,-0x4(%rbp)
jmp    1169 <ov_idiv+0x69>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1169 <ov_idiv+0x69>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ov_idiv>:
test   %esi,%esi
je     111d <ov_idiv+0x1d>
mov    %edi,%eax
cmp    $0xffffffff,%esi
jne    1126 <ov_idiv+0x26>
mov    0x2ed6(%rip),%rcx
cmp    %eax,(%rcx)
jne    1126 <ov_idiv+0x26>
movl   $0x1,(%rdx)
ret
xor    %eax,%eax
movl   $0x1,(%rdx)
ret
cltd
idiv   %esi
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @ov_idiv(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %3
%11 = load i32, i32* %5
%12 = load i32, i32* @INT_MIN
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %24
17: ; preds = %14, %3
%18 = load i32*, i32** %7
store i32 1, i32* %18
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %4
br label %28
22: ; preds = %17
%23 = load i32, i32* %5
store i32 %23, i32* %4
br label %28
24: ; preds = %14, %10
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = sdiv i32 %25, %26
store i32 %27, i32* %4
br label %28
28: ; preds = %24, %22, %21
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @ov_idiv(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = load i32, i32* @INT_MIN
%7 = icmp eq i32 %6, %0
%8 = icmp eq i32 %1, -1
%9 = and i1 %8, %7
br i1 %9, label %10, label %12
10: ; preds = %5, %3
%11 = phi i32 [ %0, %5 ], [ 0, %3 ]
store i32 1, i32* %2
br label %14
12: ; preds = %5
%13 = sdiv i32 %0, %1
br label %14
14: ; preds = %10, %12
%15 = phi i32 [ %13, %12 ], [ %11, %10 ]
ret i32 %15
}
int isduplicate(int c, int pc) { return c == pc; }


x86 assembly (clang, -O0):
<isduplicate>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @isduplicate(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = icmp eq i32 %5, %6
%8 = zext i1 %7 to i32
ret i32 %8
}

LLVM IR (-O2):
define i32 @isduplicate(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, %1
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int fnextChar(void *ud) {
  int c = fgetc((FILE *)ud);
  if (c == EOF) {
    return -1;
  }
  return c;
}


x86 assembly (clang, -O0):
<fnextChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%eax
jne    1146 <fnextChar+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    114c <fnextChar+0x3c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnextChar>:
push   %rax
call   1030 <fgetc@plt>
mov    0x2ecb(%rip),%rcx
cmp    (%rcx),%eax
mov    $0xffffffff,%ecx
cmove  %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fnextChar(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = bitcast i8* %5 to i32*
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %14
12: ; preds = %1
%13 = load i32, i32* %4
store i32 %13, i32* %2
br label %14
14: ; preds = %12, %11
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @fnextChar(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = tail call i32 @fgetc(i32* %2)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
%6 = select i1 %5, i32 -1, i32 %3
ret i32 %6
}
void av_realloc_f() {}


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

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

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

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

/* Variables and functions */
uint64_t read_little_endian64(const uint8_t *array, uint64_t pos) {
  return *((uint64_t *)(array + pos));
}


x86 assembly (clang, -O0):
<read_little_endian64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_little_endian64>:
movslq %esi,%rax
mov    (%rdi,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @read_little_endian64(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32*, i32** %3
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %5, i64 %7
%9 = load i32, i32* %8
ret i32 %9
}

LLVM IR (-O2):
define i32 @read_little_endian64(i32* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
ret i32 %5
}
/* Type definitions */
typedef scalar_t__ int32_t;

/* Variables and functions */
int32_t int32max(int32_t a, int32_t b) { return a > b ? a : b; }


x86 assembly (clang, -O0):
<int32max>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    1127 <int32max+0x27>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    112f <int32max+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<int32max>:
mov    %rsi,%rax
cmp    %rsi,%rdi
cmovg  %rdi,%rax
ret

LLVM IR (-O0):
define i64 @int32max(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
%7 = icmp sgt i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i64, i64* %3
br label %12
10: ; preds = %2
%11 = load i64, i64* %4
br label %12
12: ; preds = %10, %8
%13 = phi i64 [ %9, %8 ], [ %11, %10 ]
ret i64 %13
}

LLVM IR (-O2):
define i64 @int32max(i64 %0, i64 %1) {
%3 = icmp sgt i64 %0, %1
%4 = select i1 %3, i64 %0, i64 %1
ret i64 %4
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, long, int /*<<< orphan*/ *);
void saveFile(const char filename[], unsigned char *buffer, long size) {
  FILE *f;
  f = fopen(filename, "wb+");
  if (!f)
    return;
  fwrite(buffer, 1, size, f);
  fclose(f);
}


x86 assembly (clang, -O0):
<saveFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1168 <saveFile+0x38>
jmp    1187 <saveFile+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveFile>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xebe(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     116f <saveFile+0x3f>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"wb+\00"
define void @saveFile(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp ne i32* %10, null
br i1 %11, label %13, label %12
12: ; preds = %3
br label %20
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i64, i64* %6
%16 = load i32*, i32** %7
%17 = call i32 @fwrite(i8* %14, i32 1, i64 %15, i32* %16)
%18 = load i32*, i32** %7
%19 = call i32 @fclose(i32* %18)
br label %20
20: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"wb+\00"
define void @saveFile(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @fwrite(i8* %1, i32 1, i64 %2, i32* %4)
%8 = tail call i32 @fclose(i32* %4)
br label %9
9: ; preds = %3, %6
ret void
}
char *GetMemory(void) {
  char p[] = "hello world";
  return p;
}


x86 assembly (clang, -O0):
<GetMemory>:
push   %rbp
mov    %rsp,%rbp
mov    0xef5(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xef3(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetMemory>:
lea    -0xc(%rsp),%rax
ret

LLVM IR (-O0):
@__const.GetMemory.p = [12 x i8] c"hello world\00"
define i8* @GetMemory() {
%1 = alloca [12 x i8]
%2 = bitcast [12 x i8]* %1 to i8*
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
ret i8* %3
}

LLVM IR (-O2):
define noalias i8* @GetMemory() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ test_utc_timestamp_to_timeval();
void utils_test() {
  puts("# Utils tests:");
  test_utc_timestamp_to_timeval();
}


x86 assembly (clang, -O0):
<utils_test>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1040 <test_utc_timestamp_to_timeval@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<utils_test>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <test_utc_timestamp_to_timeval@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"# Utils tests:\00"
define void @utils_test() {
%1 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = call i32 (...) @test_utc_timestamp_to_timeval()
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"# Utils tests:\00"
define void @utils_test() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @test_utc_timestamp_to_timeval()
ret void
}