xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
void strv_print(char **l) {
  char **s;
  if (!l)
    return;
  for ((s) = (l); (s) && *(s); (s)++)
    puts(*s);
}


x86 assembly (clang, -O0):
<strv_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <strv_print+0x1c>
jmp    117f <strv_print+0x6f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1152 <strv_print+0x42>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1162 <strv_print+0x52>
jmp    117f <strv_print+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <strv_print+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strv_print>:
push   %rbx
test   %rdi,%rdi
je     1141 <strv_print+0x31>
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1141 <strv_print+0x31>
add    $0x8,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <puts@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1130 <strv_print+0x20>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @strv_print(i8** %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %11, %6 ], [ %4, %3 ]
%8 = phi i8** [ %10, %6 ], [ %0, %3 ]
%9 = tail call i32 @puts(i8* %7)
%10 = getelementptr inbounds i8*, i8** %8, i64 1
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6, %3, %1
ret void
}
float power(float val, int power) {
  float res = 1;
  int i;
  for (i = 0; i < power; i++) {
    res = res * val;
  }
  return res;
}


x86 assembly (clang, -O0):
<power>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
movss  0xeec(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1149 <power+0x49>
movss  -0xc(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1120 <power+0x20>
movss  -0xc(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<power>:
test   %edi,%edi
jle    111b <power+0x1b>
lea    -0x1(%rdi),%ecx
mov    %edi,%eax
and    $0x7,%eax
cmp    $0x7,%ecx
jae    1124 <power+0x24>
movss  0xee7(%rip),%xmm1
jmp    1155 <power+0x55>
movss  0xedd(%rip),%xmm0
ret
and    $0xfffffff8,%edi
movss  0xed1(%rip),%xmm1
nop
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
add    $0xfffffff8,%edi
jne    1130 <power+0x30>
test   %eax,%eax
je     1169 <power+0x69>
nopl   0x0(%rax)
mulss  %xmm0,%xmm1
add    $0xffffffff,%eax
jne    1160 <power+0x60>
movaps %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @power(float %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
store float %0, float* %3
store i32 %1, i32* %4
store float 1.000000e+00, float* %5
store i32 0, i32* %6
br label %7
7: ; preds = %15, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load float, float* %5
%13 = load float, float* %3
%14 = fmul float %12, %13
store float %14, float* %5
br label %15
15: ; preds = %11
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %7
18: ; preds = %7
%19 = load float, float* %5
ret float %19
}

LLVM IR (-O2):
define float @power(float %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %33
4: ; preds = %2
%5 = add i32 %1, -1
%6 = and i32 %1, 7
%7 = icmp ult i32 %5, 7
br i1 %7, label %23, label %8
8: ; preds = %4
%9 = and i32 %1, -8
br label %10
10: ; preds = %10, %8
%11 = phi float [ 1.000000e+00, %8 ], [ %20, %10 ]
%12 = phi i32 [ 0, %8 ], [ %21, %10 ]
%13 = fmul float %11, %0
%14 = fmul float %13, %0
%15 = fmul float %14, %0
%16 = fmul float %15, %0
%17 = fmul float %16, %0
%18 = fmul float %17, %0
%19 = fmul float %18, %0
%20 = fmul float %19, %0
%21 = add i32 %12, 8
%22 = icmp eq i32 %21, %9
br i1 %22, label %23, label %10
23: ; preds = %10, %4
%24 = phi float [ undef, %4 ], [ %20, %10 ]
%25 = phi float [ 1.000000e+00, %4 ], [ %20, %10 ]
%26 = icmp eq i32 %6, 0
br i1 %26, label %33, label %27
27: ; preds = %23, %27
%28 = phi float [ %30, %27 ], [ %25, %23 ]
%29 = phi i32 [ %31, %27 ], [ 0, %23 ]
%30 = fmul float %28, %0
%31 = add i32 %29, 1
%32 = icmp eq i32 %31, %6
br i1 %32, label %33, label %27
33: ; preds = %23, %27, %2
%34 = phi float [ 1.000000e+00, %2 ], [ %24, %23 ], [ %30, %27 ]
ret float %34
}
/* Variables and functions */
bool nrf53_errata_67(void) { return false; }


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

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

LLVM IR (-O0):
define i32 @nrf53_errata_67() {
ret i32 0
}

LLVM IR (-O2):
define i32 @nrf53_errata_67() {
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ val;

/* Variables and functions */
int /*<<< orphan*/ fread_unlocked(double *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stdin;
void transform_double(void) {
  double val;
  fread_unlocked(&val, sizeof(val), 1, stdin);
  printf("%f", val);
}


x86 assembly (clang, -O0):
<transform_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%ecx
lea    -0x8(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread_unlocked@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform_double>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread_unlocked@plt>
movsd  (%rsp),%xmm0
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%f\00"
define void @transform_double() {
%1 = alloca double
%2 = load i32, i32* @stdin
%3 = call i32 @fread_unlocked(double* %1, i32 8, i32 1, i32 %2)
%4 = load double, double* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %4)
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%f\00"
define void @transform_double() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = load i32, i32* @stdin
%4 = call i32 @fread_unlocked(double* %1, i32 8, i32 1, i32 %3)
%5 = load double, double* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %5)
ret void
}
int LZ5_compressBound(int isize) {
  return ((unsigned)(isize) > (unsigned)0x7E000000
              ? 0
              : (isize) + ((isize) / 128) + 16);
}


x86 assembly (clang, -O0):
<LZ5_compressBound>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x7e000000,-0x4(%rbp)
jbe    111e <LZ5_compressBound+0x1e>
xor    %eax,%eax
mov    %eax,-0x8(%rbp)
jmp    113c <LZ5_compressBound+0x3c>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
add    $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<LZ5_compressBound>:
mov    %edi,%eax
shr    $0x7,%eax
xor    %ecx,%ecx
cmp    $0x7e000001,%edi
lea    0x10(%rdi,%rax,1),%eax
cmovae %ecx,%eax
ret

LLVM IR (-O0):
define i32 @LZ5_compressBound(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ugt i32 %3, 2113929216
br i1 %4, label %5, label %6
5: ; preds = %1
br label %12
6: ; preds = %1
%7 = load i32, i32* %2
%8 = load i32, i32* %2
%9 = sdiv i32 %8, 128
%10 = add nsw i32 %7, %9
%11 = add nsw i32 %10, 16
br label %12
12: ; preds = %6, %5
%13 = phi i32 [ 0, %5 ], [ %11, %6 ]
ret i32 %13
}

LLVM IR (-O2):
define i32 @LZ5_compressBound(i32 %0) {
%2 = icmp ugt i32 %0, 2113929216
%3 = lshr i32 %0, 7
%4 = add i32 %0, 16
%5 = add i32 %4, %3
%6 = select i1 %2, i32 0, i32 %5
ret i32 %6
}
/* Type definitions */
struct sockaddr_in {
  int dummy;
};
struct hostent {
  int dummy;
};

/* Variables and functions */
int Common_Initialize_Sockaddr_in(struct sockaddr_in *, struct hostent **,
                                  char const *, short);
int Initialize_Sockaddr_in(struct sockaddr_in *server, struct hostent **hp,
                           const char *host_addr, short int port) {
  return Common_Initialize_Sockaddr_in(server, hp, host_addr, port);
}


x86 assembly (clang, -O0):
<Initialize_Sockaddr_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movswl -0x1a(%rbp),%ecx
call   1030 <Common_Initialize_Sockaddr_in@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Initialize_Sockaddr_in>:
jmp    1030 <Common_Initialize_Sockaddr_in@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.hostent = type { i32 }
define i32 @Initialize_Sockaddr_in(%struct.sockaddr_in* %0, %struct.hostent** %1, i8* %2, i16 signext %3) {
%5 = alloca %struct.sockaddr_in*
%6 = alloca %struct.hostent**
%7 = alloca i8*
%8 = alloca i16
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %5
store %struct.hostent** %1, %struct.hostent*** %6
store i8* %2, i8** %7
store i16 %3, i16* %8
%9 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%10 = load %struct.hostent**, %struct.hostent*** %6
%11 = load i8*, i8** %7
%12 = load i16, i16* %8
%13 = call i32 @Common_Initialize_Sockaddr_in(%struct.sockaddr_in* %9, %struct.hostent** %10, i8* %11, i16 signext %12)
ret i32 %13
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.hostent = type { i32 }
define i32 @Initialize_Sockaddr_in(%struct.sockaddr_in* %0, %struct.hostent** %1, i8* %2, i16 signext %3) {
%5 = tail call i32 @Common_Initialize_Sockaddr_in(%struct.sockaddr_in* %0, %struct.hostent** %1, i8* %2, i16 signext %3)
ret i32 %5
}
void gtk_action_activate() {}


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

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

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

LLVM IR (-O2):
define void @gtk_action_activate() {
ret void
}
double foo(double a) { return 2 * a; }


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

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

LLVM IR (-O0):
define double @foo(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fmul double 2.000000e+00, %3
ret double %4
}

LLVM IR (-O2):
define double @foo(double %0) {
%2 = fmul double %0, 2.000000e+00
ret double %2
}
/* Variables and functions */
int /*<<< orphan*/ createChildThreads();
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  printf("Main program starting %s\n", "jaggi");
  createChildThreads();
  printf("Main program exiting %s\n", "jaggi");
  return 0;
}


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)
lea    0xec3(%rip),%rdi
lea    0xed6(%rip),%rsi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <createChildThreads@plt>
lea    0xec9(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
lea    0xeeb(%rip),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <createChildThreads@plt>
lea    0xedb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Main program starting %s\0A\00"
@.str.1 = [6 x i8] c"jaggi\00"
@.str.2 = [25 x i8] c"Main program exiting %s\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 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (...) @createChildThreads()
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Main program starting %s\0A\00"
@.str.1 = [6 x i8] c"jaggi\00"
@.str.2 = [25 x i8] c"Main program exiting %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (...) @createChildThreads()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}
/* Type definitions */
struct sched_param {
  int dummy;
};
typedef int /*<<< orphan*/ pthread_attr_t;

/* Variables and functions */
int pthread_attr_setschedparam(int /*<<< orphan*/ *,
                               struct sched_param const *);
int my_pthread_attr_setschedparam(pthread_attr_t *__attr,
                                  struct sched_param const *param) {
  pthread_attr_t *realattr = (pthread_attr_t *)*(unsigned int *)__attr;
  return pthread_attr_setschedparam(realattr, param);
}


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

x86 assembly (clang, -O2):
<my_pthread_attr_setschedparam>:
mov    (%rdi),%edi
jmp    1030 <pthread_attr_setschedparam@plt>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
define i32 @my_pthread_attr_setschedparam(i32* %0, %struct.sched_param* %1) {
%3 = alloca i32*
%4 = alloca %struct.sched_param*
%5 = alloca i32*
store i32* %0, i32** %3
store %struct.sched_param* %1, %struct.sched_param** %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %6
%8 = zext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = load %struct.sched_param*, %struct.sched_param** %4
%12 = call i32 @pthread_attr_setschedparam(i32* %10, %struct.sched_param* %11)
ret i32 %12
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
define i32 @my_pthread_attr_setschedparam(i32* nocapture %0, %struct.sched_param* %1) {
%3 = load i32, i32* %0
%4 = zext i32 %3 to i64
%5 = inttoptr i64 %4 to i32*
%6 = tail call i32 @pthread_attr_setschedparam(i32* %5, %struct.sched_param* %1)
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ ksft_print_cnts();
int ksft_exit_pass(void) {
  ksft_print_cnts();
  exit(0);
}


x86 assembly (clang, -O0):
<ksft_exit_pass>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <ksft_print_cnts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<ksft_exit_pass>:
push   %rax
xor    %eax,%eax
call   1030 <ksft_print_cnts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define i32 @ksft_exit_pass() {
%1 = call i32 (...) @ksft_print_cnts()
%2 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @ksft_exit_pass() {
%1 = tail call i32 (...) @ksft_print_cnts()
%2 = tail call i32 @exit(i32 0)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int enterChoice(void) {
  int menuChoice;
  printf("Enter your choice:\n"
         "1 - Create a text file of all tools records\n"
         "    named \"tools.txt\"\n"
         "2 - add a new record\n"
         "3 - update an existing record\n"
         "4 - delete a record\n"
         "5 - display all tool records\n"
         "6 - end program\n? ");
  scanf("%d", &menuChoice);
  fflush(stdin);
  return menuChoice;
}


x86 assembly (clang, -O0):
<enterChoice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf81(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enterChoice>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
lea    0xf88(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [204 x i8] c"Enter your choice:\0A1 - Create a text file of all tools records\0A named \22tools.txt\22\0A2 - add a new record\0A3 - update an existing record\0A4 - delete a record\0A5 - display all tool records\0A6 - end program\0A? \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
define i32 @enterChoice() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([204 x i8], [204 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%4 = load i32, i32* @stdin
%5 = call i32 @fflush(i32 %4)
%6 = load i32, i32* %1
ret i32 %6
}

LLVM IR (-O2):
@.str = [204 x i8] c"Enter your choice:\0A1 - Create a text file of all tools records\0A named \22tools.txt\22\0A2 - add a new record\0A3 - update an existing record\0A4 - delete a record\0A5 - display all tool records\0A6 - end program\0A? \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
define i32 @enterChoice() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([204 x i8], [204 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* @stdin
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* %1
ret i32 %7
}
long int lrintl(long double x) { return x; }


x86 assembly (clang, -O0):
<lrintl>:
push   %rbp
mov    %rsp,%rbp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
fnstcw -0x1a(%rbp)
movzwl -0x1a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x1c(%rbp)
fldcw  -0x1c(%rbp)
fistpll -0x18(%rbp)
fldcw  -0x1a(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<lrintl>:
fldt   0x8(%rsp)
fnstcw -0xc(%rsp)
movzwl -0xc(%rsp),%eax
or     $0xc00,%eax
mov    %ax,-0xa(%rsp)
fldcw  -0xa(%rsp)
fistpll -0x8(%rsp)
fldcw  -0xc(%rsp)
mov    -0x8(%rsp),%rax
ret

LLVM IR (-O0):
define i64 @lrintl(x86_fp80 %0) {
%2 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %2
%3 = load x86_fp80, x86_fp80* %2
%4 = fptosi x86_fp80 %3 to i64
ret i64 %4
}

LLVM IR (-O2):
define i64 @lrintl(x86_fp80 %0) {
%2 = fptosi x86_fp80 %0 to i64
ret i64 %2
}
int sem_add(int semid, int val) { return 0; }


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

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

LLVM IR (-O0):
define i32 @sem_add(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
ret i32 0
}

LLVM IR (-O2):
define i32 @sem_add(i32 %0, i32 %1) {
ret i32 0
}
/* Variables and functions */
bool iscomment(int chr) { return chr != '\0' && chr != '\n'; }


x86 assembly (clang, -O0):
<iscomment>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     1120 <iscomment+0x20>
cmpl   $0xa,-0x4(%rbp)
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<iscomment>:
test   %edi,%edi
setne  %al
cmp    $0xa,%edi
setne  %cl
and    %al,%cl
movzbl %cl,%eax
ret

LLVM IR (-O0):
define i32 @iscomment(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 %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 10
br label %8
8: ; preds = %5, %1
%9 = phi i1 [ false, %1 ], [ %7, %5 ]
%10 = zext i1 %9 to i32
ret i32 %10
}

LLVM IR (-O2):
define i32 @iscomment(i32 %0) {
%2 = icmp ne i32 %0, 0
%3 = icmp ne i32 %0, 10
%4 = and i1 %2, %3
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ USE2(void *, void *);
void USE4(void *a, void *b, void *c, void *d) {
  USE2(a, b);
  USE2(c, d);
}


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

x86 assembly (clang, -O2):
<USE4>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
call   1030 <USE2@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <USE2@plt>

LLVM IR (-O0):
define void @USE4(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i32 @USE2(i8* %9, i8* %10)
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = call i32 @USE2(i8* %12, i8* %13)
ret void
}

LLVM IR (-O2):
define void @USE4(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @USE2(i8* %0, i8* %1)
%6 = tail call i32 @USE2(i8* %2, i8* %3)
ret void
}
unsigned int inttobcd(int num) {
  unsigned int result = 0U;
  while (num > 0) {
    result <<= 4;
    result |= ((num % 10) & 0xff);
    num /= 10;
  }
  return result;
}


x86 assembly (clang, -O0):
<inttobcd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    114c <inttobcd+0x4c>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
and    $0xff,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    110e <inttobcd+0xe>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<inttobcd>:
xor    %eax,%eax
test   %edi,%edi
jle    1130 <inttobcd+0x30>
mov    $0xcccccccd,%r8d
nopl   0x0(%rax)
shl    $0x4,%eax
mov    %edi,%edx
imul   %r8,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edi,%ecx
sub    %esi,%ecx
or     %ecx,%eax
cmp    $0x9,%edi
mov    %edx,%edi
ja     1110 <inttobcd+0x10>
ret

LLVM IR (-O0):
define i32 @inttobcd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %7, %1
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = load i32, i32* %3
%9 = shl i32 %8, 4
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
%12 = and i32 %11, 255
%13 = load i32, i32* %3
%14 = or i32 %13, %12
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = sdiv i32 %15, 10
store i32 %16, i32* %2
br label %4
17: ; preds = %4
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @inttobcd(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %11
3: ; preds = %1, %3
%4 = phi i32 [ %8, %3 ], [ 0, %1 ]
%5 = phi i32 [ %9, %3 ], [ %0, %1 ]
%6 = shl i32 %4, 4
%7 = urem i32 %5, 10
%8 = or i32 %6, %7
%9 = udiv i32 %5, 10
%10 = icmp ult i32 %5, 10
br i1 %10, label %11, label %3
11: ; preds = %3, %1
%12 = phi i32 [ 0, %1 ], [ %8, %3 ]
ret i32 %12
}
/* Variables and functions */
int nice(int);
void net_init(void) {
  int err;
  err = nice(-20);
}


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

x86 assembly (clang, -O2):
<net_init>:
mov    $0xffffffec,%edi
jmp    1030 <nice@plt>

LLVM IR (-O0):
define void @net_init() {
%1 = alloca i32
%2 = call i32 @nice(i32 -20)
store i32 %2, i32* %1
ret void
}

LLVM IR (-O2):
define void @net_init() {
%1 = tail call i32 @nice(i32 -20)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ mem_set(int *, int const, int);
int /*<<< orphan*/ vector_add(int *, int *, int *, int const);
void hello_world() {
  const int length = 10;
  int *a = 0;
  int *b = length * sizeof(int);
  int *res = 2 * length * sizeof(int);
  int i;
  for (i = 0; i < length; i++)
    a[i] = i;
  mem_set(b, length, 1);
  vector_add(res, a, b, length);
}


x86 assembly (clang, -O0):
<hello_world>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xa,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x28,%eax
mov    %rax,-0x18(%rbp)
mov    $0x50,%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    1176 <hello_world+0x56>
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <hello_world+0x30>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
call   1030 <mem_set@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0xa,%ecx
call   1040 <vector_add@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hello_world>:
push   %rax
mov    $0x28,%edi
mov    $0xa,%esi
mov    $0x1,%edx
call   1030 <mem_set@plt>
mov    $0x50,%edi
mov    $0x28,%edx
xor    %esi,%esi
mov    $0xa,%ecx
pop    %rax
jmp    1040 <vector_add@plt>

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

LLVM IR (-O2):
define void @hello_world() {
%1 = tail call i32 @mem_set(i32* inttoptr (i64 40 to i32*), i32 10, i32 1)
%2 = tail call i32 @vector_add(i32* inttoptr (i64 80 to i32*), i32* null, i32* inttoptr (i64 40 to i32*), i32 10)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ testCelebrities();
void run_tests() { testCelebrities(); }


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

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

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

LLVM IR (-O2):
define void @run_tests() {
%1 = tail call i32 (...) @testCelebrities()
ret void
}
void dj_stop(void) {}


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

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

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

LLVM IR (-O2):
define void @dj_stop() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
void load_glex() {
  int numErr = 0;
  if (numErr > 0)
    exit(1);
}


x86 assembly (clang, -O0):
<load_glex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1133 <load_glex+0x23>
mov    $0x1,%edi
call   1030 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @load_glex() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* %1
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @exit(i32 1)
unreachable
6: ; preds = %0
ret void
}

LLVM IR (-O2):
define void @load_glex() {
ret void
}
int fun(long n) {
  long m;
  if (n < 2)
    return n;
  if (n % 2 == 0)
    m = n / 2;
  else
    m = 3 * n + 1;
  return fun(m);
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x2,-0x10(%rbp)
jge    1133 <fun+0x23>
mov    -0x10(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    117b <fun+0x6b>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1162 <fun+0x52>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    116f <fun+0x5f>
imul   $0x3,-0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fun@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
mov    %rdi,%rax
cmp    $0x2,%rdi
jl     1127 <fun+0x27>
nopl   0x0(%rax)
mov    %rax,%rcx
shr    %rcx
test   $0x1,%al
lea    0x1(%rax,%rax,2),%rax
cmove  %rcx,%rax
cmp    $0x2,%rax
jge    1110 <fun+0x10>
ret

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

LLVM IR (-O2):
define i32 @fun(i64 %0) {
%2 = icmp slt i64 %0, 2
br i1 %2, label %3, label %6
3: ; preds = %6, %1
%4 = phi i64 [ %0, %1 ], [ %13, %6 ]
%5 = trunc i64 %4 to i32
ret i32 %5
6: ; preds = %1, %6
%7 = phi i64 [ %13, %6 ], [ %0, %1 ]
%8 = and i64 %7, 1
%9 = icmp eq i64 %8, 0
%10 = lshr i64 %7, 1
%11 = mul nsw i64 %7, 3
%12 = add nsw i64 %11, 1
%13 = select i1 %9, i64 %10, i64 %12
%14 = icmp slt i64 %13, 2
br i1 %14, label %3, label %6
}
/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, void (*)(int));
void use_quit(int sig) {
  printf("\n(interrupt) use quit to exit.\n");
  signal(SIGINT, use_quit);
}


x86 assembly (clang, -O0):
<use_quit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    0x2e99(%rip),%rsi
call   1040 <signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<use_quit>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
mov    0x2ea3(%rip),%rsi
pop    %rax
jmp    1040 <signal@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\0A(interrupt) use quit to exit.\0A\00"
@SIGINT = global i32 0
define void @use_quit(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @SIGINT
%5 = call i32 @signal(i32 %4, void (i32)* @use_quit)
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@str = [31 x i8] c"\0A(interrupt) use quit to exit.\00"
define void @use_quit(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @SIGINT
%4 = tail call i32 @signal(i32 %3, void (i32)* @use_quit)
ret void
}
void SWI_ISR(void) {
  for (;;) {
    ;
  }
}


x86 assembly (clang, -O0):
<SWI_ISR>:
push   %rbp
mov    %rsp,%rbp
jmp    1109 <SWI_ISR+0x9>
jmp    1109 <SWI_ISR+0x9>

x86 assembly (clang, -O2):
<SWI_ISR>:
jmp    1100 <SWI_ISR>

LLVM IR (-O0):
define void @SWI_ISR() {
br label %1
1: ; preds = %1, %0
br label %1
}

LLVM IR (-O2):
define void @SWI_ISR() {
br label %1
1: ; preds = %1, %0
br label %1
}
/* Variables and functions */
int /*<<< orphan*/ genericError(char *, int);
void errorMalloc() { genericError("Malloc failed!", 1); }


x86 assembly (clang, -O0):
<errorMalloc>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
mov    $0x1,%esi
call   1030 <genericError@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<errorMalloc>:
lea    0xee9(%rip),%rdi
mov    $0x1,%esi
jmp    1030 <genericError@plt>

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

LLVM IR (-O2):
@.str = [15 x i8] c"Malloc failed!\00"
define void @errorMalloc() {
%1 = tail call i32 @genericError(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 1)
ret void
}
int yyerror(void *root, char const *msg) { return 1; }


x86 assembly (clang, -O0):
<yyerror>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @yyerror(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
ret i32 1
}

LLVM IR (-O2):
define i32 @yyerror(i8* nocapture readnone %0, i8* nocapture readnone %1) {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ free(void **);
int omp_get_thread_num();
void ompx_free(void **ptrs) {
#pragma omp parallel shared(ptrs)
  {
    int me = omp_get_thread_num();
    free(ptrs[me]);
  }
  free(ptrs);
}


x86 assembly (clang, -O0):
<ompx_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ompx_free>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
cltq
mov    (%rbx,%rax,8),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @ompx_free(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
%4 = call i32 (...) @omp_get_thread_num()
store i32 %4, i32* %3
%5 = load i8**, i8*** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %5, i64 %7
%9 = load i8*, i8** %8
%10 = bitcast i8* %9 to i8**
%11 = call i32 @free(i8** %10)
%12 = load i8**, i8*** %2
%13 = call i32 @free(i8** %12)
ret void
}

LLVM IR (-O2):
define void @ompx_free(i8** nocapture %0) {
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8*, i8** %0, i64 %3
%5 = bitcast i8** %4 to i8***
%6 = load i8**, i8*** %5
%7 = tail call i32 @free(i8** %6)
%8 = tail call i32 @free(i8** %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void test_newline(void) { printf("\r\n"); }


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

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

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

LLVM IR (-O2):
@str = [2 x i8] c"\0D\00"
define void @test_newline() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}
void rop3_173_0_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  unsigned char stk3;
  stk3 = S & *D;
  stk2 = T | stk3;
  stk1 = *D ^ stk2;
  stk1 = ~stk1;
  *D = stk1;
}


x86 assembly (clang, -O0):
<rop3_173_0_0>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
movzbl -0x9(%rbp),%eax
mov    -0x8(%rbp),%rcx
movzbl (%rcx),%ecx
and    %ecx,%eax
mov    %al,-0xd(%rbp)
movzbl -0xa(%rbp),%eax
movzbl -0xd(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
movzbl -0xc(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0xb(%rbp)
movzbl -0xb(%rbp),%eax
xor    $0xffffffff,%eax
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rop3_173_0_0>:
mov    (%rdi),%al
and    %al,%sil
or     %dl,%sil
xor    %al,%sil
not    %sil
mov    %sil,(%rdi)
ret

LLVM IR (-O0):
define void @rop3_173_0_0(i8* %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = and i32 %11, %14
%16 = trunc i32 %15 to i8
store i8 %16, i8* %9
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = load i8, i8* %9
%20 = zext i8 %19 to i32
%21 = or i32 %18, %20
%22 = trunc i32 %21 to i8
store i8 %22, i8* %8
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = load i8, i8* %8
%27 = zext i8 %26 to i32
%28 = xor i32 %25, %27
%29 = trunc i32 %28 to i8
store i8 %29, i8* %7
%30 = load i8, i8* %7
%31 = zext i8 %30 to i32
%32 = xor i32 %31, -1
%33 = trunc i32 %32 to i8
store i8 %33, i8* %7
%34 = load i8, i8* %7
%35 = load i8*, i8** %4
store i8 %34, i8* %35
ret void
}

LLVM IR (-O2):
define void @rop3_173_0_0(i8* nocapture %0, i8 zeroext %1, i8 zeroext %2) {
%4 = load i8, i8* %0
%5 = and i8 %4, %1
%6 = or i8 %5, %2
%7 = xor i8 %4, %6
%8 = xor i8 %7, -1
store i8 %8, i8* %0
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test_utils_strncpy_0();
int /*<<< orphan*/ test_utils_strncpy_1();
int /*<<< orphan*/ test_utils_strncpy_basic();
int /*<<< orphan*/ test_utils_strncpy_concat();
int /*<<< orphan*/ test_utils_strncpy_concat_loop();
int /*<<< orphan*/ test_utils_strncpy_overflow();
void test_utils(void) {
  test_utils_strncpy_basic();
  test_utils_strncpy_overflow();
  test_utils_strncpy_1();
  test_utils_strncpy_0();
  test_utils_strncpy_concat();
  test_utils_strncpy_concat_loop();
  printf("All utils tests passed!\n");
}


x86 assembly (clang, -O0):
<test_utils>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1070 <test_utils_strncpy_basic@plt>
mov    $0x0,%al
call   1060 <test_utils_strncpy_overflow@plt>
mov    $0x0,%al
call   1080 <test_utils_strncpy_1@plt>
mov    $0x0,%al
call   1030 <test_utils_strncpy_0@plt>
mov    $0x0,%al
call   1090 <test_utils_strncpy_concat@plt>
mov    $0x0,%al
call   1050 <test_utils_strncpy_concat_loop@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_utils>:
push   %rax
xor    %eax,%eax
call   1070 <test_utils_strncpy_basic@plt>
xor    %eax,%eax
call   1060 <test_utils_strncpy_overflow@plt>
xor    %eax,%eax
call   1080 <test_utils_strncpy_1@plt>
xor    %eax,%eax
call   1040 <test_utils_strncpy_0@plt>
xor    %eax,%eax
call   1090 <test_utils_strncpy_concat@plt>
xor    %eax,%eax
call   1050 <test_utils_strncpy_concat_loop@plt>
lea    0xe5e(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"All utils tests passed!\0A\00"
define void @test_utils() {
%1 = call i32 (...) @test_utils_strncpy_basic()
%2 = call i32 (...) @test_utils_strncpy_overflow()
%3 = call i32 (...) @test_utils_strncpy_1()
%4 = call i32 (...) @test_utils_strncpy_0()
%5 = call i32 (...) @test_utils_strncpy_concat()
%6 = call i32 (...) @test_utils_strncpy_concat_loop()
%7 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [24 x i8] c"All utils tests passed!\00"
define void @test_utils() {
%1 = tail call i32 (...) @test_utils_strncpy_basic()
%2 = tail call i32 (...) @test_utils_strncpy_overflow()
%3 = tail call i32 (...) @test_utils_strncpy_1()
%4 = tail call i32 (...) @test_utils_strncpy_0()
%5 = tail call i32 (...) @test_utils_strncpy_concat()
%6 = tail call i32 (...) @test_utils_strncpy_concat_loop()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
void usage(char *pname) {
  printf("USAGE: %s [msg] [qty]\n", pname);
  exit(1);
}


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

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

LLVM IR (-O0):
@.str = [23 x i8] c"USAGE: %s [msg] [qty]\0A\00"
define void @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"USAGE: %s [msg] [qty]\0A\00"
define void @usage(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @exit(i32 1)
unreachable
}
double floor(x)
double x;
{
  extern double modf();
  double val;
  return modf(x, &val) < 0 ? val - 1.0 : val;
}


x86 assembly (clang, -O0):
<floor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
call   1030 <modf@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1156 <floor+0x46>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1160 <floor+0x50>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floor>:
push   %rax
mov    %rsp,%rdi
call   1030 <modf@plt>
movsd  (%rsp),%xmm1
movsd  0xeda(%rip),%xmm2
addsd  %xmm1,%xmm2
xorpd  %xmm3,%xmm3
cmpltsd %xmm3,%xmm0
movapd %xmm0,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm2,%xmm0
orpd   %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @floor(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = call double @modf(double %4, double* %3)
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load double, double* %3
%9 = fsub double %8, 1.000000e+00
br label %12
10: ; preds = %1
%11 = load double, double* %3
br label %12
12: ; preds = %10, %7
%13 = phi double [ %9, %7 ], [ %11, %10 ]
ret double %13
}

LLVM IR (-O2):
define double @floor(double %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = call double @modf(double %0, double* %2)
%5 = fcmp olt double %4, 0.000000e+00
%6 = load double, double* %2
%7 = fadd double %6, -1.000000e+00
%8 = select i1 %5, double %7, double %6
ret double %8
}
int test_imm_77uint8_reg(unsigned char val) {
  return ((val) & (0x77 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_77uint8_reg>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edx
and    $0x77,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_77uint8_reg>:
test   $0x77,%dil
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_77uint8_reg(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = and i32 %4, 119
%6 = icmp ne i32 %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_77uint8_reg(i8 zeroext %0) {
%2 = and i8 %0, 119
%3 = icmp eq i8 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
void chip8_init(void) {}


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

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

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

LLVM IR (-O2):
define void @chip8_init() {
ret void
}
unsigned xrop3_37_0_0(unsigned char s, unsigned char t) {
  unsigned D = 0x00ff;
  unsigned S = ((unsigned)s << 8) | s;
  unsigned T = ((unsigned)t << 8) | t;
  unsigned stk1;
  unsigned stk2;
  unsigned stk3;
  stk3 = S & T;
  stk3 = ~stk3;
  stk2 = D & stk3;
  stk1 = T ^ stk2;
  stk1 = ~stk1;
  return stk1;
}


x86 assembly (clang, -O0):
<xrop3_37_0_0>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movl   $0xff,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x8,%eax
movzbl -0x1(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
movzbl -0x2(%rbp),%eax
shl    $0x8,%eax
movzbl -0x2(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrop3_37_0_0>:
mov    %esi,%ecx
shl    $0x8,%ecx
or     %esi,%ecx
and    %esi,%edi
lea    -0x100(%rdi),%eax
xor    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @xrop3_37_0_0(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
store i32 255, i32* %5
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = shl i32 %12, 8
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = or i32 %13, %15
store i32 %16, i32* %6
%17 = load i8, i8* %4
%18 = zext i8 %17 to i32
%19 = shl i32 %18, 8
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = or i32 %19, %21
store i32 %22, i32* %7
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = and i32 %23, %24
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = xor i32 %26, -1
store i32 %27, i32* %10
%28 = load i32, i32* %5
%29 = load i32, i32* %10
%30 = and i32 %28, %29
store i32 %30, i32* %9
%31 = load i32, i32* %7
%32 = load i32, i32* %9
%33 = xor i32 %31, %32
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = xor i32 %34, -1
store i32 %35, i32* %8
%36 = load i32, i32* %8
ret i32 %36
}

LLVM IR (-O2):
define i32 @xrop3_37_0_0(i8 zeroext %0, i8 zeroext %1) {
%3 = zext i8 %1 to i32
%4 = mul nuw nsw i32 %3, 257
%5 = and i8 %1, %0
%6 = zext i8 %5 to i32
%7 = or i32 %6, -256
%8 = xor i32 %7, %4
ret i32 %8
}