xunge/DecIR huggingface dataset:
/* Type definitions */
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
void fthread_mutex_unlock_(pthread_mutex_t **theMutex) {
  pthread_mutex_unlock(*theMutex);
}


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

x86 assembly (clang, -O2):
<fthread_mutex_unlock_>:
mov    (%rdi),%rdi
jmp    1030 <pthread_mutex_unlock@plt>

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

LLVM IR (-O2):
define void @fthread_mutex_unlock_(i32** nocapture %0) {
%2 = load i32*, i32** %0
%3 = tail call i32 @pthread_mutex_unlock(i32* %2)
ret void
}
/* Variables and functions */
char *strrchr(const char *s, int c) {
  char *match = NULL;
  do {
    if (*s == (char)c) {
      match = (char *)s;
    }
  } while (*s++);
  return match;
}


x86 assembly (clang, -O0):
<strrchr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    -0xc(%rbp),%ecx
movsbl %cl,%ecx
cmp    %ecx,%eax
jne    1130 <strrchr+0x30>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1135 <strrchr+0x35>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
cmpb   $0x0,(%rax)
jne    1113 <strrchr+0x13>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strrchr>:
movsbl %sil,%ecx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsbl (%rdi),%edx
cmp    %edx,%ecx
cmove  %rdi,%rax
add    $0x1,%rdi
test   %edx,%edx
jne    1110 <strrchr+0x10>
ret

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

LLVM IR (-O2):
define i8* @strrchr(i8* %0, i32 %1) {
%3 = shl i32 %1, 24
%4 = ashr exact i32 %3, 24
br label %5
5: ; preds = %5, %2
%6 = phi i8* [ %0, %2 ], [ %12, %5 ]
%7 = phi i8* [ null, %2 ], [ %11, %5 ]
%8 = load i8, i8* %6
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %4, %9
%11 = select i1 %10, i8* %6, i8* %7
%12 = getelementptr inbounds i8, i8* %6, i64 1
%13 = icmp eq i8 %8, 0
br i1 %13, label %14, label %5
14: ; preds = %5
ret i8* %11
}
/* Variables and functions */
int strcmp(char const *, char const *);
int sr_strcmp0(const char *s1, const char *s2) {
  if (s1)
    return s2 ? strcmp(s1, s2) : 1;
  else
    return s2 ? -1 : 0;
}


x86 assembly (clang, -O0):
<sr_strcmp0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <sr_strcmp0+0x53>
cmpq   $0x0,-0x18(%rbp)
je     114b <sr_strcmp0+0x3b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1158 <sr_strcmp0+0x48>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <sr_strcmp0+0x48>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1178 <sr_strcmp0+0x68>
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sr_strcmp0>:
test   %rdi,%rdi
je     111f <sr_strcmp0+0xf>
test   %rsi,%rsi
je     1125 <sr_strcmp0+0x15>
jmp    1030 <strcmp@plt>
neg    %rsi
sbb    %eax,%eax
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @sr_strcmp0(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 = icmp ne i8* %6, null
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = call i32 @strcmp(i8* %12, i8* %13)
br label %16
15: ; preds = %8
br label %16
16: ; preds = %15, %11
%17 = phi i32 [ %14, %11 ], [ 1, %15 ]
store i32 %17, i32* %3
br label %23
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 -1, i32 0
store i32 %22, i32* %3
br label %23
23: ; preds = %18, %16
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @sr_strcmp0(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp eq i8* %1, null
br i1 %5, label %11, label %6
6: ; preds = %4
%7 = tail call i32 @strcmp(i8* %0, i8* %1)
br label %11
8: ; preds = %2
%9 = icmp ne i8* %1, null
%10 = sext i1 %9 to i32
br label %11
11: ; preds = %6, %4, %8
%12 = phi i32 [ %10, %8 ], [ %7, %6 ], [ 1, %4 ]
ret i32 %12
}
/* Type definitions */
typedef int int32_t;
typedef int int16_t;

/* Variables and functions */
int16_t s2n_kyber_512_r3_montgomery_reduce(int32_t a) {
  int32_t t;
  int16_t u;
  u = a * 62209;
  t = (int32_t)u * 3329;
  t = a - t;
  t >>= 16;
  return t;
}


x86 assembly (clang, -O0):
<s2n_kyber_512_r3_montgomery_reduce>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
imul   $0xf301,-0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
imul   $0xd01,-0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<s2n_kyber_512_r3_montgomery_reduce>:
imul   $0xf3a80000,%edi,%eax
sar    $0x10,%eax
ret

LLVM IR (-O0):
define i32 @s2n_kyber_512_r3_montgomery_reduce(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = mul nsw i32 %5, 62209
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = mul nsw i32 %7, 3329
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = sub nsw i32 %9, %10
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = ashr i32 %12, 16
store i32 %13, i32* %3
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
define i32 @s2n_kyber_512_r3_montgomery_reduce(i32 %0) {
%2 = mul i32 %0, -207093760
%3 = ashr exact i32 %2, 16
ret i32 %3
}
void console_set_error_color() {}


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

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

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

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

/* Variables and functions */
int /*<<< orphan*/ OUT_RING(struct pscnv_ib_chan *, int);
void BEGIN_RING_CONST(struct pscnv_ib_chan *ch, int subc, int mthd, int len) {
  OUT_RING(ch, mthd | subc << 13 | len << 18 | (0x4 << 28));
}


x86 assembly (clang, -O0):
<BEGIN_RING_CONST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%eax
shl    $0xd,%eax
or     %eax,%esi
mov    -0x14(%rbp),%eax
shl    $0x12,%eax
or     %eax,%esi
or     $0x40000000,%esi
call   1030 <OUT_RING@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BEGIN_RING_CONST>:
shl    $0xd,%esi
shl    $0x12,%ecx
or     %edx,%esi
or     %ecx,%esi
or     $0x40000000,%esi
jmp    1030 <OUT_RING@plt>

LLVM IR (-O0):
%struct.pscnv_ib_chan = type { i32 }
define void @BEGIN_RING_CONST(%struct.pscnv_ib_chan* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.pscnv_ib_chan*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.pscnv_ib_chan* %0, %struct.pscnv_ib_chan** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load %struct.pscnv_ib_chan*, %struct.pscnv_ib_chan** %5
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = shl i32 %11, 13
%13 = or i32 %10, %12
%14 = load i32, i32* %8
%15 = shl i32 %14, 18
%16 = or i32 %13, %15
%17 = or i32 %16, 1073741824
%18 = call i32 @OUT_RING(%struct.pscnv_ib_chan* %9, i32 %17)
ret void
}

LLVM IR (-O2):
%struct.pscnv_ib_chan = type { i32 }
define void @BEGIN_RING_CONST(%struct.pscnv_ib_chan* %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %1, 13
%6 = shl i32 %3, 18
%7 = or i32 %5, %2
%8 = or i32 %7, %6
%9 = or i32 %8, 1073741824
%10 = tail call i32 @OUT_RING(%struct.pscnv_ib_chan* %0, i32 %9)
ret void
}
void recorrer(int arr[], int tam, int pos) {
  int i = tam;
  for (i; i >= pos; i--) {
    if (i - 1 != -1) {
      arr[i] = arr[i - 1];
    }
  }
}


x86 assembly (clang, -O0):
<recorrer>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     115d <recorrer+0x5d>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cmp    $0xffffffff,%eax
je     114a <recorrer+0x4a>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    114f <recorrer+0x4f>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1114 <recorrer+0x14>
pop    %rbp
ret

x86 assembly (clang, -O2):
<recorrer>:
cmp    %edx,%esi
jge    1105 <recorrer+0x5>
ret
movslq %esi,%rcx
movslq %edx,%rax
jmp    1123 <recorrer+0x23>
nopl   (%rax)
lea    -0x1(%rcx),%rdx
mov    -0x4(%rdi,%rcx,4),%esi
mov    %esi,(%rdi,%rcx,4)
cmp    %rax,%rcx
mov    %rdx,%rcx
jle    1104 <recorrer+0x4>
test   %rcx,%rcx
jne    1110 <recorrer+0x10>
mov    $0xffffffffffffffff,%rdx
jmp    111b <recorrer+0x1b>

LLVM IR (-O0):
define void @recorrer(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
store i32 %8, i32* %7
%9 = load i32, i32* %7
br label %10
10: ; preds = %30, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp sge i32 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %7
%16 = sub nsw i32 %15, 1
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %19, i64 %22
%24 = load i32, i32* %23
%25 = load i32*, i32** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %24, i32* %28
br label %29
29: ; preds = %18, %14
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, -1
store i32 %32, i32* %7
br label %10
33: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @recorrer(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, %2
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = sext i32 %1 to i64
%7 = sext i32 %2 to i64
br label %8
8: ; preds = %5, %16
%9 = phi i64 [ %6, %5 ], [ %17, %16 ]
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = add nsw i64 %9, -1
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 %14, i32* %15
br label %16
16: ; preds = %8, %11
%17 = phi i64 [ %12, %11 ], [ -1, %8 ]
%18 = icmp sgt i64 %9, %7
br i1 %18, label %8, label %19
19: ; preds = %16, %3
ret void
}
/* Variables and functions */
void *stdc_5B162B7F(void *, void const *, size_t);
void *memmove(void *str1, const void *str2, size_t n) {
  return stdc_5B162B7F(str1, str2, n);
}


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

x86 assembly (clang, -O2):
<memmove>:
jmp    1030 <stdc_5B162B7F@plt>

LLVM IR (-O0):
define i8* @memmove(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i64, i64* %6
%10 = call i8* @stdc_5B162B7F(i8* %7, i8* %8, i64 %9)
ret i8* %10
}

LLVM IR (-O2):
define i8* @memmove(i8* %0, i8* %1, i64 %2) {
%4 = tail call i8* @stdc_5B162B7F(i8* %0, i8* %1, i64 %2)
ret i8* %4
}
/* Variables and functions */
int /*<<< orphan*/ pass1();
int /*<<< orphan*/ pass2();
int assemble() {
  pass1();
  pass2();
}


x86 assembly (clang, -O0):
<assemble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <pass1@plt>
mov    $0x0,%al
call   1030 <pass2@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assemble>:
push   %rax
xor    %eax,%eax
call   1040 <pass1@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <pass2@plt>

LLVM IR (-O0):
define i32 @assemble() {
%1 = alloca i32
%2 = call i32 (...) @pass1()
%3 = call i32 (...) @pass2()
%4 = load i32, i32* %1
ret i32 %4
}

LLVM IR (-O2):
define i32 @assemble() {
%1 = tail call i32 (...) @pass1()
%2 = tail call i32 (...) @pass2()
ret i32 undef
}
void move2i_(x, y) int *x, *y;
{ move((float)*x, (float)*y, 0.0); }


x86 assembly (clang, -O0):
<move2i_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2ssl (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
cvtsi2ssl (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
mov    $0x3,%al
call   1030 <move@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move2i_>:
cvtsi2ssl (%rdi),%xmm0
cvtsi2ssl (%rsi),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
mov    $0x3,%al
jmp    1030 <move@plt>

LLVM IR (-O0):
define void @move2i_(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* %5
%7 = sitofp i32 %6 to float
%8 = fpext float %7 to double
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = sitofp i32 %10 to float
%12 = fpext float %11 to double
%13 = call i32 (double, double, double, ...) bitcast (i32 (...)* @move to i32 (double, double, double, ...)*)(double %8, double %12, double 0.000000e+00)
ret void
}

LLVM IR (-O2):
define void @move2i_(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %0
%4 = sitofp i32 %3 to float
%5 = fpext float %4 to double
%6 = load i32, i32* %1
%7 = sitofp i32 %6 to float
%8 = fpext float %7 to double
%9 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @move to i32 (double, double, double, ...)*)(double %5, double %8, double 0.000000e+00)
ret void
}
int main() {
  int x = 1 / 0;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int getRandomNum(int, int);
int rollDice(void) {
  int die1, die2, worksum;
  die1 = getRandomNum(1, 6);
  die2 = getRandomNum(1, 6);
  worksum = die1 + die2;
  return worksum;
}


x86 assembly (clang, -O0):
<rollDice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0x6,%esi
call   1030 <getRandomNum@plt>
mov    %eax,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x6,%esi
call   1030 <getRandomNum@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rollDice>:
push   %rbx
mov    $0x1,%edi
mov    $0x6,%esi
call   1030 <getRandomNum@plt>
mov    %eax,%ebx
mov    $0x1,%edi
mov    $0x6,%esi
call   1030 <getRandomNum@plt>
add    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @rollDice() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @getRandomNum(i32 1, i32 6)
store i32 %4, i32* %1
%5 = call i32 @getRandomNum(i32 1, i32 6)
store i32 %5, i32* %2
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add nsw i32 %6, %7
store i32 %8, i32* %3
%9 = load i32, i32* %3
ret i32 %9
}

LLVM IR (-O2):
define i32 @rollDice() {
%1 = tail call i32 @getRandomNum(i32 1, i32 6)
%2 = tail call i32 @getRandomNum(i32 1, i32 6)
%3 = add nsw i32 %2, %1
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void sigint() {
  endwin();
  exit(0);
}


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

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

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

LLVM IR (-O2):
define void @sigint() {
%1 = tail call i32 (...) @endwin()
%2 = tail call i32 @exit(i32 0)
unreachable
}
/* Variables and functions */
double atan2(double, double);
double degree(double radian) {
  double pi = 4.0 * atan2(1.0, 1.0);
  return (radian / pi) * 180.0;
}


x86 assembly (clang, -O0):
<degree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeeb(%rip),%xmm1
movaps %xmm1,%xmm0
call   1030 <atan2@plt>
movaps %xmm0,%xmm1
movsd  0xed0(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
mulsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<degree>:
push   %rax
movsd  %xmm0,(%rsp)
movsd  0xee2(%rip),%xmm0
movaps %xmm0,%xmm1
call   1030 <atan2@plt>
movsd  (%rsp),%xmm0
divsd  0xed5(%rip),%xmm0
mulsd  0xed5(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @degree(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = call double @atan2(double 1.000000e+00, double 1.000000e+00)
%5 = fmul double 4.000000e+00, %4
store double %5, double* %3
%6 = load double, double* %2
%7 = load double, double* %3
%8 = fdiv double %6, %7
%9 = fmul double %8, 1.800000e+02
ret double %9
}

LLVM IR (-O2):
define double @degree(double %0) {
%2 = tail call double @atan2(double 1.000000e+00, double 1.000000e+00)
%3 = fdiv double %0, 0x400921FB54442D18
%4 = fmul double %3, 1.800000e+02
ret double %4
}
/* Variables and functions */
int /*<<< orphan*/ putchar(char);
double putchard(double X) {
  putchar((char)X);
  return 0;
}


x86 assembly (clang, -O0):
<putchard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
xorps  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putchard>:
push   %rax
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
xorpd  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @putchard(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fptosi double %3 to i8
%5 = call i32 @putchar(i8 signext %4)
ret double 0.000000e+00
}

LLVM IR (-O2):
define double @putchard(double %0) {
%2 = fptosi double %0 to i8
%3 = tail call i32 @putchar(i8 signext %2)
ret double 0.000000e+00
}
/* Type definitions */
typedef int /*<<< orphan*/ __u_char;

/* Variables and functions */
int /*<<< orphan*/ _IO(int, int);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
void cbmarch_pp_write(int f, __u_char c) { ioctl(f, _IO(0xcb, 11), c); }


x86 assembly (clang, -O0):
<cbmarch_pp_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0xcb,%edi
mov    $0xb,%esi
call   1030 <_IO@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <ioctl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbmarch_pp_write>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0xcb,%edi
mov    $0xb,%esi
call   1030 <_IO@plt>
mov    %ebp,%edi
mov    %eax,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ioctl@plt>

LLVM IR (-O0):
define void @cbmarch_pp_write(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 i32 @_IO(i32 203, i32 11)
%7 = load i32, i32* %4
%8 = call i32 @ioctl(i32 %5, i32 %6, i32 %7)
ret void
}

LLVM IR (-O2):
define void @cbmarch_pp_write(i32 %0, i32 %1) {
%3 = tail call i32 @_IO(i32 203, i32 11)
%4 = tail call i32 @ioctl(i32 %0, i32 %3, i32 %1)
ret void
}
int test_04(int a, int b, int c, int d) { return a + b + c + 1; }


x86 assembly (clang, -O0):
<test_04>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_04>:
add    %esi,%edi
lea    (%rdx,%rdi,1),%eax
add    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @test_04(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add i32 %0, 1
%6 = add i32 %5, %1
%7 = add i32 %6, %2
ret i32 %7
}
/* Variables and functions */
long abstract_text___Byte_byte_to_s_len___impl(unsigned char);
long core__abstract_text___Byte___byte_to_s_len(unsigned char self) {
  long var;
  long var1;
  var1 = abstract_text___Byte_byte_to_s_len___impl(self);
  var = var1;
  goto RET_LABEL;
RET_LABEL:;
  return var;
}


x86 assembly (clang, -O0):
<core__abstract_text___Byte___byte_to_s_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edi
call   1030 <abstract_text___Byte_byte_to_s_len___impl@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<core__abstract_text___Byte___byte_to_s_len>:
jmp    1030 <abstract_text___Byte_byte_to_s_len___impl@plt>

LLVM IR (-O0):
define i64 @core__abstract_text___Byte___byte_to_s_len(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i64
%4 = alloca i64
store i8 %0, i8* %2
%5 = load i8, i8* %2
%6 = call i64 @abstract_text___Byte_byte_to_s_len___impl(i8 zeroext %5)
store i64 %6, i64* %4
%7 = load i64, i64* %4
store i64 %7, i64* %3
br label %8
8: ; preds = %1
%9 = load i64, i64* %3
ret i64 %9
}

LLVM IR (-O2):
define i64 @core__abstract_text___Byte___byte_to_s_len(i8 zeroext %0) {
%2 = tail call i64 @abstract_text___Byte_byte_to_s_len___impl(i8 zeroext %0)
ret i64 %2
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void default_error(const char *msg) { fprintf(stderr, "%s\n", msg); }


x86 assembly (clang, -O0):
<default_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xed0(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<default_error>:
mov    %rdi,%rdx
mov    0x2ec6(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @default_error(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
void test_stats_on(int temp) {}


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

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

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

LLVM IR (-O2):
define void @test_stats_on(i32 %0) {
ret void
}
int happy(int a) {
  int i, ret = 0, t;
  for (i = a; i > 0; i /= 10) {
    t = i % 10;
    ret += t * t;
  }
  return ret;
}


x86 assembly (clang, -O0):
<happy>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    114c <happy+0x4c>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1114 <happy+0x14>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @happy(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %11
3: ; preds = %1, %3
%4 = phi i32 [ %9, %3 ], [ %0, %1 ]
%5 = phi i32 [ %8, %3 ], [ 0, %1 ]
%6 = urem i32 %4, 10
%7 = mul nuw nsw i32 %6, %6
%8 = add nuw nsw i32 %7, %5
%9 = udiv i32 %4, 10
%10 = icmp ult i32 %4, 10
br i1 %10, label %11, label %3
11: ; preds = %3, %1
%12 = phi i32 [ 0, %1 ], [ %8, %3 ]
ret i32 %12
}
int omp_get_num_threads(void) { return 1; }


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

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

LLVM IR (-O0):
define i32 @omp_get_num_threads() {
ret i32 1
}

LLVM IR (-O2):
define i32 @omp_get_num_threads() {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ alarm(int);
int main() {
  alarm(60);
  for (;;)
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3c,%edi
call   1030 <alarm@plt>
jmp    1129 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3c,%edi
call   1030 <alarm@plt>
nopl   0x0(%rax,%rax,1)
jmp    1120 <main+0x10>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @alarm(i32 60)
br label %3
3: ; preds = %3, %0
br label %3
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @alarm(i32 60)
br label %2
2: ; preds = %2, %0
br label %2
}
/* Variables and functions */
int /*<<< orphan*/ swapArgs(int *, int *);
int main() {
  int m = 13, n = 44;
  swapArgs(&m, &n);
  return m;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xd,-0x8(%rbp)
movl   $0x2c,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <swapArgs@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0xd,(%rsp)
movl   $0x2c,0x4(%rsp)
mov    %rsp,%rdi
lea    0x4(%rsp),%rsi
call   1030 <swapArgs@plt>
mov    (%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 13, i32* %2
store i32 44, i32* %3
%4 = call i32 @swapArgs(i32* %2, i32* %3)
%5 = load i32, i32* %2
ret i32 %5
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 13, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 44, i32* %2
%5 = call i32 @swapArgs(i32* %1, i32* %2)
%6 = load i32, i32* %1
ret i32 %6
}
int(cstrreplace)(char *s, char old, char new) {
  char *p = s;
  int numReplaced = 0;
  while (*p != '\0') {
    if (*p == old) {
      *p = new;
      numReplaced++;
    }
    p++;
  }
  return numReplaced;
}


x86 assembly (clang, -O0):
<cstrreplace>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1168 <cstrreplace+0x68>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    1157 <cstrreplace+0x57>
mov    -0xa(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1122 <cstrreplace+0x22>
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cstrreplace>:
mov    (%rdi),%cl
test   %cl,%cl
je     1129 <cstrreplace+0x29>
add    $0x1,%rdi
xor    %eax,%eax
jmp    111b <cstrreplace+0x1b>
xchg   %ax,%ax
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
je     1128 <cstrreplace+0x28>
cmp    %sil,%cl
jne    1110 <cstrreplace+0x10>
mov    %dl,-0x1(%rdi)
add    $0x1,%eax
jmp    1110 <cstrreplace+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @cstrreplace(i8* nocapture %0, i8 signext %1, i8 signext %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %3, %13
%7 = phi i8 [ %16, %13 ], [ %4, %3 ]
%8 = phi i32 [ %14, %13 ], [ 0, %3 ]
%9 = phi i8* [ %15, %13 ], [ %0, %3 ]
%10 = icmp eq i8 %7, %1
br i1 %10, label %11, label %13
11: ; preds = %6
store i8 %2, i8* %9
%12 = add nsw i32 %8, 1
br label %13
13: ; preds = %11, %6
%14 = phi i32 [ %12, %11 ], [ %8, %6 ]
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %13, %3
%19 = phi i32 [ 0, %3 ], [ %14, %13 ]
ret i32 %19
}
/* Variables and functions */
int /*<<< orphan*/ cmos_read_rtc();
void update_time(void) { cmos_read_rtc(); }


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

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

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

LLVM IR (-O2):
define void @update_time() {
%1 = tail call i32 (...) @cmos_read_rtc()
ret void
}
int compare_double(const void *d1, const void *d2) {
  return (*(double *)d1 < *(double *)d2) ? 1 : -1;
}


x86 assembly (clang, -O0):
<compare_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_double>:
movsd  (%rsi),%xmm0
xor    %eax,%eax
ucomisd (%rdi),%xmm0
seta   %al
add    %eax,%eax
add    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @compare_double(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 = bitcast i8* %5 to double*
%7 = load double, double* %6
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to double*
%10 = load double, double* %9
%11 = fcmp olt double %7, %10
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 1, i32 -1
ret i32 %13
}

LLVM IR (-O2):
define i32 @compare_double(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to double*
%4 = load double, double* %3
%5 = bitcast i8* %1 to double*
%6 = load double, double* %5
%7 = fcmp olt double %4, %6
%8 = select i1 %7, i32 1, i32 -1
ret i32 %8
}
int main() {
  char *test = "123";
  return test[0] + test[1];
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
lea    0xeee(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
add    %ecx,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [4 x i8] c"123\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = add nsw i32 %6, %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @main() {
ret i32 99
}
void gg_free_search(struct gg_http *h) {}


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

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

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

LLVM IR (-O2):
%struct.gg_http = type opaque
define void @gg_free_search(%struct.gg_http* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ grub_sh_fini();
void grub_fini_all(void) { grub_sh_fini(); }


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

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

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

LLVM IR (-O2):
define void @grub_fini_all() {
%1 = tail call i32 (...) @grub_sh_fini()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ syscall(int, char *, int);
int send(char *msg, int pid) { syscall(54, msg, pid); }


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

x86 assembly (clang, -O2):
<send>:
mov    %esi,%edx
mov    %rdi,%rsi
mov    $0x36,%edi
jmp    1030 <syscall@plt>

LLVM IR (-O0):
define i32 @send(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = load i32, i32* %5
%8 = call i32 @syscall(i32 54, i8* %6, i32 %7)
%9 = load i32, i32* %3
ret i32 %9
}

LLVM IR (-O2):
define i32 @send(i8* %0, i32 %1) {
%3 = tail call i32 @syscall(i32 54, i8* %0, i32 %1)
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ ExecCfg(char *);
void SIO1about() { ExecCfg("about"); }


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

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

LLVM IR (-O0):
@.str = [6 x i8] c"about\00"
define void @SIO1about() {
%1 = call i32 @ExecCfg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"about\00"
define void @SIO1about() {
%1 = tail call i32 @ExecCfg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret void
}
void finalize_cache_mp_write_session_write_response(
    struct cache_mp_write_session_write_response *mp_ws_write_response) {
  (void)0;
  (void)0;
}


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

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

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

LLVM IR (-O2):
%struct.cache_mp_write_session_write_response = type opaque
define void @finalize_cache_mp_write_session_write_response(%struct.cache_mp_write_session_write_response* nocapture %0) {
ret void
}
void MergeRGBRow_C() {}


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

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

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

LLVM IR (-O2):
define void @MergeRGBRow_C() {
ret void
}
void xnarch_set_irq_affinity(unsigned irq, unsigned long affinity) {}


x86 assembly (clang, -O0):
<xnarch_set_irq_affinity>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @xnarch_set_irq_affinity(i32 %0, i64 %1) {
ret void
}
/* Type definitions */
struct mmli_context {
  int dummy;
};

/* Variables and functions */
int interp_ctl(struct mmli_context *, char const *, char const **, int **);
int mmli_ctl(struct mmli_context *c, const char *s, const char **tailp,
             int *channel) {
  return interp_ctl(c, s, tailp, &channel);
}


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

x86 assembly (clang, -O2):
<mmli_ctl>:
push   %rax
mov    %rcx,(%rsp)
mov    %rsp,%rcx
call   1030 <interp_ctl@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.mmli_context = type { i32 }
define i32 @mmli_ctl(%struct.mmli_context* %0, i8* %1, i8** %2, i32* %3) {
%5 = alloca %struct.mmli_context*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32*
store %struct.mmli_context* %0, %struct.mmli_context** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
store i32* %3, i32** %8
%9 = load %struct.mmli_context*, %struct.mmli_context** %5
%10 = load i8*, i8** %6
%11 = load i8**, i8*** %7
%12 = call i32 @interp_ctl(%struct.mmli_context* %9, i8* %10, i8** %11, i32** %8)
ret i32 %12
}

LLVM IR (-O2):
%struct.mmli_context = type { i32 }
define i32 @mmli_ctl(%struct.mmli_context* %0, i8* %1, i8** %2, i32* %3) {
%5 = alloca i32*
store i32* %3, i32** %5
%6 = call i32 @interp_ctl(%struct.mmli_context* %0, i8* %1, i8** %2, i32** %5)
ret i32 %6
}
/* Variables and functions */
int read(int, void *, int);
int cw_read(int fd, void *buf, int count, int ssl) {
  return read(fd, buf, count);
}


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

x86 assembly (clang, -O2):
<cw_read>:
jmp    1030 <read@plt>

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

LLVM IR (-O2):
define i32 @cw_read(i32 %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 @read(i32 %0, i8* %1, i32 %2)
ret i32 %5
}
/* Type definitions */
struct Dict {
  int dummy;
};

/* Variables and functions */
void *dict_getl(struct Dict *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
void *dict_get(struct Dict *dict, const char *key) {
  return dict_getl(dict, key, strlen(key));
}


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

x86 assembly (clang, -O2):
<dict_get>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <dict_getl@plt>

LLVM IR (-O0):
%struct.Dict = type { i32 }
define i8* @dict_get(%struct.Dict* %0, i8* %1) {
%3 = alloca %struct.Dict*
%4 = alloca i8*
store %struct.Dict* %0, %struct.Dict** %3
store i8* %1, i8** %4
%5 = load %struct.Dict*, %struct.Dict** %3
%6 = load i8*, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = call i8* @dict_getl(%struct.Dict* %5, i8* %6, i32 %8)
ret i8* %9
}

LLVM IR (-O2):
%struct.Dict = type { i32 }
define i8* @dict_get(%struct.Dict* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i8* @dict_getl(%struct.Dict* %0, i8* %1, i32 %3)
ret i8* %4
}
/* Type definitions */
typedef int /*<<< orphan*/ d;

/* Variables and functions */
int /*<<< orphan*/ oled_SendCommand(unsigned char *, int);
void SetPageAddress(char x) {
  unsigned char d[] = {0xB0 | (x & 0x0F)};
  oled_SendCommand(d, sizeof(d));
}


x86 assembly (clang, -O0):
<SetPageAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
and    $0xf,%eax
or     $0xb0,%eax
mov    %al,-0x2(%rbp)
lea    -0x2(%rbp),%rdi
mov    $0x1,%esi
call   1030 <oled_SendCommand@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetPageAddress>:
push   %rax
and    $0xf,%dil
or     $0xb0,%dil
mov    %dil,0x7(%rsp)
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
call   1030 <oled_SendCommand@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @SetPageAddress(i8 signext %0) {
%2 = alloca i8
%3 = alloca [1 x i8]
store i8 %0, i8* %2
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = and i32 %6, 15
%8 = or i32 176, %7
%9 = trunc i32 %8 to i8
store i8 %9, i8* %4
%10 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%11 = call i32 @oled_SendCommand(i8* %10, i32 1)
ret void
}

LLVM IR (-O2):
define void @SetPageAddress(i8 signext %0) {
%2 = alloca [1 x i8]
%3 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%4 = and i8 %0, 15
%5 = or i8 %4, -80
store i8 %5, i8* %3
%6 = call i32 @oled_SendCommand(i8* %3, i32 1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ stop_frame();
void first_frame() { stop_frame(); }


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

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

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

LLVM IR (-O2):
define void @first_frame() {
%1 = tail call i32 (...) @stop_frame()
ret void
}
/* Variables and functions */
unsigned long LONG_MAX;
unsigned long roundup_pow_of_two(unsigned long size) {
  unsigned long i = 4;
  if (size >= LONG_MAX)
    return LONG_MAX;
  while (1) {
    if (i >= size)
      return i;
    i *= 2;
  }
}


x86 assembly (clang, -O0):
<roundup_pow_of_two>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movq   $0x4,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2ec5(%rip),%rcx
cmp    (%rcx),%rax
jb     1137 <roundup_pow_of_two+0x37>
mov    0x2eb5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1168 <roundup_pow_of_two+0x68>
jmp    113c <roundup_pow_of_two+0x3c>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     1157 <roundup_pow_of_two+0x57>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1168 <roundup_pow_of_two+0x68>
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113c <roundup_pow_of_two+0x3c>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<roundup_pow_of_two>:
mov    0x2ed9(%rip),%rax
mov    (%rax),%rax
cmp    %rdi,%rax
jbe    112b <roundup_pow_of_two+0x2b>
mov    $0x4,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,%rax
add    %rcx,%rcx
cmp    %rdi,%rax
jb     1120 <roundup_pow_of_two+0x20>
ret

LLVM IR (-O0):
@LONG_MAX = global i64 0
define i64 @roundup_pow_of_two(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 4, i64* %4
%5 = load i64, i64* %3
%6 = load i64, i64* @LONG_MAX
%7 = icmp uge i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i64, i64* @LONG_MAX
store i64 %9, i64* %2
br label %20
10: ; preds = %1
br label %11
11: ; preds = %10, %17
%12 = load i64, i64* %4
%13 = load i64, i64* %3
%14 = icmp uge i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i64, i64* %4
store i64 %16, i64* %2
br label %20
17: ; preds = %11
%18 = load i64, i64* %4
%19 = mul i64 %18, 2
store i64 %19, i64* %4
br label %11
20: ; preds = %15, %8
%21 = load i64, i64* %2
ret i64 %21
}

LLVM IR (-O2):
@LONG_MAX = global i64 0
define i64 @roundup_pow_of_two(i64 %0) {
%2 = load i64, i64* @LONG_MAX
%3 = icmp ugt i64 %2, %0
br i1 %3, label %4, label %8
4: ; preds = %1, %4
%5 = phi i64 [ %7, %4 ], [ 4, %1 ]
%6 = icmp ult i64 %5, %0
%7 = shl i64 %5, 1
br i1 %6, label %4, label %8
8: ; preds = %4, %1
%9 = phi i64 [ %2, %1 ], [ %5, %4 ]
ret i64 %9
}
int fun414() { return 414; }


x86 assembly (clang, -O0):
<fun414>:
push   %rbp
mov    %rsp,%rbp
mov    $0x19e,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @fun414() {
ret i32 414
}

LLVM IR (-O2):
define i32 @fun414() {
ret i32 414
}