xunge/DecIR huggingface dataset:
char *consume_line(char *c) {
  while (*c && *c != '\n') {
    c++;
  }
  if (*c) {
    c++;
  }
  return c;
}


x86 assembly (clang, -O0):
<consume_line>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
je     112d <consume_line+0x2d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    113d <consume_line+0x3d>
jmp    114e <consume_line+0x4e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <consume_line+0x8>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1167 <consume_line+0x67>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<consume_line>:
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rax),%ecx
test   %cl,%cl
je     1122 <consume_line+0x22>
cmp    $0xa,%cl
je     1122 <consume_line+0x22>
add    $0x1,%rax
jmp    1110 <consume_line+0x10>
cmp    $0x1,%cl
sbb    $0xffffffffffffffff,%rax
ret

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

LLVM IR (-O2):
define i8* @consume_line(i8* %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %7
i8 10, label %7
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2, %2
%8 = icmp ne i8 %4, 0
%9 = zext i1 %8 to i64
%10 = getelementptr i8, i8* %3, i64 %9
ret i8* %10
}
unsigned long long
unsignedlonglong_ignoring_signedshortint(unsigned long long x,
                                         signed short int y) {
  return x;
}


x86 assembly (clang, -O0):
<unsignedlonglong_ignoring_signedshortint>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i64 @unsignedlonglong_ignoring_signedshortint(i64 returned %0, i16 signext %1) {
ret i64 %0
}
/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ _atomic_exchange_u32(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/);
int32_t _atomic_exchange_s32(int32_t *ptr, int32_t value) {
  return _atomic_exchange_u32((uint32_t *)ptr, value);
}


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

x86 assembly (clang, -O2):
<_atomic_exchange_s32>:
jmp    1030 <_atomic_exchange_u32@plt>

LLVM IR (-O0):
define i32 @_atomic_exchange_s32(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 = call i32 @_atomic_exchange_u32(i32* %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @_atomic_exchange_s32(i32* %0, i32 %1) {
%3 = tail call i32 @_atomic_exchange_u32(i32* %0, i32 %1)
ret i32 %3
}
int d_ble_rc1(double a1) { return (__builtin_islessequal(a1, 100)); }


x86 assembly (clang, -O0):
<d_ble_rc1>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeef(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_ble_rc1>:
movsd  0xef8(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
ret

LLVM IR (-O0):
define i32 @d_ble_rc1(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp ole double %3, 1.000000e+02
%5 = zext i1 %4 to i32
ret i32 %5
}

LLVM IR (-O2):
define i32 @d_ble_rc1(double %0) {
%2 = fcmp ole double %0, 1.000000e+02
%3 = zext i1 %2 to i32
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
char *erase() {
  printf("erase\n");
  return "1";
}


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

x86 assembly (clang, -O2):
<erase>:
push   %rax
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [2 x i8] c"1\00"
@str = [6 x i8] c"erase\00"
define i8* @erase() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
}
/* Variables and functions */
int ec(int, int);
void x() { ec(ec(1, 12), 12); }


x86 assembly (clang, -O0):
<x>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%edi
mov    $0xc,%esi
call   1030 <ec@plt>
mov    %eax,%edi
mov    $0xc,%esi
call   1030 <ec@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<x>:
push   %rax
mov    $0x1,%edi
mov    $0xc,%esi
call   1030 <ec@plt>
mov    %eax,%edi
mov    $0xc,%esi
pop    %rax
jmp    1030 <ec@plt>

LLVM IR (-O0):
define void @x() {
%1 = call i32 @ec(i32 1, i32 12)
%2 = call i32 @ec(i32 %1, i32 12)
ret void
}

LLVM IR (-O2):
define void @x() {
%1 = tail call i32 @ec(i32 1, i32 12)
%2 = tail call i32 @ec(i32 %1, i32 12)
ret void
}
int nc_side(int cell) {
  switch (cell) {
  case 1:
    return (4);
  case 3:
    return (1);
  case 5:
    return (3);
  case 7:
    return (2);
  case 0:
    return (1);
  case 2:
    return (4);
  case 6:
    return (2);
  case 8:
    return (3);
  }
}


x86 assembly (clang, -O0):
<nc_side>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x8,%rax
ja     1187 <nc_side+0x87>
mov    -0x10(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x4,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x1,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x3,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x2,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x1,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x4,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x2,-0x4(%rbp)
jmp    1187 <nc_side+0x87>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc_side>:
mov    $0x4,%eax
cmp    $0x8,%edi
ja     1117 <nc_side+0x17>
movslq %edi,%rax
lea    0xeec(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

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

LLVM IR (-O2):
@switch.table.nc_side = [9 x i32] [i32 1, i32 4, i32 4, i32 1, i32 4, i32 3, i32 2, i32 2, i32 3]
define i32 @nc_side(i32 %0) {
%2 = icmp ult i32 %0, 9
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds [9 x i32], [9 x i32]* @switch.table.nc_side, i64 0, i64 %4
%6 = load i32, i32* %5
br label %7
7: ; preds = %3, %1
%8 = phi i32 [ 4, %1 ], [ %6, %3 ]
ret i32 %8
}
/* Type definitions */
struct tavl_table {
  int dummy;
};

/* Variables and functions */
void **tavl_probe(struct tavl_table *, void *);
void *tavl_insert(struct tavl_table *table, void *item) {
  void **p = tavl_probe(table, item);
  return p == NULL || *p == item ? NULL : *p;
}


x86 assembly (clang, -O0):
<tavl_insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <tavl_probe@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     114d <tavl_insert+0x3d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jne    1158 <tavl_insert+0x48>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    1163 <tavl_insert+0x53>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tavl_insert>:
push   %rbx
mov    %rsi,%rbx
call   1030 <tavl_probe@plt>
test   %rax,%rax
je     112c <tavl_insert+0x1c>
mov    (%rax),%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
cmovne %rcx,%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.tavl_table = type { i32 }
define i8* @tavl_insert(%struct.tavl_table* %0, i8* %1) {
%3 = alloca %struct.tavl_table*
%4 = alloca i8*
%5 = alloca i8**
store %struct.tavl_table* %0, %struct.tavl_table** %3
store i8* %1, i8** %4
%6 = load %struct.tavl_table*, %struct.tavl_table** %3
%7 = load i8*, i8** %4
%8 = call i8** @tavl_probe(%struct.tavl_table* %6, i8* %7)
store i8** %8, i8*** %5
%9 = load i8**, i8*** %5
%10 = icmp eq i8** %9, null
br i1 %10, label %16, label %11
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = load i8*, i8** %4
%15 = icmp eq i8* %13, %14
br i1 %15, label %16, label %17
16: ; preds = %11, %2
br label %20
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
br label %20
20: ; preds = %17, %16
%21 = phi i8* [ null, %16 ], [ %19, %17 ]
ret i8* %21
}

LLVM IR (-O2):
%struct.tavl_table = type { i32 }
define i8* @tavl_insert(%struct.tavl_table* %0, i8* %1) {
%3 = tail call i8** @tavl_probe(%struct.tavl_table* %0, i8* %1)
%4 = icmp eq i8** %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
%8 = select i1 %7, i8* null, i8* %6
br label %9
9: ; preds = %5, %2
%10 = phi i8* [ null, %2 ], [ %8, %5 ]
ret i8* %10
}
/* Type definitions */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int **, int **, int);
void copy_ptr(int64_t *x) {
  int64_t *y;
  memcpy(&y, &x, sizeof(int64_t *));
  *y = 5;
}


x86 assembly (clang, -O0):
<copy_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_ptr>:
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    0x8(%rsp),%rax
movl   $0x5,(%rax)
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define void @copy_ptr(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
store i32* %0, i32** %2
%4 = bitcast i32** %3 to i8*
%5 = call i32 @memcpy(i32** %3, i32** %2, i32 8)
%6 = load i32*, i32** %3
store i32 5, i32* %6
ret void
}
int to_up(int a) {
  if (a >= 'a' && a <= 'z')
    return a + 'A' - 'a';
  else
    return a;
}


x86 assembly (clang, -O0):
<to_up>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x61,-0x8(%rbp)
jl     112c <to_up+0x2c>
cmpl   $0x7a,-0x8(%rbp)
jg     112c <to_up+0x2c>
mov    -0x8(%rbp),%eax
add    $0x41,%eax
sub    $0x61,%eax
mov    %eax,-0x4(%rbp)
jmp    1132 <to_up+0x32>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_up>:
lea    -0x61(%rdi),%ecx
lea    -0x20(%rdi),%eax
cmp    $0x1a,%ecx
cmovae %edi,%eax
ret

LLVM IR (-O0):
define i32 @to_up(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 97
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 122
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 65
%12 = sub nsw i32 %11, 97
store i32 %12, i32* %2
br label %15
13: ; preds = %6, %1
%14 = load i32, i32* %3
store i32 %14, i32* %2
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @to_up(i32 %0) {
%2 = add i32 %0, -97
%3 = icmp ult i32 %2, 26
%4 = add nsw i32 %0, -32
%5 = select i1 %3, i32 %4, i32 %0
ret i32 %5
}
void Host_close_audio(void) {}


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

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

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

LLVM IR (-O2):
define void @Host_close_audio() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isdigit(int);
void t_isdigit_0x62() {
  Assert_real((isdigit(98) == 0),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isdigit.c",
              495, ("isdigit should be 0 for b"));
}


x86 assembly (clang, -O0):
<t_isdigit_0x62>:
push   %rbp
mov    %rsp,%rbp
mov    $0x62,%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xebf(%rip),%rsi
mov    $0x1ef,%edx
lea    0xf5b(%rip),%rcx
call   1040 <Assert_real@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_isdigit_0x62>:
push   %rax
mov    $0x62,%edi
call   1030 <isdigit@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf66(%rip),%rcx
mov    $0x1ef,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isdigit.c\00"
@.str.1 = [26 x i8] c"isdigit should be 0 for b\00"
define void @t_isdigit_0x62() {
%1 = call i64 @isdigit(i32 98)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 495, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isdigit.c\00"
@.str.1 = [26 x i8] c"isdigit should be 0 for b\00"
define void @t_isdigit_0x62() {
%1 = tail call i64 @isdigit(i32 98)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 495, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *);
int error(const char *string) {
  printf("%s\n", string);
  return -1;
}


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

x86 assembly (clang, -O2):
<error>:
push   %rax
mov    %rdi,%rsi
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @error(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
ret i32 -1
}
char hex2dec(char s0, char s1) {
  int sum;
  if ((s1 >= 48) && (s1 <= 57))
    sum = s1 - 48;
  else
    sum = s1 - 55;
  if ((s0 >= 48) && (s0 <= 57))
    sum += (s0 - 48) * 16;
  else
    sum += (s0 - 55) * 16;
  return sum;
}


x86 assembly (clang, -O0):
<hex2dec>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x30,%eax
jl     1139 <hex2dec+0x39>
movsbl -0x2(%rbp),%eax
cmp    $0x39,%eax
jg     1139 <hex2dec+0x39>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
jmp    1143 <hex2dec+0x43>
movsbl -0x2(%rbp),%eax
sub    $0x37,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     1172 <hex2dec+0x72>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     1172 <hex2dec+0x72>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
shl    $0x4,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1182 <hex2dec+0x82>
movsbl -0x1(%rbp),%eax
sub    $0x37,%eax
shl    $0x4,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
movsbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex2dec>:
lea    -0x30(%rsi),%eax
add    $0xc9,%sil
cmp    $0xa,%al
movzbl %al,%eax
movzbl %sil,%ecx
cmovb  %eax,%ecx
lea    -0x30(%rdi),%eax
shl    $0x4,%dil
lea    -0x70(%rdi),%edx
cmp    $0xa,%al
movzbl %dil,%esi
movzbl %dl,%eax
cmovb  %esi,%eax
add    %cl,%al
ret

LLVM IR (-O0):
define signext i8 @hex2dec(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp sge i32 %7, 48
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp sle i32 %11, 57
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 48
store i32 %16, i32* %5
br label %21
17: ; preds = %9, %2
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 55
store i32 %20, i32* %5
br label %21
21: ; preds = %17, %13
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 48
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp sle i32 %27, 57
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 48
%33 = mul nsw i32 %32, 16
%34 = load i32, i32* %5
%35 = add nsw i32 %34, %33
store i32 %35, i32* %5
br label %43
36: ; preds = %25, %21
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 55
%40 = mul nsw i32 %39, 16
%41 = load i32, i32* %5
%42 = add nsw i32 %41, %40
store i32 %42, i32* %5
br label %43
43: ; preds = %36, %29
%44 = load i32, i32* %5
%45 = trunc i32 %44 to i8
ret i8 %45
}

LLVM IR (-O2):
define signext i8 @hex2dec(i8 signext %0, i8 signext %1) {
%3 = add i8 %1, -48
%4 = icmp ult i8 %3, 10
%5 = add i8 %1, -55
%6 = select i1 %4, i8 %3, i8 %5
%7 = add i8 %0, -48
%8 = icmp ult i8 %7, 10
%9 = shl i8 %0, 4
%10 = add i8 %9, -112
%11 = select i1 %8, i8 %9, i8 %10
%12 = add i8 %6, %11
ret i8 %12
}
int tosInt32_add(int x, int y) { return x + y; }


x86 assembly (clang, -O0):
<tosInt32_add>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @tosInt32_add(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 = add nsw i32 %5, %6
ret i32 %7
}

LLVM IR (-O2):
define i32 @tosInt32_add(i32 %0, i32 %1) {
%3 = add nsw i32 %1, %0
ret i32 %3
}
int mod(int x, int y) { return x - ((x / y) * y); }


x86 assembly (clang, -O0):
<mod>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
imul   -0x8(%rbp),%ecx
sub    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod>:
mov    %edi,%eax
cltd
idiv   %esi
mov    %edx,%eax
ret

LLVM IR (-O0):
define i32 @mod(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* %3
%7 = load i32, i32* %4
%8 = sdiv i32 %6, %7
%9 = load i32, i32* %4
%10 = mul nsw i32 %8, %9
%11 = sub nsw i32 %5, %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @mod(i32 %0, i32 %1) {
%3 = srem i32 %0, %1
ret i32 %3
}
/* Variables and functions */
double log(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double x, y;
  scanf("%lf", &x);
  y = log(x) / log(2);
  printf("%.0lf", y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cvttsd2si -0x10(%rbp),%edi
call   1050 <log@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x2,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
cvttsd2si 0x10(%rsp),%edi
call   1050 <log@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1050 <log@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
lea    0xe93(%rip),%rdi
movapd %xmm1,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [6 x i8] c"%.0lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%5 = load double, double* %2
%6 = fptosi double %5 to i32
%7 = call double @log(i32 %6)
%8 = call double @log(i32 2)
%9 = fdiv double %7, %8
store double %9, double* %3
%10 = load double, double* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [6 x i8] c"%.0lf\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = fptosi double %4 to i32
%6 = call double @log(i32 %5)
%7 = call double @log(i32 2)
%8 = fdiv double %6, %7
%9 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %8)
ret i32 0
}
/* Variables and functions */
int japi_borderpanel(int, int);
int j_borderpanel(int arg0, int arg1) { return (japi_borderpanel(arg0, arg1)); }


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

x86 assembly (clang, -O2):
<j_borderpanel>:
jmp    1030 <japi_borderpanel@plt>

LLVM IR (-O0):
define i32 @j_borderpanel(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 = call i32 @japi_borderpanel(i32 %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @j_borderpanel(i32 %0, i32 %1) {
%3 = tail call i32 @japi_borderpanel(i32 %0, i32 %1)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ foo();
void test01(int flag) {
  if (flag)
    foo();
  foo();
}


x86 assembly (clang, -O0):
<test01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     112c <test01+0x1c>
mov    $0x0,%al
call   1030 <foo@plt>
mov    $0x0,%al
call   1030 <foo@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test01>:
test   %edi,%edi
je     1120 <test01+0x10>
push   %rax
xor    %eax,%eax
call   1030 <foo@plt>
add    $0x8,%rsp
xor    %eax,%eax
jmp    1030 <foo@plt>

LLVM IR (-O0):
define void @test01(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (...) @foo()
br label %7
7: ; preds = %5, %1
%8 = call i32 (...) @foo()
ret void
}

LLVM IR (-O2):
define void @test01(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 (...) @foo()
br label %5
5: ; preds = %3, %1
%6 = tail call i32 (...) @foo()
ret void
}
/* Variables and functions */
const char *__find_next_newline(const char *base, const char *limit) {
  while (*base++ != '\n' && base != limit)
    ;
  return base <= limit ? base : NULL;
}


x86 assembly (clang, -O0):
<__find_next_newline>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     113a <__find_next_newline+0x3a>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    114a <__find_next_newline+0x4a>
jmp    114f <__find_next_newline+0x4f>
jmp    110c <__find_next_newline+0xc>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     116a <__find_next_newline+0x6a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1175 <__find_next_newline+0x75>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    1175 <__find_next_newline+0x75>
mov    -0x20(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__find_next_newline>:
lea    0x1(%rdi),%rcx
cmpb   $0xa,(%rdi)
je     1111 <__find_next_newline+0x11>
mov    %rcx,%rdi
cmp    %rsi,%rcx
jne    1100 <__find_next_newline>
xor    %eax,%eax
cmp    %rsi,%rcx
cmovbe %rcx,%rax
ret

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

LLVM IR (-O2):
define i8* @__find_next_newline(i8* %0, i8* readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i8* [ %0, %2 ], [ %5, %3 ]
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = load i8, i8* %4
%7 = icmp ne i8 %6, 10
%8 = icmp ne i8* %5, %1
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %3, label %10
10: ; preds = %3
%11 = icmp ugt i8* %5, %1
%12 = select i1 %11, i8* null, i8* %5
ret i8* %12
}
/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int open_file(const char *fileName) {
  int fp;
  fp = open(fileName, O_RDONLY);
  printf("Open is: %d\n", fp);
  if (fp < 0) {
    printf("Bus Error 22\n");
    exit(0);
  }
  return fp;
}


x86 assembly (clang, -O0):
<open_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    1181 <open_file+0x51>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_file>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,%ebx
lea    0xea8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     1169 <open_file+0x29>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [13 x i8] c"Open is: %d\0A\00"
@.str.1 = [14 x i8] c"Bus Error 22\0A\00"
define i32 @open_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* %4, i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %1
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [13 x i8] c"Open is: %d\0A\00"
@str = [13 x i8] c"Bus Error 22\00"
define i32 @open_file(i8* nocapture %0) {
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* %0, i32 %2)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %3, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %1
ret i32 %3
}
unsigned char f23(unsigned char x, int y) {
  return (x >> ((-y) & (8 - 1))) ^ (x << y);
}


x86 assembly (clang, -O0):
<f23>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
xor    %ecx,%ecx
sub    -0x8(%rbp),%ecx
and    $0x7,%ecx
sar    %cl,%eax
movzbl -0x1(%rbp),%edx
mov    -0x8(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
xor    %ecx,%eax
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<f23>:
mov    %esi,%ecx
neg    %cl
and    $0x7,%cl
mov    %edi,%eax
shr    %cl,%eax
mov    %esi,%ecx
shl    %cl,%edi
xor    %edi,%eax
ret

LLVM IR (-O0):
define zeroext i8 @f23(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
%5 = load i8, i8* %3
%6 = zext i8 %5 to i32
%7 = load i32, i32* %4
%8 = sub nsw i32 0, %7
%9 = and i32 %8, 7
%10 = ashr i32 %6, %9
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = load i32, i32* %4
%14 = shl i32 %12, %13
%15 = xor i32 %10, %14
%16 = trunc i32 %15 to i8
ret i8 %16
}

LLVM IR (-O2):
define zeroext i8 @f23(i8 zeroext %0, i32 %1) {
%3 = zext i8 %0 to i32
%4 = sub nsw i32 0, %1
%5 = and i32 %4, 7
%6 = lshr i32 %3, %5
%7 = shl i32 %3, %1
%8 = xor i32 %6, %7
%9 = trunc i32 %8 to i8
ret i8 %9
}
int mod_positive(int vin, int mod) { return (vin % mod + mod) % mod; }


x86 assembly (clang, -O0):
<mod_positive>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,%eax
add    -0x8(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_positive>:
mov    %edi,%eax
cltd
idiv   %esi
lea    (%rdx,%rsi,1),%eax
cltd
idiv   %esi
mov    %edx,%eax
ret

LLVM IR (-O0):
define i32 @mod_positive(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 = srem i32 %5, %6
%8 = load i32, i32* %4
%9 = add nsw i32 %7, %8
%10 = load i32, i32* %4
%11 = srem i32 %9, %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @mod_positive(i32 %0, i32 %1) {
%3 = srem i32 %0, %1
%4 = add nsw i32 %3, %1
%5 = srem i32 %4, %1
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
__attribute__((hotpatch(1000001))) void hp3(void) { printf("hello, world!\n"); }


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

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

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

LLVM IR (-O2):
@str = [14 x i8] c"hello, world!\00"
define void @hp3() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret void
}
void secondary() {}


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

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

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

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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char const *, char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void logger(const char *tag, const char *message) {
  time_t now;
  time(&now);
  printf("%s [%s]: %s\n", ctime(&now), tag, message);
}


x86 assembly (clang, -O0):
<logger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logger>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1050 <time@plt>
mov    %r15,%rdi
call   1030 <ctime@plt>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s [%s]: %s\0A\00"
define void @logger(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 @time(i32* %5)
%7 = call i8* @ctime(i32* %5)
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8, i8* %9)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s [%s]: %s\0A\00"
define void @logger(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @time(i32* %3)
%6 = call i8* @ctime(i32* %3)
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %0, i8* %1)
ret void
}
/* Variables and functions */
double sin(double);
double sinfn(double d) {
  double res;
  res = sin(d * 2.0 * 3.14159265358979323846);
  return res;
}


x86 assembly (clang, -O0):
<sinfn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xee3(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xece(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinfn>:
addsd  %xmm0,%xmm0
mulsd  0xee4(%rip),%xmm0
jmp    1030 <sin@plt>

LLVM IR (-O0):
define double @sinfn(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fmul double %4, 2.000000e+00
%6 = fmul double %5, 0x400921FB54442D18
%7 = call double @sin(double %6)
store double %7, double* %3
%8 = load double, double* %3
ret double %8
}

LLVM IR (-O2):
define double @sinfn(double %0) {
%2 = fmul double %0, 2.000000e+00
%3 = fmul double %2, 0x400921FB54442D18
%4 = tail call double @sin(double %3)
ret double %4
}
/* Type definitions */
struct h2get_h2_header {
  int dummy;
};
struct h2get_ctx {
  int dummy;
};
struct h2get_buf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dump_zone(char *, size_t);
void h2get_frame_render_data(struct h2get_ctx *ctx, struct h2get_buf *out,
                             struct h2get_h2_header *h, char *payload,
                             size_t plen) {
  dump_zone(payload, plen);
}


x86 assembly (clang, -O0):
<h2get_frame_render_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <dump_zone@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<h2get_frame_render_data>:
mov    %r8,%rsi
mov    %rcx,%rdi
jmp    1030 <dump_zone@plt>

LLVM IR (-O0):
%struct.h2get_ctx = type { i32 }
%struct.h2get_buf = type { i32 }
%struct.h2get_h2_header = type { i32 }
define void @h2get_frame_render_data(%struct.h2get_ctx* %0, %struct.h2get_buf* %1, %struct.h2get_h2_header* %2, i8* %3, i64 %4) {
%6 = alloca %struct.h2get_ctx*
%7 = alloca %struct.h2get_buf*
%8 = alloca %struct.h2get_h2_header*
%9 = alloca i8*
%10 = alloca i64
store %struct.h2get_ctx* %0, %struct.h2get_ctx** %6
store %struct.h2get_buf* %1, %struct.h2get_buf** %7
store %struct.h2get_h2_header* %2, %struct.h2get_h2_header** %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%11 = load i8*, i8** %9
%12 = load i64, i64* %10
%13 = call i32 @dump_zone(i8* %11, i64 %12)
ret void
}

LLVM IR (-O2):
%struct.h2get_ctx = type { i32 }
%struct.h2get_buf = type { i32 }
%struct.h2get_h2_header = type { i32 }
define void @h2get_frame_render_data(%struct.h2get_ctx* nocapture readnone %0, %struct.h2get_buf* nocapture readnone %1, %struct.h2get_h2_header* nocapture readnone %2, i8* %3, i64 %4) {
%6 = tail call i32 @dump_zone(i8* %3, i64 %4)
ret void
}
/* Variables and functions */
int Partition(int *, int, int);
void QuickSort(int arr[], int left, int right) {
  int pivot;
  if (left <= right) {
    pivot = Partition(arr, left, right);
    QuickSort(arr, left, pivot - 1);
    QuickSort(arr, pivot + 1, right);
  }
}


x86 assembly (clang, -O0):
<QuickSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1174 <QuickSort+0x54>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <Partition@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1030 <QuickSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <QuickSort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuickSort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    %edx,%esi
jg     1164 <QuickSort+0x44>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <Partition@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <QuickSort@plt>
lea    0x1(%rbx),%ebp
cmp    %r14d,%ebx
jl     1140 <QuickSort+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @QuickSort(i32* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
br i1 %4, label %11, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %9, %5 ], [ %1, %3 ]
%7 = tail call i32 @Partition(i32* %0, i32 %6, i32 %2)
%8 = add nsw i32 %7, -1
tail call void @QuickSort(i32* %0, i32 %6, i32 %8)
%9 = add nsw i32 %7, 1
%10 = icmp slt i32 %7, %2
br i1 %10, label %5, label %11
11: ; preds = %5, %3
ret void
}
int test_imm_E9uint64_lowword_mem(unsigned long long *val) {
  return ((*val) & (0xE9 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_E9uint64_lowword_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
and    $0xe9,%rdx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_E9uint64_lowword_mem>:
testb  $0xe9,(%rdi)
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_E9uint64_lowword_mem(i64* %0) {
%2 = alloca i64*
store i64* %0, i64** %2
%3 = load i64*, i64** %2
%4 = load i64, i64* %3
%5 = and i64 %4, 233
%6 = icmp ne i64 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 -20, i32 -40
ret i32 %8
}

LLVM IR (-O2):
define i32 @test_imm_E9uint64_lowword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 233
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int iParent(int i) {
  if (i - 1 == 0 || i - 2 == 0)
    return 0;
  else if ((i - 1) % 2 == 0)
    return (i - 1) / 2;
  else
    return (i - 2) / 2;
}


x86 assembly (clang, -O0):
<iParent>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
je     1125 <iParent+0x25>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cmp    $0x0,%eax
jne    1131 <iParent+0x31>
movl   $0x0,-0x4(%rbp)
jmp    116f <iParent+0x6f>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115e <iParent+0x5e>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    116f <iParent+0x6f>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<iParent>:
xor    %eax,%eax
mov    %edi,%ecx
add    $0xffffffff,%ecx
je     1125 <iParent+0x25>
add    $0xfffffffe,%edi
je     1125 <iParent+0x25>
test   $0x1,%cl
jne    111c <iParent+0x1c>
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
jmp    1123 <iParent+0x23>
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
ret

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

LLVM IR (-O2):
define i32 @iParent(i32 %0) {
%2 = add nsw i32 %0, -1
%3 = icmp eq i32 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = add nsw i32 %0, -2
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = and i32 %2, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = sdiv i32 %2, 2
br label %14
12: ; preds = %7
%13 = sdiv i32 %5, 2
br label %14
14: ; preds = %1, %4, %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ], [ 0, %4 ], [ 0, %1 ]
ret i32 %15
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void packet_renderer(char dgramrender[], char *targetdest) {
  int g;
  printf(" \r\n---Packet Render----\r\n");
  printf(" Target: %s\r\n", targetdest);
  printf("--------------------\r\n\r\n");
}


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

x86 assembly (clang, -O2):
<packet_renderer>:
push   %rbx
mov    %rsi,%rbx
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [26 x i8] c" \0D\0A---Packet Render----\0D\0A\00"
@.str.1 = [14 x i8] c" Target: %s\0D\0A\00"
@.str.2 = [25 x i8] c"--------------------\0D\0A\0D\0A\00"
define void @packet_renderer(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c" Target: %s\0D\0A\00"
@str = [25 x i8] c" \0D\0A---Packet Render----\0D\00"
@str.3 = [24 x i8] c"--------------------\0D\0A\0D\00"
define void @packet_renderer(i8* nocapture readnone %0, i8* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
ret void
}
int regina(int x) { return x + 23; }


x86 assembly (clang, -O0):
<regina>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x17,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @regina(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add nsw i32 %3, 23
ret i32 %4
}

LLVM IR (-O2):
define i32 @regina(i32 %0) {
%2 = add nsw i32 %0, 23
ret i32 %2
}