xunge/DecIR huggingface dataset:
/* Variables and functions */
scalar_t__ isspace(char);
char *stripwhite(char *line) {
  char *p = line;
  while (isspace(*p)) {
    p++;
  }
  return p;
}


x86 assembly (clang, -O0):
<stripwhite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     114b <stripwhite+0x3b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <stripwhite+0x14>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripwhite>:
push   %rbx
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    1120 <stripwhite+0x10>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @stripwhite(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %10, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i64 @isspace(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
br label %5
13: ; preds = %5
%14 = load i8*, i8** %3
ret i8* %14
}

LLVM IR (-O2):
define i8* @stripwhite(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2
ret i8* %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
void lib_motor(int v0, int v1) { printf("motor  %d  %d \n", v0, v1); }


x86 assembly (clang, -O0):
<lib_motor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib_motor>:
mov    %esi,%edx
mov    %edi,%esi
lea    0xee5(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"motor %d %d \0A\00"
define void @lib_motor(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 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"motor %d %d \0A\00"
define void @lib_motor(i32 %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
ret void
}
/* Variables and functions */
float cos(float);
float cosf(float x) { return cos(x); }


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

x86 assembly (clang, -O2):
<cosf>:
jmp    1030 <cos@plt>

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

LLVM IR (-O2):
define float @cosf(float %0) {
%2 = tail call float @cos(float %0)
ret float %2
}
/* Variables and functions */
char *strsep(char **, char const *);
char *strtok(char *s, const char *delim) {
  static char *holder;
  if (s)
    holder = s;
  do {
    s = strsep(&holder, delim);
  } while (s && !*s);
  return s;
}


x86 assembly (clang, -O0):
<strtok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1136 <strtok+0x26>
mov    -0x8(%rbp),%rax
mov    %rax,0x2efa(%rip)
jmp    113b <strtok+0x2b>
mov    -0x10(%rbp),%rsi
lea    0x2eea(%rip),%rdi
call   1030 <strsep@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     116e <strtok+0x5e>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113b <strtok+0x2b>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtok>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %rdi,%rdi
je     1123 <strtok+0x13>
mov    %rdi,0x2f0d(%rip)
lea    0x2f06(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strsep@plt>
test   %rax,%rax
je     1145 <strtok+0x35>
cmpb   $0x0,(%rax)
je     1130 <strtok+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@strtok.holder = internal global i8* null
define i8* @strtok(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = load i8*, i8** %3
store i8* %8, i8** @strtok.holder
br label %9
9: ; preds = %7, %2
br label %10
10: ; preds = %21, %9
%11 = load i8*, i8** %4
%12 = call i8* @strsep(i8** @strtok.holder, i8* %11)
store i8* %12, i8** %3
br label %13
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
%20 = xor i1 %19, true
br label %21
21: ; preds = %16, %13
%22 = phi i1 [ false, %13 ], [ %20, %16 ]
br i1 %22, label %10, label %23
23: ; preds = %21
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
@strtok.holder = internal global i8* null
define i8* @strtok(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %5, label %4
4: ; preds = %2
store i8* %0, i8** @strtok.holder
br label %5
5: ; preds = %4, %2
br label %6
6: ; preds = %5, %9
%7 = tail call i8* @strsep(i8** @strtok.holder, i8* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %9
ret i8* %7
}
/* Type definitions */
struct aeEventLoop {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ puts(char *);
void loop_init(struct aeEventLoop *l) { puts("I'm loop_init!!! \n"); }


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

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

LLVM IR (-O0):
%struct.aeEventLoop = type { i32 }
@.str = [19 x i8] c"I'm loop_init!!! \0A\00"
define void @loop_init(%struct.aeEventLoop* %0) {
%2 = alloca %struct.aeEventLoop*
store %struct.aeEventLoop* %0, %struct.aeEventLoop** %2
%3 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.aeEventLoop = type { i32 }
@.str = [19 x i8] c"I'm loop_init!!! \0A\00"
define void @loop_init(%struct.aeEventLoop* nocapture readnone %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
ret void
}
float lerp(float a, float b, float numerator, float denominator) {
  return a + numerator * (b - a) / denominator;
}


x86 assembly (clang, -O0):
<lerp>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm2
subss  -0x4(%rbp),%xmm2
mulss  %xmm2,%xmm1
divss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<lerp>:
subss  %xmm0,%xmm1
mulss  %xmm2,%xmm1
divss  %xmm3,%xmm1
addss  %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @lerp(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%9 = load float, float* %5
%10 = load float, float* %7
%11 = load float, float* %6
%12 = load float, float* %5
%13 = fsub float %11, %12
%14 = fmul float %10, %13
%15 = load float, float* %8
%16 = fdiv float %14, %15
%17 = fadd float %9, %16
ret float %17
}

LLVM IR (-O2):
define float @lerp(float %0, float %1, float %2, float %3) {
%5 = fsub float %1, %0
%6 = fmul float %5, %2
%7 = fdiv float %6, %3
%8 = fadd float %7, %0
ret float %8
}
void f(int *p, int *q) {
  *p = 1;
  *q = 2;
}


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

x86 assembly (clang, -O2):
<f>:
movl   $0x1,(%rdi)
movl   $0x2,(%rsi)
ret

LLVM IR (-O0):
define void @f(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
store i32 1, i32* %5
%6 = load i32*, i32** %4
store i32 2, i32* %6
ret void
}

LLVM IR (-O2):
define void @f(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
store i32 1, i32* %0
store i32 2, i32* %1
ret void
}
unsigned long UARTFlowControlGet(unsigned long ulBase) {
  ;
  return ((*((volatile unsigned long *)(ulBase + 0x00000030))) &
          (0x00008000 | 0x00004000));
}


x86 assembly (clang, -O0):
<UARTFlowControlGet>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x30(%rax),%rax
and    $0xc000,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<UARTFlowControlGet>:
mov    0x30(%rdi),%rax
and    $0xc000,%eax
ret

LLVM IR (-O0):
define i64 @UARTFlowControlGet(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = add i64 %3, 48
%5 = inttoptr i64 %4 to i64*
%6 = load volatile i64, i64* %5
%7 = and i64 %6, 49152
ret i64 %7
}

LLVM IR (-O2):
define i64 @UARTFlowControlGet(i64 %0) {
%2 = add i64 %0, 48
%3 = inttoptr i64 %2 to i64*
%4 = load volatile i64, i64* %3
%5 = and i64 %4, 49152
ret i64 %5
}
/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ freeHistory();
int /*<<< orphan*/ linenoiseDisableRawMode(int /*<<< orphan*/);
void linenoiseAtExit(void) {
  linenoiseDisableRawMode(STDIN_FILENO);
  freeHistory();
}


x86 assembly (clang, -O0):
<linenoiseAtExit>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
call   1030 <linenoiseDisableRawMode@plt>
mov    $0x0,%al
call   1040 <freeHistory@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<linenoiseAtExit>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
call   1030 <linenoiseDisableRawMode@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <freeHistory@plt>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
define void @linenoiseAtExit() {
%1 = load i32, i32* @STDIN_FILENO
%2 = call i32 @linenoiseDisableRawMode(i32 %1)
%3 = call i32 (...) @freeHistory()
ret void
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
define void @linenoiseAtExit() {
%1 = load i32, i32* @STDIN_FILENO
%2 = tail call i32 @linenoiseDisableRawMode(i32 %1)
%3 = tail call i32 (...) @freeHistory()
ret void
}
/* Variables and functions */
void os_program_deinit(void) {}


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

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

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

LLVM IR (-O2):
define void @os_program_deinit() {
ret void
}
void foo558() {}


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

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

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

LLVM IR (-O2):
define void @foo558() {
ret void
}
void bmoments(double a, double b, double *mean, double *var) {
  double x2, g, xmean, x, m, v;
  double xa, xb, ym, yv;
  x = a + b;
  *mean = a / x;
  *var = (a * b) / (x * x * (x + 1));
}


x86 assembly (clang, -O0):
<bmoments>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  0xead(%rip),%xmm2
addsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmoments>:
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm0,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,(%rdi)
mulsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
addsd  0xedc(%rip),%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
movsd  %xmm0,(%rsi)
ret

LLVM IR (-O0):
define void @bmoments(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%19 = load double, double* %5
%20 = load double, double* %6
%21 = fadd double %19, %20
store double %21, double* %12
%22 = load double, double* %5
%23 = load double, double* %12
%24 = fdiv double %22, %23
%25 = load double*, double** %7
store double %24, double* %25
%26 = load double, double* %5
%27 = load double, double* %6
%28 = fmul double %26, %27
%29 = load double, double* %12
%30 = load double, double* %12
%31 = fmul double %29, %30
%32 = load double, double* %12
%33 = fadd double %32, 1.000000e+00
%34 = fmul double %31, %33
%35 = fdiv double %28, %34
%36 = load double*, double** %8
store double %35, double* %36
ret void
}

LLVM IR (-O2):
define void @bmoments(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = fadd double %0, %1
%6 = fdiv double %0, %5
store double %6, double* %2
%7 = fmul double %0, %1
%8 = fmul double %5, %5
%9 = fadd double %5, 1.000000e+00
%10 = fmul double %8, %9
%11 = fdiv double %7, %10
store double %11, double* %3
ret void
}
/* Variables and functions */
int /*<<< orphan*/ sort(int *, int /*<<< orphan*/, int);
void quick_sort(int *array, int size) { sort(array, 0, size); }


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

x86 assembly (clang, -O2):
<quick_sort>:
mov    %esi,%edx
xor    %esi,%esi
jmp    1030 <sort@plt>

LLVM IR (-O0):
define void @quick_sort(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 @sort(i32* %5, i32 0, i32 %6)
ret void
}

LLVM IR (-O2):
define void @quick_sort(i32* %0, i32 %1) {
%3 = tail call i32 @sort(i32* %0, i32 0, i32 %1)
ret void
}
/* Forward declarations */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  long quot;
  long rem;
};
typedef TYPE_1__ ldiv_t;

/* Variables and functions */
ldiv_t ldiv(long int numer, long int denom) {
  ldiv_t result;
  result.quot = numer / denom;
  result.rem = numer % denom;
  return result;
}


x86 assembly (clang, -O0):
<ldiv>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rdx
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldiv>:
mov    %rdi,%rax
mov    %rdi,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     1115 <ldiv+0x15>
cqto
idiv   %rsi
ret
xor    %edx,%edx
div    %esi
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i64 }
define { i64, i64 } @ldiv(i64 %0, i64 %1) {
%3 = alloca %struct.TYPE_3__
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
%6 = load i64, i64* %4
%7 = load i64, i64* %5
%8 = sdiv i64 %6, %7
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
store i64 %8, i64* %9
%10 = load i64, i64* %4
%11 = load i64, i64* %5
%12 = srem i64 %10, %11
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
store i64 %12, i64* %13
%14 = bitcast %struct.TYPE_3__* %3 to { i64, i64 }*
%15 = load { i64, i64 }, { i64, i64 }* %14
ret { i64, i64 } %15
}

LLVM IR (-O2):
define { i64, i64 } @ldiv(i64 %0, i64 %1) {
%3 = sdiv i64 %0, %1
%4 = srem i64 %0, %1
%5 = insertvalue { i64, i64 } poison, i64 %3, 0
%6 = insertvalue { i64, i64 } %5, i64 %4, 1
ret { i64, i64 } %6
}
/* Variables and functions */
int /*<<< orphan*/ lv1_panic(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void fatal(const char *msg) {
  printf("FATAL: %s\n", msg);
  printf("Panicking.\n");
  lv1_panic(0);
  while (1)
    ;
}


x86 assembly (clang, -O0):
<fatal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1030 <lv1_panic@plt>
jmp    1153 <fatal+0x33>

x86 assembly (clang, -O2):
<fatal>:
push   %rax
mov    %rdi,%rsi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1030 <lv1_panic@plt>
cs nopw 0x0(%rax,%rax,1)
nop
jmp    1160 <fatal+0x30>

LLVM IR (-O0):
@.str = [11 x i8] c"FATAL: %s\0A\00"
@.str.1 = [12 x i8] c"Panicking.\0A\00"
define void @fatal(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @lv1_panic(i32 0)
br label %7
7: ; preds = %1, %7
br label %7
}

LLVM IR (-O2):
@.str = [11 x i8] c"FATAL: %s\0A\00"
@str = [11 x i8] c"Panicking.\00"
define void @fatal(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @lv1_panic(i32 0)
br label %5
5: ; preds = %1, %5
br label %5
}
/* Variables and functions */
int abs(int);
int rand();
int rnd(int range) { return abs((rand() >> 5) + (rand() >> 5)) % range; }


x86 assembly (clang, -O0):
<rnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
sar    $0x5,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x8(%rbp),%edi
sar    $0x5,%eax
add    %eax,%edi
call   1030 <abs@plt>
cltd
idivl  -0x4(%rbp)
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnd>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
sar    $0x5,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
sar    $0x5,%eax
add    %ebp,%eax
mov    %eax,%ecx
neg    %ecx
cmovns %ecx,%eax
cltd
idiv   %ebx
mov    %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rnd(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @rand()
%4 = ashr i32 %3, 5
%5 = call i32 (...) @rand()
%6 = ashr i32 %5, 5
%7 = add nsw i32 %4, %6
%8 = call i32 @abs(i32 %7)
%9 = load i32, i32* %2
%10 = srem i32 %8, %9
ret i32 %10
}

LLVM IR (-O2):
define i32 @rnd(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = ashr i32 %2, 5
%4 = tail call i32 (...) @rand()
%5 = ashr i32 %4, 5
%6 = add nsw i32 %5, %3
%7 = tail call i32 @llvm.abs.i32(i32 %6, i1 true)
%8 = srem i32 %7, %0
ret i32 %8
}
char *Salloc(s)
char *s;
{ return strcpy(Malloc(strlen(s) + 1), s); }


x86 assembly (clang, -O0):
<Salloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x0,%al
call   1030 <Malloc@plt>
movslq %eax,%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Salloc>:
push   %rbx
mov    %rdi,%rbx
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
xor    %eax,%eax
call   1030 <Malloc@plt>
movslq %eax,%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1040 <strcpy@plt>

LLVM IR (-O0):
define i8* @Salloc(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @strlen(i8* %3)
%5 = add i64 %4, 1
%6 = call i32 (i64, ...) bitcast (i32 (...)* @Malloc to i32 (i64, ...)*)(i64 %5)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
%9 = load i8*, i8** %2
%10 = call i8* @strcpy(i8* %8, i8* %9)
ret i8* %10
}

LLVM IR (-O2):
define i8* @Salloc(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add i64 %2, 1
%4 = tail call i32 (i64, ...) bitcast (i32 (...)* @Malloc to i32 (i64, ...)*)(i64 %3)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i8*
%7 = tail call i8* @strcpy(i8* dereferenceable(1) %6, i8* dereferenceable(1) %0)
ret i8* %6
}
void SPI_SD_SaveConfig(void) {}


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

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

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

LLVM IR (-O2):
define void @SPI_SD_SaveConfig() {
ret void
}
/* Type definitions */
struct cart {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _cartVarDbName(char *, char *);
char *cartString(struct cart *, int /*<<< orphan*/);
char *cartStringDb(struct cart *cart, char *db, char *var) {
  return cartString(cart, _cartVarDbName(db, var));
}


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

x86 assembly (clang, -O2):
<cartStringDb>:
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1040 <_cartVarDbName@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1030 <cartString@plt>

LLVM IR (-O0):
%struct.cart = type { i32 }
define i8* @cartStringDb(%struct.cart* %0, i8* %1, i8* %2) {
%4 = alloca %struct.cart*
%5 = alloca i8*
%6 = alloca i8*
store %struct.cart* %0, %struct.cart** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load %struct.cart*, %struct.cart** %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = call i32 @_cartVarDbName(i8* %8, i8* %9)
%11 = call i8* @cartString(%struct.cart* %7, i32 %10)
ret i8* %11
}

LLVM IR (-O2):
%struct.cart = type { i32 }
define i8* @cartStringDb(%struct.cart* %0, i8* %1, i8* %2) {
%4 = tail call i32 @_cartVarDbName(i8* %1, i8* %2)
%5 = tail call i8* @cartString(%struct.cart* %0, i32 %4)
ret i8* %5
}
double max(double a, double b) {
  double maximum = a > b ? a : b;
  return maximum;
}


x86 assembly (clang, -O0):
<max>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    112d <max+0x2d>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1137 <max+0x37>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<max>:
maxsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define double @max(double %0, double %1) {
%3 = fcmp ogt double %0, %1
%4 = select i1 %3, double %0, double %1
ret double %4
}
/* Type definitions */
struct bplus_tree {
  int dummy;
};
typedef int /*<<< orphan*/ key_t;

/* Variables and functions */
int bplus_tree_delete(struct bplus_tree *, int /*<<< orphan*/);
int bplus_tree_insert(struct bplus_tree *, int /*<<< orphan*/, long);
int bplus_tree_put(struct bplus_tree *tree, key_t key, long data) {
  if (data) {
    return bplus_tree_insert(tree, key, data);
  } else {
    return bplus_tree_delete(tree, key);
  }
}


x86 assembly (clang, -O0):
<bplus_tree_put>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1156 <bplus_tree_put+0x36>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1030 <bplus_tree_insert@plt>
mov    %eax,-0x4(%rbp)
jmp    1165 <bplus_tree_put+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <bplus_tree_delete@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bplus_tree_put>:
test   %rdx,%rdx
je     112a <bplus_tree_put+0xa>
jmp    1030 <bplus_tree_insert@plt>
jmp    1040 <bplus_tree_delete@plt>

LLVM IR (-O0):
%struct.bplus_tree = type { i32 }
define i32 @bplus_tree_put(%struct.bplus_tree* %0, i32 %1, i64 %2) {
%4 = alloca i32
%5 = alloca %struct.bplus_tree*
%6 = alloca i32
%7 = alloca i64
store %struct.bplus_tree* %0, %struct.bplus_tree** %5
store i32 %1, i32* %6
store i64 %2, i64* %7
%8 = load i64, i64* %7
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load %struct.bplus_tree*, %struct.bplus_tree** %5
%12 = load i32, i32* %6
%13 = load i64, i64* %7
%14 = call i32 @bplus_tree_insert(%struct.bplus_tree* %11, i32 %12, i64 %13)
store i32 %14, i32* %4
br label %19
15: ; preds = %3
%16 = load %struct.bplus_tree*, %struct.bplus_tree** %5
%17 = load i32, i32* %6
%18 = call i32 @bplus_tree_delete(%struct.bplus_tree* %16, i32 %17)
store i32 %18, i32* %4
br label %19
19: ; preds = %15, %10
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
%struct.bplus_tree = type { i32 }
define i32 @bplus_tree_put(%struct.bplus_tree* %0, i32 %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @bplus_tree_insert(%struct.bplus_tree* %0, i32 %1, i64 %2)
br label %9
7: ; preds = %3
%8 = tail call i32 @bplus_tree_delete(%struct.bplus_tree* %0, i32 %1)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
ret i32 %10
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
bool testPath(char path[]) {
  FILE *testfile = fopen(path, "r");
  if (testfile != NULL) {
    fclose(testfile);
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<testPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1160 <testPath+0x40>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1167 <testPath+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testPath>:
push   %rax
lea    0xed8(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1141 <testPath+0x21>
mov    %rax,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @testPath(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @fclose(i32* %2)
br label %6
6: ; preds = %1, %4
%7 = phi i32 [ 1, %4 ], [ 0, %1 ]
ret i32 %7
}
int xassert_msg(const char msg[]) { return 1; }


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

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

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

LLVM IR (-O2):
define i32 @xassert_msg(i8* nocapture readnone %0) {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ mvprintw(int, int, char *, char *);
int strlen(char *);
void PrintCenter(char *str, int y, int x, int width) {
  int len = strlen(str), i, j, start = (width - len) / 2;
  mvprintw(y, x + start, "%s", str);
}


x86 assembly (clang, -O0):
<PrintCenter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
add    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xe9a(%rip),%rdx
call   1040 <mvprintw@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintCenter>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbp
call   1030 <strlen@plt>
sub    %eax,%ebx
mov    %ebx,%esi
shr    $0x1f,%esi
add    %ebx,%esi
sar    %esi
add    %r15d,%esi
lea    0xeb4(%rip),%rdx
mov    %r14d,%edi
mov    %rbp,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mvprintw@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @PrintCenter(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %9
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = sub nsw i32 %15, %16
%18 = sdiv i32 %17, 2
store i32 %18, i32* %12
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = load i32, i32* %12
%22 = add nsw i32 %20, %21
%23 = load i8*, i8** %5
%24 = call i32 @mvprintw(i32 %19, i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @PrintCenter(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = sub nsw i32 %3, %5
%7 = sdiv i32 %6, 2
%8 = add nsw i32 %7, %2
%9 = tail call i32 @mvprintw(i32 %1, i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
int pointer_compare(void *location1, void *location2) {
  if (location1 < location2) {
    return -1;
  } else if (location1 > location2) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<pointer_compare>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1126 <pointer_compare+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    1147 <pointer_compare+0x47>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1140 <pointer_compare+0x40>
movl   $0x1,-0x4(%rbp)
jmp    1147 <pointer_compare+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointer_compare>:
xor    %ecx,%ecx
cmp    %rsi,%rdi
seta   %cl
mov    $0xffffffff,%eax
cmovae %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @pointer_compare(i8* readnone %0, i8* readnone %1) {
%3 = icmp ult i8* %0, %1
%4 = icmp ugt i8* %0, %1
%5 = zext i1 %4 to i32
%6 = select i1 %3, i32 -1, i32 %5
ret i32 %6
}
/* Variables and functions */
int random();
int random_int(void) { return (random() % 1000000); }


x86 assembly (clang, -O0):
<random_int>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <random@plt>
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_int>:
push   %rax
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x431bde83,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rcx
add    %edx,%ecx
imul   $0xf4240,%ecx,%ecx
sub    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @random_int() {
%1 = call i32 (...) @random()
%2 = srem i32 %1, 1000000
ret i32 %2
}

LLVM IR (-O2):
define i32 @random_int() {
%1 = tail call i32 (...) @random()
%2 = srem i32 %1, 1000000
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ E(char *);
int /*<<< orphan*/ I(char *);
int /*<<< orphan*/ T(char *);
int /*<<< orphan*/ V(char *, int);
int /*<<< orphan*/ W(char *);
int main() {
  int i = 42;
  T("Make this!");
  V("Extra noisy information like: (%i)", i);
  I("Norma information!");
  W("A warning, but probably nothing critical.  Probably");
  E("SEGFAULT INCOMING");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2a,-0x8(%rbp)
lea    0xe93(%rip),%rdi
call   1030 <T@plt>
mov    -0x8(%rbp),%esi
lea    0xe8f(%rip),%rdi
call   1040 <V@plt>
lea    0xea6(%rip),%rdi
call   1060 <I@plt>
lea    0xead(%rip),%rdi
call   1070 <W@plt>
lea    0xed5(%rip),%rdi
call   1050 <E@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
call   1030 <T@plt>
lea    0xea7(%rip),%rdi
mov    $0x2a,%esi
call   1040 <V@plt>
lea    0xeb9(%rip),%rdi
call   1060 <I@plt>
lea    0xec0(%rip),%rdi
call   1070 <W@plt>
lea    0xee8(%rip),%rdi
call   1050 <E@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Make this!\00"
@.str.1 = [35 x i8] c"Extra noisy information like: (%i)\00"
@.str.2 = [19 x i8] c"Norma information!\00"
@.str.3 = [52 x i8] c"A warning, but probably nothing critical. Probably\00"
@.str.4 = [18 x i8] c"SEGFAULT INCOMING\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 42, i32* %2
%3 = call i32 @T(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = call i32 @V(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = call i32 @I(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @W(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @E(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Make this!\00"
@.str.1 = [35 x i8] c"Extra noisy information like: (%i)\00"
@.str.2 = [19 x i8] c"Norma information!\00"
@.str.3 = [52 x i8] c"A warning, but probably nothing critical. Probably\00"
@.str.4 = [18 x i8] c"SEGFAULT INCOMING\00"
define i32 @main() {
%1 = tail call i32 @T(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @V(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 42)
%3 = tail call i32 @I(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @W(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @E(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
int inp(int);
int /*<<< orphan*/ outp(int, int);
void floppy_reset_controller(void) {
  uint8_t val8;
  val8 = inp(0x03f2);
  outp(0x03f2, val8 & ~0x04);
  outp(0x03f2, val8 | 0x04);
  do {
    val8 = inp(0x3f4);
  } while ((val8 & 0xc0) != 0x80);
}


x86 assembly (clang, -O0):
<floppy_reset_controller>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x3f2,%edi
call   1040 <inp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
and    $0xfffffffb,%esi
mov    $0x3f2,%edi
call   1030 <outp@plt>
mov    -0x4(%rbp),%esi
or     $0x4,%esi
mov    $0x3f2,%edi
call   1030 <outp@plt>
mov    $0x3f4,%edi
call   1040 <inp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    1155 <floppy_reset_controller+0x35>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floppy_reset_controller>:
push   %rbx
mov    $0x3f2,%edi
call   1040 <inp@plt>
mov    %eax,%ebx
mov    %eax,%esi
and    $0xfffffffb,%esi
mov    $0x3f2,%edi
call   1030 <outp@plt>
or     $0x4,%ebx
mov    $0x3f2,%edi
mov    %ebx,%esi
call   1030 <outp@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x3f4,%edi
call   1040 <inp@plt>
and    $0xc0,%eax
cmp    $0x80,%eax
jne    1150 <floppy_reset_controller+0x30>
pop    %rbx
ret

LLVM IR (-O0):
define void @floppy_reset_controller() {
%1 = alloca i32
%2 = call i32 @inp(i32 1010)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = and i32 %3, -5
%5 = call i32 @outp(i32 1010, i32 %4)
%6 = load i32, i32* %1
%7 = or i32 %6, 4
%8 = call i32 @outp(i32 1010, i32 %7)
br label %9
9: ; preds = %11, %0
%10 = call i32 @inp(i32 1012)
store i32 %10, i32* %1
br label %11
11: ; preds = %9
%12 = load i32, i32* %1
%13 = and i32 %12, 192
%14 = icmp ne i32 %13, 128
br i1 %14, label %9, label %15
15: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @floppy_reset_controller() {
%1 = tail call i32 @inp(i32 1010)
%2 = and i32 %1, -5
%3 = tail call i32 @outp(i32 1010, i32 %2)
%4 = or i32 %1, 4
%5 = tail call i32 @outp(i32 1010, i32 %4)
br label %6
6: ; preds = %6, %0
%7 = tail call i32 @inp(i32 1012)
%8 = and i32 %7, 192
%9 = icmp eq i32 %8, 128
br i1 %9, label %10, label %6
10: ; preds = %6
ret void
}
int algorithm(int a, int b) {
  int result;
  result = a * b;
  result = result / 8;
  result = result + 1024;
  result = result / 16;
  return result;
}


x86 assembly (clang, -O0):
<algorithm>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x400,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<algorithm>:
imul   %esi,%edi
lea    0x7(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
sar    $0x3,%eax
lea    0x400(%rax),%ecx
add    $0x40f,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x4,%eax
ret

LLVM IR (-O0):
define i32 @algorithm(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = mul nsw i32 %6, %7
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = sdiv i32 %9, 8
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = add nsw i32 %11, 1024
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = sdiv i32 %13, 16
store i32 %14, i32* %5
%15 = load i32, i32* %5
ret i32 %15
}

LLVM IR (-O2):
define i32 @algorithm(i32 %0, i32 %1) {
%3 = mul nsw i32 %1, %0
%4 = sdiv i32 %3, 8
%5 = add nsw i32 %4, 1024
%6 = sdiv i32 %5, 16
ret i32 %6
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
void WatchdogIntTypeSet(uint32_t ui32Type) {

  ;
  (*((volatile unsigned long
          *)(((unsigned long)(0x40080000 + 0x00000008) & 0xF0000000) |
             0x02000000 |
             (((unsigned long)(0x40080000 + 0x00000008) & 0x000FFFFF) << 5) |
             ((2) << 2)))) = (ui32Type == 0x00000000) ? 0 : 1;
}


x86 assembly (clang, -O0):
<WatchdogIntTypeSet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
movslq %eax,%rcx
mov    $0x43000108,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<WatchdogIntTypeSet>:
xor    %eax,%eax
test   %edi,%edi
setne  %al
mov    %rax,0x43000108
43
ret

LLVM IR (-O0):
define void @WatchdogIntTypeSet(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i64
%6 = select i1 %4, i32 0, i32 1
%7 = sext i32 %6 to i64
store volatile i64 %7, i64* inttoptr (i64 1124073736 to i64*)
ret void
}

LLVM IR (-O2):
define void @WatchdogIntTypeSet(i32 %0) {
%2 = icmp ne i32 %0, 0
%3 = zext i1 %2 to i64
store volatile i64 %3, i64* inttoptr (i64 1124073736 to i64*)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ const uint32_t;

/* Variables and functions */
uint32_t getblock32(const uint32_t *p, int i) { return p[i]; }


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

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

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

LLVM IR (-O2):
define i32 @getblock32(i32* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
ret i32 %5
}
/* Variables and functions */
int VIDSoftVdp2Reset(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @VIDSoftVdp2Reset() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ spiInit();
void max6675Init(void) { spiInit(); }


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

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

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

LLVM IR (-O2):
define void @max6675Init() {
%1 = tail call i32 (...) @spiInit()
ret void
}
/* Type definitions */
struct sched_attr {
  int dummy;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int syscall(int, int /*<<< orphan*/, struct sched_attr const *, unsigned int);
int sched_setattr(pid_t pid, const struct sched_attr *attr,
                  unsigned int flags) {
  return syscall(314, pid, attr, flags);
}


x86 assembly (clang, -O0):
<sched_setattr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    $0x13a,%edi
call   1030 <syscall@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sched_setattr>:
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %edi,%esi
mov    $0x13a,%edi
jmp    1030 <syscall@plt>

LLVM IR (-O0):
%struct.sched_attr = type { i32 }
define i32 @sched_setattr(i32 %0, %struct.sched_attr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sched_attr*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.sched_attr* %1, %struct.sched_attr** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load %struct.sched_attr*, %struct.sched_attr** %5
%9 = load i32, i32* %6
%10 = call i32 @syscall(i32 314, i32 %7, %struct.sched_attr* %8, i32 %9)
ret i32 %10
}

LLVM IR (-O2):
%struct.sched_attr = type { i32 }
define i32 @sched_setattr(i32 %0, %struct.sched_attr* %1, i32 %2) {
%4 = tail call i32 @syscall(i32 314, i32 %0, %struct.sched_attr* %1, i32 %2)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void add_y() {
  int x = 10;
  int *px;
  px = &x;
  int y = *px;
  printf("y = %d\n", y);
}


x86 assembly (clang, -O0):
<add_y>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str = [8 x i8] c"y = %d\0A\00"
define void @add_y() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 10)
ret void
}
/* Variables and functions */
int printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int sum(int /*<<< orphan*/);
int main() {
  int n;
  return 0 * printf("%d", sum((scanf("%d", &n), n)));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <sum@plt>
mov    %eax,%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
imul   $0x0,%eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
call   1040 <sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%4 = load i32, i32* %2
%5 = call i32 @sum(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = mul nsw i32 0, %6
ret i32 %7
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @sum(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
ret i32 0
}