xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void lprintf(int array[], int size) {
  for (int i = 0; i < size; i++) {
    printf("%d\t", array[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<lprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1159 <lprintf+0x49>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <lprintf+0x16>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lprintf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1157 <lprintf+0x37>
mov    %rdi,%r15
mov    %esi,%r12d
lea    0xec7(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <lprintf+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @lprintf(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %17, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32*, i32** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %6
20: ; preds = %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @lprintf(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %8
6: ; preds = %8, %2
%7 = tail call i32 @putchar(i32 10)
ret void
8: ; preds = %4, %8
%9 = phi i64 [ 0, %4 ], [ %13, %8 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %6, label %8
}
void tm_fcs_a0_over(void *p) {}


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

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

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

LLVM IR (-O2):
define void @tm_fcs_a0_over(i8* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ execute_sendto();
int /*<<< orphan*/ server_recvfrom();
int execute_recvfrom() {
  server_recvfrom();
  execute_sendto();
  return 0;
}


x86 assembly (clang, -O0):
<execute_recvfrom>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <server_recvfrom@plt>
mov    $0x0,%al
call   1030 <execute_sendto@plt>
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @execute_recvfrom() {
%1 = call i32 (...) @server_recvfrom()
%2 = call i32 (...) @execute_sendto()
ret i32 0
}

LLVM IR (-O2):
define i32 @execute_recvfrom() {
%1 = tail call i32 (...) @server_recvfrom()
%2 = tail call i32 (...) @execute_sendto()
ret i32 0
}
int main() {
  union {
    void *p0;
    struct {
      char c[2];
      void *p1;
      void *p2;
    } str;
  } data;
  data.p0 = malloc(37U);
  data.str.p2 = &data;
  data.str.c[1] = sizeof data.str.p1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x25,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
movb   $0x8,-0x1f(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%union.anon = type { %struct.anon }
%struct.anon = type { [2 x i8], i8*, i8* }
define i32 @main() {
%1 = alloca i32
%2 = alloca %union.anon
store i32 0, i32* %1
%3 = call i8* @malloc(i64 37)
%4 = bitcast %union.anon* %2 to i8**
store i8* %3, i8** %4
%5 = bitcast %union.anon* %2 to i8*
%6 = bitcast %union.anon* %2 to %struct.anon*
%7 = getelementptr inbounds %struct.anon, %struct.anon* %6, i32 0, i32 2
store i8* %5, i8** %7
%8 = bitcast %union.anon* %2 to %struct.anon*
%9 = getelementptr inbounds %struct.anon, %struct.anon* %8, i32 0, i32 0
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 1
store i8 8, i8* %10
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
long factorial(int);
long binomial_coefficient(int a, int b) {
  return factorial(a) / (factorial(b) * factorial(a - b));
}


x86 assembly (clang, -O0):
<binomial_coefficient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <factorial@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
sub    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
imul   %rdx,%rcx
cqto
idiv   %rcx
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binomial_coefficient>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <factorial@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1030 <factorial@plt>
mov    %rax,%r15
sub    %ebp,%ebx
mov    %ebx,%edi
call   1030 <factorial@plt>
mov    %rax,%rcx
imul   %r15,%rcx
mov    %r14,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1153 <binomial_coefficient+0x43>
mov    %r14,%rax
cqto
idiv   %rcx
jmp    115a <binomial_coefficient+0x4a>
mov    %r14d,%eax
xor    %edx,%edx
div    %ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i64 @binomial_coefficient(i32 %0, i32 %1) {
%3 = tail call i64 @factorial(i32 %0)
%4 = tail call i64 @factorial(i32 %1)
%5 = sub nsw i32 %0, %1
%6 = tail call i64 @factorial(i32 %5)
%7 = mul nsw i64 %6, %4
%8 = sdiv i64 %3, %7
ret i64 %8
}
/* Variables and functions */
int /*<<< orphan*/ emitln(char *);
int /*<<< orphan*/ match(char);
int /*<<< orphan*/ term();
void add(void) {
  match('+');
  term();
  emitln("ADD (SP)+,D0");
}


x86 assembly (clang, -O0):
<add>:
push   %rbp
mov    %rsp,%rbp
mov    $0x2b,%edi
call   1050 <match@plt>
mov    $0x0,%al
call   1040 <term@plt>
lea    0xeb4(%rip),%rdi
call   1030 <emitln@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<add>:
push   %rax
mov    $0x2b,%edi
call   1050 <match@plt>
xor    %eax,%eax
call   1040 <term@plt>
lea    0xeb7(%rip),%rdi
pop    %rax
jmp    1030 <emitln@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"ADD (SP)+,D0\00"
define void @add() {
%1 = call i32 @match(i8 signext 43)
%2 = call i32 (...) @term()
%3 = call i32 @emitln(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"ADD (SP)+,D0\00"
define void @add() {
%1 = tail call i32 @match(i8 signext 43)
%2 = tail call i32 (...) @term()
%3 = tail call i32 @emitln(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret void
}
void xmem_init(void) {}


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

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

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

LLVM IR (-O2):
define void @xmem_init() {
ret void
}
double alpha_c(double p0, double T, double qt, double qv) {
  return (287.1 * T) / p0 * (1.0 - qt + 1.6074538488331591 * qv);
}


x86 assembly (clang, -O0):
<alpha_c>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xef0(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  0xed6(%rip),%xmm2
subsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movsd  0xebc(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<alpha_c>:
mulsd  0xef8(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xef4(%rip),%xmm0
subsd  %xmm2,%xmm0
mulsd  0xef0(%rip),%xmm3
addsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @alpha_c(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %6
%10 = fmul double 2.871000e+02, %9
%11 = load double, double* %5
%12 = fdiv double %10, %11
%13 = load double, double* %7
%14 = fsub double 1.000000e+00, %13
%15 = load double, double* %8
%16 = call double @llvm.fmuladd.f64(double 0x3FF9B82186E9157D, double %15, double %14)
%17 = fmul double %12, %16
ret double %17
}

LLVM IR (-O2):
define double @alpha_c(double %0, double %1, double %2, double %3) {
%5 = fmul double %1, 2.871000e+02
%6 = fdiv double %5, %0
%7 = fsub double 1.000000e+00, %2
%8 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FF9B82186E9157D, double %7)
%9 = fmul double %6, %8
ret double %9
}
int get_tbh_size(unsigned char buf[]) {
  return (((int)buf[0]) << 8) + ((int)buf[1]);
}


x86 assembly (clang, -O0):
<get_tbh_size>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tbh_size>:
movzwl (%rdi),%eax
shl    $0x10,%eax
bswap  %eax
ret

LLVM IR (-O0):
define i32 @get_tbh_size(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = shl i32 %6, 8
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = add nsw i32 %7, %11
ret i32 %12
}

LLVM IR (-O2):
define i32 @get_tbh_size(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = shl nuw nsw i32 %3, 8
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = or i32 %4, %7
ret i32 %8
}
int d_ge_rm1(double a1, double *a2) { return (((a1) >= (*a2))); }


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

x86 assembly (clang, -O2):
<d_ge_rm1>:
xor    %eax,%eax
ucomisd (%rdi),%xmm0
setae  %al
ret

LLVM IR (-O0):
define i32 @d_ge_rm1(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
store double %0, double* %3
store double* %1, double** %4
%5 = load double, double* %3
%6 = load double*, double** %4
%7 = load double, double* %6
%8 = fcmp oge double %5, %7
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
define i32 @d_ge_rm1(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = fcmp ole double %3, %0
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Type definitions */
typedef unsigned long long const uint32_t;

/* Variables and functions */
unsigned long long const UINT32_MAX;
uint32_t truncate_int(const unsigned long long value) {
  if (value < 0) {
    return 0;
  } else if (value > UINT32_MAX) {
    return UINT32_MAX;
  } else
    return (uint32_t)value;
}


x86 assembly (clang, -O0):
<truncate_int>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jae    1120 <truncate_int+0x20>
movq   $0x0,-0x8(%rbp)
jmp    114f <truncate_int+0x4f>
mov    -0x10(%rbp),%rax
mov    0x2ecd(%rip),%rcx
cmp    (%rcx),%rax
jbe    1147 <truncate_int+0x47>
mov    0x2ebd(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    114f <truncate_int+0x4f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

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

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

LLVM IR (-O2):
@UINT32_MAX = constant i64 0
define i64 @truncate_int(i64 %0) {
ret i64 0
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void error(const char *s) {
  fputs("JSMIN Error: ", stderr);
  fputs(s, stderr);
  fputc('\n', stderr);
  exit(1);
}


x86 assembly (clang, -O0):
<error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
lea    0xeb4(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<error>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea2(%rip),%r14
mov    (%r14),%esi
lea    0xeb8(%rip),%rdi
call   1030 <fputs@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <fputs@plt>
mov    (%r14),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"JSMIN Error: \00"
@stderr = global i32 0
define void @error(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i8*, i8** %2
%6 = load i32, i32* @stderr
%7 = call i32 @fputs(i8* %5, i32 %6)
%8 = load i32, i32* @stderr
%9 = call i32 @fputc(i8 signext 10, i32 %8)
%10 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [14 x i8] c"JSMIN Error: \00"
@stderr = global i32 0
define void @error(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = load i32, i32* @stderr
%5 = tail call i32 @fputs(i8* %0, i32 %4)
%6 = load i32, i32* @stderr
%7 = tail call i32 @fputc(i8 signext 10, i32 %6)
%8 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
size_t strlen(char const *);
size_t my_strlen(const char *s) {
  if (s == NULL)
    return -1;
  return strlen(s);
}


x86 assembly (clang, -O0):
<my_strlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <my_strlen+0x24>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1141 <my_strlen+0x31>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strlen>:
test   %rdi,%rdi
je     111a <my_strlen+0xa>
jmp    1030 <strlen@plt>
mov    $0xffffffffffffffff,%rax
ret

LLVM IR (-O0):
define i64 @my_strlen(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i64 -1, i64* %2
br label %10
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %2
br label %10
10: ; preds = %7, %6
%11 = load i64, i64* %2
ret i64 %11
}

LLVM IR (-O2):
define i64 @my_strlen(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
br label %5
5: ; preds = %1, %3
%6 = phi i64 [ %4, %3 ], [ -1, %1 ]
ret i64 %6
}
char *copy_bytes_3(char *dst, char *src) {
  dst[0] = src[2];
  dst[1] = src[1];
  dst[2] = src[0];
  return dst + 3;
}


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

x86 assembly (clang, -O2):
<copy_bytes_3>:
mov    0x2(%rsi),%al
mov    %al,(%rdi)
mov    0x1(%rsi),%al
mov    %al,0x1(%rdi)
mov    (%rsi),%al
mov    %al,0x2(%rdi)
lea    0x3(%rdi),%rax
ret

LLVM IR (-O0):
define i8* @copy_bytes_3(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8, i8* %5, i64 2
%7 = load i8, i8* %6
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 %7, i8* %9
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %12, i8* %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 2
store i8 %17, i8* %19
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 3
ret i8* %21
}

LLVM IR (-O2):
define i8* @copy_bytes_3(i8* writeonly %0, i8* nocapture %1) {
%3 = getelementptr inbounds i8, i8* %1, i64 2
%4 = load i8, i8* %3
store i8 %4, i8* %0
%5 = getelementptr inbounds i8, i8* %1, i64 1
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %6, i8* %7
%8 = load i8, i8* %1
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %8, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 3
ret i8* %10
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void sassert(int value, const char *message) {
  if (!value) {
    fprintf(stderr, "Assertion Failed: %s\n", message);
    fflush(stderr);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<sassert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117a <sassert+0x4a>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea3(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sassert>:
test   %edi,%edi
je     1135 <sassert+0x5>
ret
push   %rbx
mov    %rsi,%rdx
mov    0x2ea0(%rip),%rbx
mov    (%rbx),%edi
lea    0xeb7(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Assertion Failed: %s\0A\00"
define void @sassert(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %4
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @stderr
%12 = call i32 @fflush(i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Assertion Failed: %s\0A\00"
define void @sassert(i32 %0, i8* %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = load i32, i32* @stderr
%8 = tail call i32 @fflush(i32 %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
ret void
}
/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ runMenu();
int main() {
  runMenu();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <runMenu@plt>
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <runMenu@plt>
mov    0x2ec1(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @runMenu()
%3 = load i32, i32* @EXIT_SUCCESS
ret i32 %3
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @runMenu()
%2 = load i32, i32* @EXIT_SUCCESS
ret i32 %2
}
void RasterEndOfInterrupt(unsigned int baseAddr, unsigned int flag) {
  (*((volatile unsigned int *)(baseAddr + (0x68)))) = flag;
}


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

x86 assembly (clang, -O2):
<RasterEndOfInterrupt>:
add    $0x68,%edi
mov    %esi,(%rdi)
ret

LLVM IR (-O0):
define void @RasterEndOfInterrupt(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load i32, i32* %3
%7 = add i32 %6, 104
%8 = zext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
store volatile i32 %5, i32* %9
ret void
}

LLVM IR (-O2):
define void @RasterEndOfInterrupt(i32 %0, i32 %1) {
%3 = add i32 %0, 104
%4 = zext i32 %3 to i64
%5 = inttoptr i64 %4 to i32*
store volatile i32 %1, i32* %5
ret void
}
const char *welcome_message() { return "center of gravity"; }


x86 assembly (clang, -O0):
<welcome_message>:
push   %rbp
mov    %rsp,%rbp
lea    0xef5(%rip),%rax
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [18 x i8] c"center of gravity\00"
define i8* @welcome_message() {
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [18 x i8] c"center of gravity\00"
define i8* @welcome_message() {
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0)
}
/* Type definitions */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
double vis5d_time_usec(double usec_beg) {
  struct timeval tv;
  double usec;
  gettimeofday(&tv, 0);
  usec = ((double)tv.tv_sec * 1000000.0) + (double)tv.tv_usec;
  return (usec - usec_beg);
}


x86 assembly (clang, -O0):
<vis5d_time_usec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cvtsi2sdq -0x10(%rbp),%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
movsd  0xec4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vis5d_time_usec>:
sub    $0x18,%rsp
movsd  %xmm0,(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x10(%rsp),%xmm0
cvtsi2sdq 0x8(%rsp),%xmm1
mulsd  0xec2(%rip),%xmm0
addsd  %xmm1,%xmm0
subsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define double @vis5d_time_usec(double %0) {
%2 = alloca double
%3 = alloca %struct.timeval
%4 = alloca double
store double %0, double* %2
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%7 = load i64, i64* %6
%8 = sitofp i64 %7 to double
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%10 = load i64, i64* %9
%11 = sitofp i64 %10 to double
%12 = call double @llvm.fmuladd.f64(double %8, double 1.000000e+06, double %11)
store double %12, double* %4
%13 = load double, double* %4
%14 = load double, double* %2
%15 = fsub double %13, %14
ret double %15
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define double @vis5d_time_usec(double %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%6 = load i64, i64* %5
%7 = sitofp i64 %6 to double
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%9 = load i64, i64* %8
%10 = sitofp i64 %9 to double
%11 = call double @llvm.fmuladd.f64(double %7, double 1.000000e+06, double %10)
%12 = fsub double %11, %0
ret double %12
}
/* Variables and functions */
bool negue(bool valor) { return true; }


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

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

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

LLVM IR (-O2):
define i32 @negue(i32 %0) {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ agent_end(double);
void RL_agent_end(double reward) { agent_end(reward); }


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

x86 assembly (clang, -O2):
<RL_agent_end>:
jmp    1030 <agent_end@plt>

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

LLVM IR (-O2):
define void @RL_agent_end(double %0) {
%2 = tail call i32 @agent_end(double %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ arc4random_buf(unsigned char *, int);
int RAND_bytes(unsigned char *buf, int num) {
  if (num > 0)
    arc4random_buf(buf, num);
  return 1;
}


x86 assembly (clang, -O0):
<RAND_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1135 <RAND_bytes+0x25>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <arc4random_buf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RAND_bytes>:
test   %esi,%esi
jle    111e <RAND_bytes+0xe>
push   %rax
call   1030 <arc4random_buf@plt>
add    $0x8,%rsp
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @RAND_bytes(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @arc4random_buf(i8* %8, i32 %9)
br label %11
11: ; preds = %7, %2
ret i32 1
}

LLVM IR (-O2):
define i32 @RAND_bytes(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @arc4random_buf(i8* %0, i32 %1)
br label %6
6: ; preds = %4, %2
ret i32 1
}
void gtk_tree_model_filter_set_visible_func() {}


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

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

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

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

/* Variables and functions */
int __setxid(int, int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int setregid(gid_t rgid, gid_t egid) { return __setxid(204, rgid, egid, 0); }


x86 assembly (clang, -O0):
<setregid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0xcc,%edi
xor    %ecx,%ecx
call   1030 <__setxid@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setregid>:
mov    %esi,%edx
mov    %edi,%esi
mov    $0xcc,%edi
xor    %ecx,%ecx
jmp    1030 <__setxid@plt>

LLVM IR (-O0):
define i32 @setregid(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 @__setxid(i32 204, i32 %5, i32 %6, i32 0)
ret i32 %7
}

LLVM IR (-O2):
define i32 @setregid(i32 %0, i32 %1) {
%3 = tail call i32 @__setxid(i32 204, i32 %0, i32 %1, i32 0)
ret i32 %3
}
/* Type definitions */
typedef scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int wait_for(pid_t pid) {
  int status;
  if (waitpid(pid, &status, 0) != pid)
    return -1;
  return status;
}


x86 assembly (clang, -O0):
<wait_for>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
xor    %edx,%edx
call   1030 <waitpid@plt>
cmp    -0x10(%rbp),%rax
je     1141 <wait_for+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    1147 <wait_for+0x37>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_for>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <waitpid@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
cmp    %rbx,%rcx
jne    1135 <wait_for+0x25>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @wait_for(i64 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i64 @waitpid(i64 %0, i32* %2, i32 0)
%5 = icmp eq i64 %4, %0
%6 = load i32, i32* %2
%7 = select i1 %5, i32 %6, i32 -1
ret i32 %7
}
void rop3_12_1_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = ~T;
  stk1 = S & stk2;
  *D = (stk1 & (~S)) | (*D & S);
}


x86 assembly (clang, -O0):
<rop3_12_1_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 -0xa(%rbp),%eax
xor    $0xffffffff,%eax
mov    %al,-0xc(%rbp)
movzbl -0x9(%rbp),%eax
movzbl -0xc(%rbp),%ecx
and    %ecx,%eax
mov    %al,-0xb(%rbp)
movzbl -0xb(%rbp),%eax
movzbl -0x9(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl (%rcx),%ecx
movzbl -0x9(%rbp),%edx
and    %edx,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rop3_12_1_0>:
and    %sil,(%rdi)
ret

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

LLVM IR (-O2):
define void @rop3_12_1_0(i8* nocapture %0, i8 zeroext %1, i8 zeroext %2) {
%4 = load i8, i8* %0
%5 = and i8 %4, %1
store i8 %5, i8* %0
ret void
}
/* Variables and functions */
size_t word_len(char const *s, char c) {
  size_t i;
  i = 0;
  while (s[i] && s[i] != c)
    i++;
  return (i);
}


x86 assembly (clang, -O0):
<word_len>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1148 <word_len+0x48>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1158 <word_len+0x58>
jmp    1169 <word_len+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1116 <word_len+0x16>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<word_len>:
mov    $0xffffffffffffffff,%rax
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rdi,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
je     1122 <word_len+0x22>
cmp    %sil,%cl
jne    1110 <word_len+0x10>
ret

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

LLVM IR (-O2):
define i64 @word_len(i8* nocapture %0, i8 signext %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %10, %3 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = icmp eq i8 %6, %1
%9 = or i1 %7, %8
%10 = add i64 %4, 1
br i1 %9, label %11, label %3
11: ; preds = %3
ret i64 %4
}
int getch() { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @getch() {
ret i32 0
}
/* Variables and functions */
int strlen(const char *str) {
  const char *p;
  for (p = str; *p != '\0'; ++p) {
  };
  return p - str;
}


x86 assembly (clang, -O0):
<strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1136 <strlen+0x36>
jmp    1125 <strlen+0x25>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <strlen+0x10>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlen>:
mov    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmpb   $0x0,(%rdi)
lea    0x1(%rdi),%rdi
jne    1110 <strlen+0x10>
ret

LLVM IR (-O0):
define i32 @strlen(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 = %11, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %5
br label %11
11: ; preds = %10
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
br label %5
14: ; preds = %5
%15 = load i8*, i8** %3
%16 = load i8*, i8** %2
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
define i32 @strlen(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %5, label %7, label %2
7: ; preds = %2
%8 = ptrtoint i8* %3 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
ret i32 %11
}
long simple_rand() {
  static unsigned long seed = 47114711;
  unsigned long this = seed * 1103515245 + 12345;
  seed = this;
  return this >> 8;
}


x86 assembly (clang, -O0):
<simple_rand>:
push   %rbp
mov    %rsp,%rbp
imul   $0x41c64e6d,0x2f11(%rip),%rax
6d 4e c6 41
add    $0x3039,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,0x2efc(%rip)
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_rand>:
imul   $0x41c64e6d,0x2f15(%rip),%rax
6d 4e c6 41
add    $0x3039,%rax
mov    %rax,0x2f08(%rip)
shr    $0x8,%rax
ret

LLVM IR (-O0):
@simple_rand.seed = internal global i64 47114711
define i64 @simple_rand() {
%1 = alloca i64
%2 = load i64, i64* @simple_rand.seed
%3 = mul i64 %2, 1103515245
%4 = add i64 %3, 12345
store i64 %4, i64* %1
%5 = load i64, i64* %1
store i64 %5, i64* @simple_rand.seed
%6 = load i64, i64* %1
%7 = lshr i64 %6, 8
ret i64 %7
}

LLVM IR (-O2):
@simple_rand.seed = internal unnamed_addr global i64 47114711
define i64 @simple_rand() {
%1 = load i64, i64* @simple_rand.seed
%2 = mul i64 %1, 1103515245
%3 = add i64 %2, 12345
store i64 %3, i64* @simple_rand.seed
%4 = lshr i64 %3, 8
ret i64 %4
}
/* Variables and functions */
char *__ulltoa_internal__(long long, char *, int, int, int /*<<< orphan*/);
char *lltoa(long long value, char *str, int base) {
  return __ulltoa_internal__((value < 0) ? -value : value, str, base, value < 0,
                             0);
}


x86 assembly (clang, -O0):
<lltoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    113d <lltoa+0x2d>
xor    %eax,%eax
sub    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1145 <lltoa+0x35>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
cmpq   $0x0,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%ecx
xor    %r8d,%r8d
call   1030 <__ulltoa_internal__@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lltoa>:
mov    %rdi,%rcx
neg    %rdi
cmovs  %rcx,%rdi
shr    $0x3f,%rcx
xor    %r8d,%r8d
jmp    1030 <__ulltoa_internal__@plt>

LLVM IR (-O0):
define i8* @lltoa(i64 %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i64, i64* %4
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i64, i64* %4
%11 = sub nsw i64 0, %10
br label %14
12: ; preds = %3
%13 = load i64, i64* %4
br label %14
14: ; preds = %12, %9
%15 = phi i64 [ %11, %9 ], [ %13, %12 ]
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = load i64, i64* %4
%19 = icmp slt i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i8* @__ulltoa_internal__(i64 %15, i8* %16, i32 %17, i32 %20, i32 0)
ret i8* %21
}

LLVM IR (-O2):
define i8* @lltoa(i64 %0, i8* %1, i32 %2) {
%4 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
%5 = lshr i64 %0, 63
%6 = trunc i64 %5 to i32
%7 = tail call i8* @__ulltoa_internal__(i64 %4, i8* %1, i32 %2, i32 %6, i32 0)
ret i8* %7
}
/* Variables and functions */
int /*<<< orphan*/ ht_bold_off();
int /*<<< orphan*/ ht_bold_on();
void l_bold_toggle(void) {
  static int bold_on;
  if (bold_on) {
    ht_bold_off();
    bold_on = 0;
  } else {
    ht_bold_on();
    bold_on = 1;
  }
}


x86 assembly (clang, -O0):
<l_bold_toggle>:
push   %rbp
mov    %rsp,%rbp
cmpl   $0x0,0x2f09(%rip)
je     1147 <l_bold_toggle+0x27>
mov    $0x0,%al
call   1030 <ht_bold_off@plt>
movl   $0x0,0x2ef2(%rip)
jmp    1158 <l_bold_toggle+0x38>
mov    $0x0,%al
call   1040 <ht_bold_on@plt>
movl   $0x1,0x2edc(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_bold_toggle>:
push   %rbx
mov    0x2f0d(%rip),%bl
xor    %eax,%eax
cmp    $0x1,%bl
jne    1135 <l_bold_toggle+0x15>
call   1030 <ht_bold_off@plt>
jmp    113a <l_bold_toggle+0x1a>
call   1040 <ht_bold_on@plt>
xor    $0x1,%bl
mov    %bl,0x2ef1(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@l_bold_toggle.bold_on = internal global i32 0
define void @l_bold_toggle() {
%1 = load i32, i32* @l_bold_toggle.bold_on
%2 = icmp ne i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 (...) @ht_bold_off()
store i32 0, i32* @l_bold_toggle.bold_on
br label %7
5: ; preds = %0
%6 = call i32 (...) @ht_bold_on()
store i32 1, i32* @l_bold_toggle.bold_on
br label %7
7: ; preds = %5, %3
ret void
}

LLVM IR (-O2):
@l_bold_toggle.bold_on = internal unnamed_addr global i1 false
define void @l_bold_toggle() {
%1 = load i1, i1* @l_bold_toggle.bold_on
br i1 %1, label %2, label %4
2: ; preds = %0
%3 = tail call i32 (...) @ht_bold_off()
br label %6
4: ; preds = %0
%5 = tail call i32 (...) @ht_bold_on()
br label %6
6: ; preds = %4, %2
%7 = xor i1 %1, true
store i1 %7, i1* @l_bold_toggle.bold_on
ret void
}
/* Variables and functions */
int noraw();
int wrap_noraw(void) { return noraw(); }


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

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

LLVM IR (-O0):
define i32 @wrap_noraw() {
%1 = call i32 (...) @noraw()
ret i32 %1
}

LLVM IR (-O2):
define i32 @wrap_noraw() {
%1 = tail call i32 (...) @noraw()
ret i32 %1
}
/* Variables and functions */
int /*<<< orphan*/ _Error(long, char *);
void Error_NonHandlerTypeVariablesCannotBeCalled(long p_position) {
  _Error(p_position, "Variables must have handler type to be called");
}


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

x86 assembly (clang, -O2):
<Error_NonHandlerTypeVariablesCannotBeCalled>:
lea    0xee9(%rip),%rsi
jmp    1030 <_Error@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"Variables must have handler type to be called\00"
define void @Error_NonHandlerTypeVariablesCannotBeCalled(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = call i32 @_Error(i64 %3, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"Variables must have handler type to be called\00"
define void @Error_NonHandlerTypeVariablesCannotBeCalled(i64 %0) {
%2 = tail call i32 @_Error(i64 %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
ret void
}
void printks(char *s) {
  char c;
  char *null_string = "<NULL>";
  if (s == ((void *)0)) {
    s = null_string;
  }
  while ((c = *s++) != '\0') {
    putchar(c);
  }
}


x86 assembly (clang, -O0):
<printks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113a <printks+0x2a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    113f <printks+0x2f>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     116f <printks+0x5f>
movsbl -0x9(%rbp),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    113f <printks+0x2f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printks>:
push   %rbx
test   %rdi,%rdi
lea    0xee5(%rip),%rbx
cmovne %rdi,%rbx
mov    (%rbx),%al
test   %al,%al
je     1145 <printks+0x35>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <printks+0x20>
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"<NULL>\00"
define void @printks(i8* %0) {
%2 = icmp eq i8* %0, null
%3 = select i1 %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %12, %6 ], [ %4, %1 ]
%8 = phi i8* [ %10, %6 ], [ %3, %1 ]
%9 = sext i8 %7 to i32
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %9)
%12 = load i8, i8* %10
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %1
ret void
}
void WDT_IRQHandler(void) {
  while (1)
    ;
}


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

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

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

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