xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
int bar(int flag) {
  puts("bar");
  return flag;
}


x86 assembly (clang, -O0):
<bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"bar\00"
define i32 @bar(i32 returned %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret i32 %0
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
uint32_t nibbles_to_samples(uint32_t nibbles) {
  uint32_t whole_frames = nibbles / 16;
  if (nibbles % 16) {
    return whole_frames * 14 + nibbles % 16 - 2;
  }
  return whole_frames * 14;
}


x86 assembly (clang, -O0):
<nibbles_to_samples>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     114b <nibbles_to_samples+0x4b>
imul   $0xe,-0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%eax
add    %edx,%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    1152 <nibbles_to_samples+0x52>
imul   $0xe,-0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nibbles_to_samples>:
lea    0xf(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
mov    %eax,%ecx
and    $0xfffffff0,%ecx
sub    %ecx,%edi
sar    $0x4,%eax
sub    %eax,%ecx
sub    %eax,%ecx
lea    -0x2(%rdi),%eax
test   %edi,%edi
cmove  %edi,%eax
add    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @nibbles_to_samples(i32 %0) {
%2 = sdiv i32 %0, 16
%3 = srem i32 %0, 16
%4 = icmp eq i32 %3, 0
%5 = mul nsw i32 %2, 14
%6 = add nsw i32 %3, -2
%7 = select i1 %4, i32 0, i32 %6
%8 = add nsw i32 %5, %7
ret i32 %8
}
/* Variables and functions */
int /*<<< orphan*/ executeApplescriptToGetInt(char *, char *, int *);
int getRating() {
  int rating = 0;
  executeApplescriptToGetInt("iTunes", "rating of current track", &rating);
  return (rating / 20);
}


x86 assembly (clang, -O0):
<getRating>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    0xeda(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1030 <executeApplescriptToGetInt@plt>
mov    -0x4(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRating>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xee0(%rip),%rdi
lea    0xee0(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1030 <executeApplescriptToGetInt@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"iTunes\00"
@.str.1 = [24 x i8] c"rating of current track\00"
define i32 @getRating() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @executeApplescriptToGetInt(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%3 = load i32, i32* %1
%4 = sdiv i32 %3, 20
ret i32 %4
}

LLVM IR (-O2):
@.str = [7 x i8] c"iTunes\00"
@.str.1 = [24 x i8] c"rating of current track\00"
define i32 @getRating() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 @executeApplescriptToGetInt(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = sdiv i32 %4, 20
ret i32 %5
}
int nanotec_round_angle(double theta) {
  if (theta >= 0)
    return (int)(theta + 0.5);
  else
    return (int)(theta - 0.5);
}


x86 assembly (clang, -O0):
<nanotec_round_angle>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1134 <nanotec_round_angle+0x34>
movsd  0xedd(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
jmp    114c <nanotec_round_angle+0x4c>
movsd  -0x10(%rbp),%xmm0
movsd  0xebf(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nanotec_round_angle>:
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
setb   %al
lea    0xeec(%rip),%rcx
addsd  (%rcx,%rax,8),%xmm0
cvttsd2si %xmm0,%eax
ret

LLVM IR (-O0):
define i32 @nanotec_round_angle(double %0) {
%2 = alloca i32
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, 0.000000e+00
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load double, double* %3
%8 = fadd double %7, 5.000000e-01
%9 = fptosi double %8 to i32
store i32 %9, i32* %2
br label %14
10: ; preds = %1
%11 = load double, double* %3
%12 = fsub double %11, 5.000000e-01
%13 = fptosi double %12 to i32
store i32 %13, i32* %2
br label %14
14: ; preds = %10, %6
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
define i32 @nanotec_round_angle(double %0) {
%2 = fcmp ult double %0, 0.000000e+00
%3 = select i1 %2, double -5.000000e-01, double 5.000000e-01
%4 = fadd double %3, %0
%5 = fptosi double %4 to i32
ret i32 %5
}
void RTPathHavePath(void) {}


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

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

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

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

/* Variables and functions */
int /*<<< orphan*/ xcloselog(int /*<<< orphan*/ *);
int slg_free(BIO *a) {
  if (a == NULL)
    return (0);
  xcloselog(a);
  return (1);
}


x86 assembly (clang, -O0):
<slg_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <slg_free+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1143 <slg_free+0x33>
mov    -0x10(%rbp),%rdi
call   1030 <xcloselog@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slg_free>:
test   %rdi,%rdi
je     1125 <slg_free+0x15>
push   %rax
call   1030 <xcloselog@plt>
mov    $0x1,%eax
add    $0x8,%rsp
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @slg_free(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @xcloselog(i32* %0)
br label %5
5: ; preds = %1, %3
%6 = phi i32 [ 1, %3 ], [ 0, %1 ]
ret i32 %6
}
/* Variables and functions */
int f343(int *);
int f344(int *p) { return f343(p); }


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

x86 assembly (clang, -O2):
<f344>:
jmp    1030 <f343@plt>

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

LLVM IR (-O2):
define i32 @f344(i32* %0) {
%2 = tail call i32 @f343(i32* %0)
ret i32 %2
}
/* Variables and functions */
char *p_dcngettext(char const *, char const *, char const *, unsigned long,
                   int);
int /*<<< orphan*/ setup();
char *g_libintl_dcngettext(const char *domainname, const char *msgid1,
                           const char *msgid2, unsigned long int n,
                           int category) {
  setup();
  return p_dcngettext(domainname, msgid1, msgid2, n, category);
}


x86 assembly (clang, -O0):
<g_libintl_dcngettext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    $0x0,%al
call   1040 <setup@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1030 <p_dcngettext@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g_libintl_dcngettext>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%rbp
xor    %eax,%eax
call   1040 <setup@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <p_dcngettext@plt>

LLVM IR (-O0):
define i8* @g_libintl_dcngettext(i8* %0, i8* %1, i8* %2, i64 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i32 %4, i32* %10
%11 = call i32 (...) @setup()
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%15 = load i64, i64* %9
%16 = load i32, i32* %10
%17 = call i8* @p_dcngettext(i8* %12, i8* %13, i8* %14, i64 %15, i32 %16)
ret i8* %17
}

LLVM IR (-O2):
define i8* @g_libintl_dcngettext(i8* %0, i8* %1, i8* %2, i64 %3, i32 %4) {
%6 = tail call i32 (...) @setup()
%7 = tail call i8* @p_dcngettext(i8* %0, i8* %1, i8* %2, i64 %3, i32 %4)
ret i8* %7
}
/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
void *malloc(size_t);
void *Wmalloc(size_t len) {
  void *p;
  p = malloc(len);
  assert(p != NULL);
  return (p);
}


x86 assembly (clang, -O0):
<Wmalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Wmalloc>:
push   %rbx
call   1040 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1030 <assert@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @Wmalloc(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i8* @malloc(i64 %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i8*, i8** %3
ret i8* %10
}

LLVM IR (-O2):
define noalias i8* @Wmalloc(i64 %0) {
%2 = tail call i8* @malloc(i64 %0)
%3 = icmp ne i8* %2, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
ret i8* %2
}
void hostapd_deinit_ht(struct hostapd_iface *iface) {}


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

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

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

LLVM IR (-O2):
%struct.hostapd_iface = type opaque
define void @hostapd_deinit_ht(%struct.hostapd_iface* nocapture %0) {
ret void
}
void plat_extra_sync_for_device(struct device *dev) { return; }


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

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

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

LLVM IR (-O2):
%struct.device = type opaque
define void @plat_extra_sync_for_device(%struct.device* nocapture %0) {
ret void
}
/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int *);
int /*<<< orphan*/ safer_free(void **);
int main(void) {
  int *ptr_i;
  ptr_i = (int *)malloc(sizeof(int));
  *ptr_i = 7;
  printf("Antes de safer_free ptr_i:%p\n", ptr_i);
  safer_free((void **)&(ptr_i));
  printf("Despues de safer_free ptr_i:%p\n", ptr_i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x7,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1050 <safer_free@plt>
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,(%rsp)
movl   $0x7,(%rax)
lea    0xeb4(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rsp,%rdi
call   1050 <safer_free@plt>
mov    (%rsp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Antes de safer_free ptr_i:%p\0A\00"
@.str.1 = [32 x i8] c"Despues de safer_free ptr_i:%p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to i32*
store i32* %4, i32** %2
%5 = load i32*, i32** %2
store i32 7, i32* %5
%6 = load i32*, i32** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32* %6)
%8 = bitcast i32** %2 to i8**
%9 = call i32 @safer_free(i8** %8)
%10 = load i32*, i32** %2
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32* %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Antes de safer_free ptr_i:%p\0A\00"
@.str.1 = [32 x i8] c"Despues de safer_free ptr_i:%p\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
%3 = tail call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to i32*
store i32* %4, i32** %1
store i32 7, i32* %4
%5 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32* %4)
%6 = bitcast i32** %1 to i8**
%7 = call i32 @safer_free(i8** %6)
%8 = load i32*, i32** %1
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32* %8)
ret i32 0
}
short NO_FLIP_SHORT(short pVar) { return pVar; }


x86 assembly (clang, -O0):
<NO_FLIP_SHORT>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<NO_FLIP_SHORT>:
mov    %edi,%eax
ret

LLVM IR (-O0):
define signext i16 @NO_FLIP_SHORT(i16 signext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
ret i16 %3
}

LLVM IR (-O2):
define signext i16 @NO_FLIP_SHORT(i16 returned signext %0) {
ret i16 %0
}
/* Variables and functions */
double RAND_MAX;
int rand();
int getrand(int min, int max) {
  return min + (int)(rand() * (max - min + 1.0) / (1.0 + RAND_MAX));
}


x86 assembly (clang, -O0):
<getrand>:
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    $0x0,%al
call   1030 <rand@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cvtsi2sd %ecx,%xmm0
mov    -0x8(%rbp),%ecx
sub    -0x4(%rbp),%ecx
cvtsi2sd %ecx,%xmm1
movsd  0xeba(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeaa(%rip),%xmm1
mov    0x2e8b(%rip),%rcx
addsd  (%rcx),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrand>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cvtsi2sd %eax,%xmm0
sub    %ebp,%ebx
cvtsi2sd %ebx,%xmm1
movsd  0xed0(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
mov    0x2ea9(%rip),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @getrand(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 (...) @rand()
%7 = sitofp i32 %6 to double
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = sub nsw i32 %8, %9
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 1.000000e+00
%13 = fmul double %7, %12
%14 = load double, double* @RAND_MAX
%15 = fadd double 1.000000e+00, %14
%16 = fdiv double %13, %15
%17 = fptosi double %16 to i32
%18 = add nsw i32 %5, %17
ret i32 %18
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @getrand(i32 %0, i32 %1) {
%3 = tail call i32 (...) @rand()
%4 = sitofp i32 %3 to double
%5 = sub nsw i32 %1, %0
%6 = sitofp i32 %5 to double
%7 = fadd double %6, 1.000000e+00
%8 = fmul double %7, %4
%9 = load double, double* @RAND_MAX
%10 = fadd double %9, 1.000000e+00
%11 = fdiv double %8, %10
%12 = fptosi double %11 to i32
%13 = add nsw i32 %12, %0
ret i32 %13
}
/* Variables and functions */
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void init_seed(void) { srand(time(NULL)); }


x86 assembly (clang, -O0):
<init_seed>:
push   %rbp
mov    %rsp,%rbp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_seed>:
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <srand@plt>

LLVM IR (-O0):
define void @init_seed() {
%1 = call i32 @time(i32* null)
%2 = call i32 @srand(i32 %1)
ret void
}

LLVM IR (-O2):
define void @init_seed() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ I2C_OIS_per_write(int, int);
void ChangeShiftOISGain(int distance) {
  int shift_gain = (0x3489) * 10 / distance;
  I2C_OIS_per_write(0x8B, shift_gain);
  I2C_OIS_per_write(0xCB, shift_gain);
}


x86 assembly (clang, -O0):
<ChangeShiftOISGain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x20d5a,%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x8b,%edi
call   1030 <I2C_OIS_per_write@plt>
mov    -0x8(%rbp),%esi
mov    $0xcb,%edi
call   1030 <I2C_OIS_per_write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ChangeShiftOISGain>:
push   %rbx
mov    $0x20d5a,%eax
xor    %edx,%edx
idiv   %edi
mov    %eax,%ebx
mov    $0x8b,%edi
mov    %eax,%esi
call   1030 <I2C_OIS_per_write@plt>
mov    $0xcb,%edi
mov    %ebx,%esi
pop    %rbx
jmp    1030 <I2C_OIS_per_write@plt>

LLVM IR (-O0):
define void @ChangeShiftOISGain(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sdiv i32 134490, %4
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = call i32 @I2C_OIS_per_write(i32 139, i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @I2C_OIS_per_write(i32 203, i32 %8)
ret void
}

LLVM IR (-O2):
define void @ChangeShiftOISGain(i32 %0) {
%2 = sdiv i32 134490, %0
%3 = tail call i32 @I2C_OIS_per_write(i32 139, i32 %2)
%4 = tail call i32 @I2C_OIS_per_write(i32 203, i32 %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  printf("hello  world \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@str = [14 x i8] c"hello world \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}
double omp_get_wtime() { return 0.0; }


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

x86 assembly (clang, -O2):
<omp_get_wtime>:
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @omp_get_wtime() {
ret double 0.000000e+00
}

LLVM IR (-O2):
define double @omp_get_wtime() {
ret double 0.000000e+00
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ get_file_frequencies(int /*<<< orphan*/ *, int *);
int *get_frequencies(const char filename[], int frequencies[]) {
  FILE *f = fopen(filename, "r");
  if (!f)
    return NULL;
  get_file_frequencies(f, frequencies);
  fclose(f);
  return frequencies;
}


x86 assembly (clang, -O0):
<get_frequencies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116c <get_frequencies+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    118a <get_frequencies+0x5a>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <get_file_frequencies@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_frequencies>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xec2(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1160 <get_frequencies+0x30>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <get_file_frequencies@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1163 <get_frequencies+0x33>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32* @get_frequencies(i8* nocapture %0, i32* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @get_file_frequencies(i32* %3, i32* %1)
%7 = tail call i32 @fclose(i32* %3)
br label %8
8: ; preds = %2, %5
%9 = phi i32* [ %1, %5 ], [ null, %2 ]
ret i32* %9
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  scanf("%d", &num);
  num *= 2;
  printf("%d", num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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

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


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

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

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

LLVM IR (-O2):
define void @producer(i32* nocapture writeonly %0) {
store i32 1, i32* %0
ret void
}
/* Type definitions */
struct timeb {
  int time;
  scalar_t__ millitm;
};

/* Variables and functions */
int /*<<< orphan*/ ftime(struct timeb *);
unsigned int frw_timeGetCurrentMs() {
  unsigned int ret = 0;
  struct timeb tv;
  ftime(&tv);
  ret = (unsigned int)(tv.time * 1000 + tv.millitm);
  return ret;
}


x86 assembly (clang, -O0):
<frw_timeGetCurrentMs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <ftime@plt>
imul   $0x3e8,-0x18(%rbp),%eax
cltq
add    -0x10(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frw_timeGetCurrentMs>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
call   1030 <ftime@plt>
imul   $0x3e8,0x8(%rsp),%eax
add    0x10(%rsp),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeb = type { i32, i64 }
define i32 @frw_timeGetCurrentMs() {
%1 = alloca i32
%2 = alloca %struct.timeb
store i32 0, i32* %1
%3 = call i32 @ftime(%struct.timeb* %2)
%4 = getelementptr inbounds %struct.timeb, %struct.timeb* %2, i32 0, i32 0
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, 1000
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds %struct.timeb, %struct.timeb* %2, i32 0, i32 1
%9 = load i64, i64* %8
%10 = add nsw i64 %7, %9
%11 = trunc i64 %10 to i32
store i32 %11, i32* %1
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
%struct.timeb = type { i32, i64 }
define i32 @frw_timeGetCurrentMs() {
%1 = alloca %struct.timeb
%2 = bitcast %struct.timeb* %1 to i8*
%3 = call i32 @ftime(%struct.timeb* %1)
%4 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, 1000
%7 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i64 0, i32 1
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = add i32 %6, %9
ret i32 %10
}
void tegra_drm_fb_free(struct drm_device *drm) {}


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

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

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

LLVM IR (-O2):
%struct.drm_device = type opaque
define void @tegra_drm_fb_free(%struct.drm_device* nocapture %0) {
ret void
}
char *parse_arguments(int argc, char *argv[]) {
  char *puzzle_key = 0;
  if (argc > 1) {
    puzzle_key = argv[1];
  }
  return puzzle_key;
}


x86 assembly (clang, -O0):
<parse_arguments>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    1129 <parse_arguments+0x29>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_arguments>:
cmp    $0x2,%edi
jl     110a <parse_arguments+0xa>
mov    0x8(%rsi),%rax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i8* @parse_arguments(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %4, %2
%8 = phi i8* [ %6, %4 ], [ null, %2 ]
ret i8* %8
}
void dummy_handler(int signo) {}


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

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

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

LLVM IR (-O2):
define void @dummy_handler(i32 %0) {
ret void
}
int g(float b, short c) { return c + (int)b; }


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
movss  %xmm0,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cvttss2si -0x4(%rbp),%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
cvttss2si %xmm0,%eax
add    %edi,%eax
ret

LLVM IR (-O0):
define i32 @g(float %0, i16 signext %1) {
%3 = alloca float
%4 = alloca i16
store float %0, float* %3
store i16 %1, i16* %4
%5 = load i16, i16* %4
%6 = sext i16 %5 to i32
%7 = load float, float* %3
%8 = fptosi float %7 to i32
%9 = add nsw i32 %6, %8
ret i32 %9
}

LLVM IR (-O2):
define i32 @g(float %0, i16 signext %1) {
%3 = sext i16 %1 to i32
%4 = fptosi float %0 to i32
%5 = add nsw i32 %3, %4
ret i32 %5
}
/* Type definitions */
typedef int /*<<< orphan*/ tss_t;

/* Variables and functions */
void *pthread_getspecific(int /*<<< orphan*/);
void *tss_get(tss_t key) { return pthread_getspecific(key); }


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

x86 assembly (clang, -O2):
<tss_get>:
jmp    1030 <pthread_getspecific@plt>

LLVM IR (-O0):
define i8* @tss_get(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i8* @pthread_getspecific(i32 %3)
ret i8* %4
}

LLVM IR (-O2):
define i8* @tss_get(i32 %0) {
%2 = tail call i8* @pthread_getspecific(i32 %0)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ big_endian_int0(int *);
void big_endian_int(int n, int *d) {
  int i;
  for (i = 0; i < n; i++)
    big_endian_int0(&d[i]);
}


x86 assembly (clang, -O0):
<big_endian_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1154 <big_endian_int+0x44>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <big_endian_int0@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <big_endian_int+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<big_endian_int>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1132 <big_endian_int+0x22>
mov    %rsi,%rbx
mov    %edi,%r14d
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <big_endian_int0@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r14
jne    1120 <big_endian_int+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @big_endian_int(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 = %16, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = call i32 @big_endian_int0(i32* %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %6
19: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @big_endian_int(i32 %0, i32* %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %10, %6 ]
%8 = getelementptr inbounds i32, i32* %1, i64 %7
%9 = tail call i32 @big_endian_int0(i32* %8)
%10 = add nuw nsw i64 %7, 1
%11 = icmp eq i64 %10, %5
br i1 %11, label %12, label %6
12: ; preds = %6, %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int syscall(int, char *, int /*<<< orphan*/);
int chname() {
  char input[64];
  printf("Input new name : ");
  gets(input);
  return syscall(2, input, 0);
}


x86 assembly (clang, -O0):
<chname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x40(%rbp),%rsi
mov    $0x2,%edi
xor    %edx,%edx
call   1040 <syscall@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chname>:
push   %rbx
sub    $0x40,%rsp
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <syscall@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Input new name : \00"
define i32 @chname() {
%1 = alloca [64 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = call i32 @gets(i8* %3)
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%6 = call i32 @syscall(i32 2, i8* %5, i32 0)
ret i32 %6
}

LLVM IR (-O2):
@.str = [18 x i8] c"Input new name : \00"
define i32 @chname() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @syscall(i32 2, i8* %2, i32 0)
ret i32 %5
}
/* Variables and functions */
int random_int(int, int);
int pivot_index(int d, int f) { return random_int(d, f); }


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

x86 assembly (clang, -O2):
<pivot_index>:
jmp    1030 <random_int@plt>

LLVM IR (-O0):
define i32 @pivot_index(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 @random_int(i32 %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @pivot_index(i32 %0, i32 %1) {
%3 = tail call i32 @random_int(i32 %0, i32 %1)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ pwm_test();
int main(void) {
  pwm_test();
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @pwm_test()
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *__original_fopen(char const *, char const *);
FILE *fopen(const char *path, const char *mode) {
  FILE *ret = 0;
  ret = __original_fopen(path, mode);
  return ret;
}


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

x86 assembly (clang, -O2):
<fopen>:
jmp    1030 <__original_fopen@plt>

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

LLVM IR (-O2):
define i32* @fopen(i8* %0, i8* %1) {
%3 = tail call i32* @__original_fopen(i8* %0, i8* %1)
ret i32* %3
}
void linkedlist_destroy_data(void *data) {}


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

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

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

LLVM IR (-O2):
define void @linkedlist_destroy_data(i8* nocapture %0) {
ret void
}
char uchar_to_char(unsigned char u) { return (char)u; }


x86 assembly (clang, -O0):
<uchar_to_char>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<uchar_to_char>:
mov    %edi,%eax
ret

LLVM IR (-O0):
define signext i8 @uchar_to_char(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
ret i8 %3
}

LLVM IR (-O2):
define signext i8 @uchar_to_char(i8 returned zeroext %0) {
ret i8 %0
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
uint32_t xor128() {
  static uint32_t x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  uint32_t t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}


x86 assembly (clang, -O0):
<xor128>:
push   %rbp
mov    %rsp,%rbp
mov    0x2f16(%rip),%eax
mov    0x2f10(%rip),%ecx
shl    $0xb,%ecx
xor    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    0x2f06(%rip),%eax
mov    %eax,0x2efc(%rip)
mov    0x2efe(%rip),%eax
mov    %eax,0x2ef4(%rip)
mov    0x2ef6(%rip),%eax
mov    %eax,0x2eec(%rip)
mov    0x2eea(%rip),%eax
mov    0x2ee4(%rip),%ecx
sar    $0x13,%ecx
xor    %ecx,%eax
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%edx
sar    $0x8,%edx
xor    %edx,%ecx
xor    %ecx,%eax
mov    %eax,0x2ecc(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<xor128>:
mov    0x2f1a(%rip),%ecx
mov    %ecx,%eax
shl    $0xb,%eax
xor    %ecx,%eax
mov    0x2f11(%rip),%ecx
mov    %ecx,0x2f07(%rip)
mov    0x2f09(%rip),%ecx
mov    %ecx,0x2eff(%rip)
mov    0x2f01(%rip),%ecx
mov    %ecx,0x2ef7(%rip)
mov    %eax,%edx
sar    $0x8,%edx
xor    %ecx,%eax
sar    $0x13,%ecx
xor    %edx,%eax
xor    %ecx,%eax
mov    %eax,0x2ee7(%rip)
ret

LLVM IR (-O0):
@xor128.x = internal global i32 123456789
@xor128.y = internal global i32 362436069
@xor128.z = internal global i32 521288629
@xor128.w = internal global i32 88675123
define i32 @xor128() {
%1 = alloca i32
%2 = load i32, i32* @xor128.x
%3 = load i32, i32* @xor128.x
%4 = shl i32 %3, 11
%5 = xor i32 %2, %4
store i32 %5, i32* %1
%6 = load i32, i32* @xor128.y
store i32 %6, i32* @xor128.x
%7 = load i32, i32* @xor128.z
store i32 %7, i32* @xor128.y
%8 = load i32, i32* @xor128.w
store i32 %8, i32* @xor128.z
%9 = load i32, i32* @xor128.w
%10 = load i32, i32* @xor128.w
%11 = ashr i32 %10, 19
%12 = xor i32 %9, %11
%13 = load i32, i32* %1
%14 = load i32, i32* %1
%15 = ashr i32 %14, 8
%16 = xor i32 %13, %15
%17 = xor i32 %12, %16
store i32 %17, i32* @xor128.w
ret i32 %17
}

LLVM IR (-O2):
@xor128.x = internal unnamed_addr global i32 123456789
@xor128.y = internal unnamed_addr global i32 362436069
@xor128.z = internal unnamed_addr global i32 521288629
@xor128.w = internal unnamed_addr global i32 88675123
define i32 @xor128() {
%1 = load i32, i32* @xor128.x
%2 = shl i32 %1, 11
%3 = xor i32 %2, %1
%4 = load i32, i32* @xor128.y
store i32 %4, i32* @xor128.x
%5 = load i32, i32* @xor128.z
store i32 %5, i32* @xor128.y
%6 = load i32, i32* @xor128.w
store i32 %6, i32* @xor128.z
%7 = ashr i32 %6, 19
%8 = ashr i32 %3, 8
%9 = xor i32 %8, %3
%10 = xor i32 %9, %6
%11 = xor i32 %10, %7
store i32 %11, i32* @xor128.w
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ Mali_SetBase(int *);
int /*<<< orphan*/ RunMaliTest_sim1_t760_part0();
int RunMaliTest_sim1_t760(int *base) {
  Mali_SetBase(base);
  RunMaliTest_sim1_t760_part0();
}


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

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

LLVM IR (-O0):
define i32 @RunMaliTest_sim1_t760(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = call i32 @Mali_SetBase(i32* %4)
%6 = call i32 (...) @RunMaliTest_sim1_t760_part0()
%7 = load i32, i32* %2
ret i32 %7
}

LLVM IR (-O2):
define i32 @RunMaliTest_sim1_t760(i32* %0) {
%2 = tail call i32 @Mali_SetBase(i32* %0)
%3 = tail call i32 (...) @RunMaliTest_sim1_t760_part0()
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
void *malloc(int);
int /*<<< orphan*/ stderr;
void *my_malloc(int sz, char *err_string) {
  void *p = malloc(sz);
  if (p == NULL) {
    fprintf(stderr, "-- malloc failure allocating %s\n", err_string);
    exit(1);
  }
  return p;
}


x86 assembly (clang, -O0):
<my_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1179 <my_malloc+0x49>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_malloc>:
push   %rbx
mov    %rsi,%rbx
call   1040 <malloc@plt>
test   %rax,%rax
je     1140 <my_malloc+0x10>
pop    %rbx
ret
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"-- malloc failure allocating %s\0A\00"
define i8* @my_malloc(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = call i8* @malloc(i32 %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8*, i8** %5
ret i8* %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"-- malloc failure allocating %s\0A\00"
define noalias i8* @my_malloc(i32 %0, i8* %1) {
%3 = tail call i8* @malloc(i32 %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %1)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
ret i8* %3
}
/* Type definitions */
struct stat {
  size_t st_size;
};

/* Variables and functions */
int /*<<< orphan*/ stat(char const *, struct stat *);
size_t fsize(const char *fname) {
  struct stat st;
  stat(fname, &st);
  return st.st_size;
}


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

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

LLVM IR (-O0):
%struct.stat = type { i64 }
define i64 @fsize(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @stat(i8* %4, %struct.stat* %3)
%6 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%7 = load i64, i64* %6
ret i64 %7
}

LLVM IR (-O2):
%struct.stat = type { i64 }
define i64 @fsize(i8* nocapture %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @stat(i8* %0, %struct.stat* %2)
%5 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%6 = load i64, i64* %5
ret i64 %6
}
/* Variables and functions */
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ writeCharToOutput();
void *rpn2c_processTimeout(void *arg) {
  usleep(500000);
  writeCharToOutput();
}


x86 assembly (clang, -O0):
<rpn2c_processTimeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x7a120,%edi
call   1040 <usleep@plt>
mov    $0x0,%al
call   1030 <writeCharToOutput@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpn2c_processTimeout>:
push   %rax
mov    $0x7a120,%edi
call   1040 <usleep@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <writeCharToOutput@plt>

LLVM IR (-O0):
define i8* @rpn2c_processTimeout(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i32 @usleep(i32 500000)
%5 = call i32 (...) @writeCharToOutput()
%6 = load i8*, i8** %2
ret i8* %6
}

LLVM IR (-O2):
define noalias i8* @rpn2c_processTimeout(i8* nocapture readnone %0) {
%2 = tail call i32 @usleep(i32 500000)
%3 = tail call i32 (...) @writeCharToOutput()
ret i8* undef
}
/* Variables and functions */
int /*<<< orphan*/ C67_asm(char *, int, int, int);
void C67_SHR(int r, int v) { C67_asm("SHR.S", r, v, v); }


x86 assembly (clang, -O0):
<C67_SHR>:
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    -0x8(%rbp),%ecx
lea    0xed2(%rip),%rdi
call   1030 <C67_asm@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [6 x i8] c"SHR.S\00"
define void @C67_SHR(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 = load i32, i32* %4
%8 = call i32 @C67_asm(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6, i32 %7)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"SHR.S\00"
define void @C67_SHR(i32 %0, i32 %1) {
%3 = tail call i32 @C67_asm(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %1)
ret void
}