xunge/DecIR huggingface dataset:
double perc(long val, int range) {
  if (range == 0)
    return 0;
  double result = (val / (double)range) * 100;
  return result;
}


x86 assembly (clang, -O0):
<perc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1122 <perc+0x22>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    114c <perc+0x4c>
cvtsi2sdq -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xec7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<perc>:
test   %esi,%esi
je     111a <perc+0x1a>
cvtsi2sd %rdi,%xmm0
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm0
mulsd  0xee7(%rip),%xmm0
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @perc(i64 %0, i32 %1) {
%3 = alloca double
%4 = alloca i64
%5 = alloca i32
%6 = alloca double
store i64 %0, i64* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store double 0.000000e+00, double* %3
br label %18
10: ; preds = %2
%11 = load i64, i64* %4
%12 = sitofp i64 %11 to double
%13 = load i32, i32* %5
%14 = sitofp i32 %13 to double
%15 = fdiv double %12, %14
%16 = fmul double %15, 1.000000e+02
store double %16, double* %6
%17 = load double, double* %6
store double %17, double* %3
br label %18
18: ; preds = %10, %9
%19 = load double, double* %3
ret double %19
}

LLVM IR (-O2):
define double @perc(i64 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = sitofp i64 %0 to double
%6 = sitofp i32 %1 to double
%7 = fdiv double %5, %6
%8 = fmul double %7, 1.000000e+02
br label %9
9: ; preds = %2, %4
%10 = phi double [ %8, %4 ], [ 0.000000e+00, %2 ]
ret double %10
}
/* Variables and functions */
int /*<<< orphan*/ putchar(char);
void function(char a) { putchar(a); }


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @function(i8 signext %0) {
%2 = tail call i32 @putchar(i8 signext %0)
ret void
}
/* Variables and functions */
int _ctype_lookup(int);
int isspace(int c) { return _ctype_lookup(c) & (0x08); }


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

x86 assembly (clang, -O2):
<isspace>:
push   %rax
call   1030 <_ctype_lookup@plt>
and    $0x8,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @isspace(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @_ctype_lookup(i32 %3)
%5 = and i32 %4, 8
ret i32 %5
}

LLVM IR (-O2):
define i32 @isspace(i32 %0) {
%2 = tail call i32 @_ctype_lookup(i32 %0)
%3 = and i32 %2, 8
ret i32 %3
}
int HelpItem158(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @HelpItem158() {
ret i32 0
}
void __VERIFIER_atomic_CAS(int *v, int e, int u, int *r) {
  if (*v == e) {
    *v = u, *r = 1;
  } else {
    *r = 0;
  }
}


x86 assembly (clang, -O0):
<__VERIFIER_atomic_CAS>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jne    1139 <__VERIFIER_atomic_CAS+0x39>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1143 <__VERIFIER_atomic_CAS+0x43>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<__VERIFIER_atomic_CAS>:
xor    %eax,%eax
cmp    %esi,(%rdi)
jne    110d <__VERIFIER_atomic_CAS+0xd>
mov    %edx,(%rdi)
mov    $0x1,%eax
mov    %eax,(%rcx)
ret

LLVM IR (-O0):
define void @__VERIFIER_atomic_CAS(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* %9
%11 = load i32, i32* %6
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load i32, i32* %7
%15 = load i32*, i32** %5
store i32 %14, i32* %15
%16 = load i32*, i32** %8
store i32 1, i32* %16
br label %19
17: ; preds = %4
%18 = load i32*, i32** %8
store i32 0, i32* %18
br label %19
19: ; preds = %17, %13
ret void
}

LLVM IR (-O2):
define void @__VERIFIER_atomic_CAS(i32* nocapture %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* %0
%6 = icmp eq i32 %5, %1
br i1 %6, label %7, label %8
7: ; preds = %4
store i32 %2, i32* %0
br label %8
8: ; preds = %4, %7
%9 = phi i32 [ 1, %7 ], [ 0, %4 ]
store i32 %9, i32* %3
ret void
}
/* Variables and functions */
int /*<<< orphan*/ on_importl(char *);
int /*<<< orphan*/ on_save_config();
int /*<<< orphan*/ scanf(char *, char *);
int on_addl() {
  char name_newdir[256];
  scanf(" %[^\n]", name_newdir);
  on_importl(name_newdir);
  on_save_config();
  return 0;
}


x86 assembly (clang, -O0):
<on_addl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    -0x100(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <scanf@plt>
lea    -0x100(%rbp),%rdi
call   1050 <on_importl@plt>
mov    $0x0,%al
call   1040 <on_save_config@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<on_addl>:
push   %rbx
sub    $0x100,%rsp
lea    0xec1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <scanf@plt>
mov    %rbx,%rdi
call   1050 <on_importl@plt>
xor    %eax,%eax
call   1040 <on_save_config@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %[^\0A]\00"
define i32 @on_addl() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = call i32 @on_importl(i8* %4)
%6 = call i32 (...) @on_save_config()
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c" %[^\0A]\00"
define i32 @on_addl() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @on_importl(i8* %2)
%5 = call i32 (...) @on_save_config()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ stderr;
void usage(void) {
  (void)fprintf(
      stderr, "%s\n%s\n",
      "usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]",
      "       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]");
  exit(1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
lea    0xecc(%rip),%rdx
lea    0xf09(%rip),%rcx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
lea    0xecf(%rip),%rdx
lea    0xf0c(%rip),%rcx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"%s\0A%s\0A\00"
@.str.1 = [68 x i8] c"usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]\00"
@.str.2 = [68 x i8] c" find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%3 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"%s\0A%s\0A\00"
@.str.1 = [68 x i8] c"usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]\00"
@.str.2 = [68 x i8] c" find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ fatal_error(int /*<<< orphan*/, char *, char *, int, char *,
                               int);
void _unexpected_eof(char *fn, int line, char *srcfn, int srcline) {
  fatal_error(0,
              "Unexpected end of file in file %s at line %d\n"
              "(Source file %s, line %d)",
              fn, line, srcfn, srcline);
}


x86 assembly (clang, -O0):
<_unexpected_eof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
xor    %edi,%edi
lea    0xec2(%rip),%rsi
call   1030 <fatal_error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_unexpected_eof>:
mov    %ecx,%r9d
mov    %rdx,%r8
mov    %esi,%ecx
mov    %rdi,%rdx
lea    0xede(%rip),%rsi
xor    %edi,%edi
jmp    1030 <fatal_error@plt>

LLVM IR (-O0):
@.str = [71 x i8] c"Unexpected end of file in file %s at line %d\0A(Source file %s, line %d)\00"
define void @_unexpected_eof(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = load i8*, i8** %7
%12 = load i32, i32* %8
%13 = call i32 @fatal_error(i32 0, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10, i8* %11, i32 %12)
ret void
}

LLVM IR (-O2):
@.str = [71 x i8] c"Unexpected end of file in file %s at line %d\0A(Source file %s, line %d)\00"
define void @_unexpected_eof(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = tail call i32 @fatal_error(i32 0, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %2, i32 %3)
ret void
}
/* Variables and functions */
unsigned long UCHAR_MAX;
int /*<<< orphan*/ printf(char *, unsigned long);
unsigned char longToUChar(unsigned long makeMeAUChar) {
  if (makeMeAUChar > UCHAR_MAX) {
    printf("%ld is out of uchar range\n", makeMeAUChar);
    return !makeMeAUChar;
  }
  return (unsigned char)makeMeAUChar;
}


x86 assembly (clang, -O0):
<longToUChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2ec9(%rip),%rcx
cmp    (%rcx),%rax
jbe    1157 <longToUChar+0x47>
mov    -0x10(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    115e <longToUChar+0x4e>
mov    -0x10(%rbp),%rax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longToUChar>:
push   %rax
mov    %rdi,%rax
mov    0x2ed5(%rip),%rcx
cmp    %rdi,(%rcx)
jae    1131 <longToUChar+0x21>
lea    0xed9(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@UCHAR_MAX = global i64 0
@.str = [27 x i8] c"%ld is out of uchar range\0A\00"
define zeroext i8 @longToUChar(i64 %0) {
%2 = alloca i8
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = load i64, i64* @UCHAR_MAX
%6 = icmp ugt i64 %4, %5
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i64, i64* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = load i64, i64* %3
%11 = icmp ne i64 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = trunc i32 %13 to i8
store i8 %14, i8* %2
br label %18
15: ; preds = %1
%16 = load i64, i64* %3
%17 = trunc i64 %16 to i8
store i8 %17, i8* %2
br label %18
18: ; preds = %15, %7
%19 = load i8, i8* %2
ret i8 %19
}

LLVM IR (-O2):
@UCHAR_MAX = global i64 0
@.str = [27 x i8] c"%ld is out of uchar range\0A\00"
define zeroext i8 @longToUChar(i64 %0) {
%2 = load i64, i64* @UCHAR_MAX
%3 = icmp ult i64 %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %8
6: ; preds = %1
%7 = trunc i64 %0 to i8
br label %8
8: ; preds = %6, %4
%9 = phi i8 [ 0, %4 ], [ %7, %6 ]
ret i8 %9
}
int five_negative() { return -5; }


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

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

LLVM IR (-O0):
define i32 @five_negative() {
ret i32 -5
}

LLVM IR (-O2):
define i32 @five_negative() {
ret i32 -5
}
void __attribute__((weak)) usb_hp_isr() { debug_handler(__FUNCTION__); }


x86 assembly (clang, -O0):
<usb_hp_isr>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <debug_handler@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_hp_isr>:
lea    0xee9(%rip),%rdi
xor    %eax,%eax
jmp    1030 <debug_handler@plt>

LLVM IR (-O0):
@__FUNCTION__.usb_hp_isr = [11 x i8] c"usb_hp_isr\00"
define weak void @usb_hp_isr() {
%1 = call i32 (i8*, ...) bitcast (i32 (...)* @debug_handler to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.usb_hp_isr, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__FUNCTION__.usb_hp_isr = [11 x i8] c"usb_hp_isr\00"
define weak void @usb_hp_isr() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @debug_handler to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.usb_hp_isr, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ abort_report(char *, char const *, ...);
int unlink(char const *);
void fifo_remove(const char *path) {
  if ((unlink(path)) == -1) {
    (2 == 1) ? abort_report("Could not remove named pipe at %s", path, "")
             : abort_report("Could not remove named pipe at %s", path);
  }
}


x86 assembly (clang, -O0):
<fifo_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
jne    1150 <fifo_remove+0x30>
mov    -0x8(%rbp),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <abort_report@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fifo_remove>:
push   %rbx
mov    %rdi,%rbx
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     1130 <fifo_remove+0x10>
pop    %rbx
ret
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
jmp    1040 <abort_report@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Could not remove named pipe at %s\00"
define void @fifo_remove(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @unlink(i8* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i32 (i8*, i8*, ...) @abort_report(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %6, %1
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"Could not remove named pipe at %s\00"
define void @fifo_remove(i8* %0) {
%2 = tail call i32 @unlink(i8* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, i8*, ...) @abort_report(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %6
6: ; preds = %4, %1
ret void
}
/* Variables and functions */
char *basename(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
void usage(char *path) {
  char *name = basename(path);
  fprintf(stderr, "Usage: %s filename num_buffers\n", name);
}


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

x86 assembly (clang, -O2):
<usage>:
push   %rax
call   1040 <basename@plt>
mov    0x2eb3(%rip),%rcx
mov    (%rcx),%edi
lea    0xeca(%rip),%rsi
mov    %rax,%rdx
pop    %rax
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Usage: %s filename num_buffers\0A\00"
define void @usage(i8* %0) {
%2 = tail call i8* @basename(i8* %0)
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %2)
ret void
}
/* Variables and functions */
int rename(char const *, char const *);
int fs_rename(const char *from, const char *to) { return rename(from, to); }


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

x86 assembly (clang, -O2):
<fs_rename>:
jmp    1030 <rename@plt>

LLVM IR (-O0):
define i32 @fs_rename(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 = load i8*, i8** %4
%7 = call i32 @rename(i8* %5, i8* %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @fs_rename(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32 @rename(i8* %0, i8* %1)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ CP();
int /*<<< orphan*/ Q();
int /*<<< orphan*/ printf(char *);
void C() {
  printf("C -> QC'\n");
  Q();
  CP();
}


x86 assembly (clang, -O0):
<C>:
push   %rbp
mov    %rsp,%rbp
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <Q@plt>
mov    $0x0,%al
call   1030 <CP@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<C>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <Q@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <CP@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"C -> QC'\0A\00"
define void @C() {
%1 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = call i32 (...) @Q()
%3 = call i32 (...) @CP()
ret void
}

LLVM IR (-O2):
@str = [9 x i8] c"C -> QC'\00"
define void @C() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @Q()
%3 = tail call i32 (...) @CP()
ret void
}
int launch_missile() { return 42; }


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

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

LLVM IR (-O0):
define i32 @launch_missile() {
ret i32 42
}

LLVM IR (-O2):
define i32 @launch_missile() {
ret i32 42
}
/* Variables and functions */
int /*<<< orphan*/ check(int, int, int);
int /*<<< orphan*/ sys_call(int, int);
void _sys(int reg, int const8) {
  check(reg, 2, 1);
  check(const8, 3, 2);
  sys_call(reg, const8);
}


x86 assembly (clang, -O0):
<_sys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <check@plt>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1040 <check@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <sys_call@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sys>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <check@plt>
mov    %ebx,%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1040 <check@plt>
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <sys_call@plt>

LLVM IR (-O0):
define void @_sys(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 @check(i32 %5, i32 2, i32 1)
%7 = load i32, i32* %4
%8 = call i32 @check(i32 %7, i32 3, i32 2)
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @sys_call(i32 %9, i32 %10)
ret void
}

LLVM IR (-O2):
define void @_sys(i32 %0, i32 %1) {
%3 = tail call i32 @check(i32 %0, i32 2, i32 1)
%4 = tail call i32 @check(i32 %1, i32 3, i32 2)
%5 = tail call i32 @sys_call(i32 %0, i32 %1)
ret void
}
/* Type definitions */
struct word {
  int dummy;
};

/* Variables and functions */
struct word *addword(char *, struct word *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
struct word *addwordlen(char *word, size_t len, struct word *wlist) {
  char word0[len + 1];
  strncpy(word0, word, len);
  word0[len] = 0;
  return addword(word0, wlist);
}


x86 assembly (clang, -O0):
<addwordlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0x10,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
mov    -0x18(%rbp),%rsi
call   1040 <addword@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addwordlen>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %rsp,%rbx
lea    0x10(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r15,%rdx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbx,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <addword@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.word = type { i32 }
define %struct.word* @addwordlen(i8* %0, i64 %1, %struct.word* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.word*
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store %struct.word* %2, %struct.word** %6
%9 = load i64, i64* %5
%10 = add i64 %9, 1
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %7
%12 = alloca i8, i64 %10
store i64 %10, i64* %8
%13 = load i8*, i8** %4
%14 = load i64, i64* %5
%15 = call i32 @strncpy(i8* %12, i8* %13, i64 %14)
%16 = load i64, i64* %5
%17 = getelementptr inbounds i8, i8* %12, i64 %16
store i8 0, i8* %17
%18 = load %struct.word*, %struct.word** %6
%19 = call %struct.word* @addword(i8* %12, %struct.word* %18)
%20 = load i8*, i8** %7
ret %struct.word* %19
}

LLVM IR (-O2):
%struct.word = type { i32 }
define %struct.word* @addwordlen(i8* %0, i64 %1, %struct.word* %2) {
%4 = add i64 %1, 1
%5 = alloca i8, i64 %4
%6 = call i32 @strncpy(i8* %5, i8* %0, i64 %1)
%7 = getelementptr inbounds i8, i8* %5, i64 %1
store i8 0, i8* %7
%8 = call %struct.word* @addword(i8* %5, %struct.word* %2)
ret %struct.word* %8
}
void paddle_refresh() {}


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

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

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

LLVM IR (-O2):
define void @paddle_refresh() {
ret void
}
void NV21ToI420() {}


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

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

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

LLVM IR (-O2):
define void @NV21ToI420() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ process_one_command();
int /*<<< orphan*/ putstr(char *);
void run_shell(void) {
  for (;;) {
    putstr("> ");
    process_one_command();
  }
}


x86 assembly (clang, -O0):
<run_shell>:
push   %rbp
mov    %rsp,%rbp
jmp    1129 <run_shell+0x9>
lea    0xed0(%rip),%rdi
call   1030 <putstr@plt>
mov    $0x0,%al
call   1040 <process_one_command@plt>
jmp    1129 <run_shell+0x9>

x86 assembly (clang, -O2):
<run_shell>:
push   %rbx
lea    0xed8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <putstr@plt>
xor    %eax,%eax
call   1040 <process_one_command@plt>
jmp    1130 <run_shell+0x10>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
define void @run_shell() {
br label %1
1: ; preds = %1, %0
%2 = call i32 @putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @process_one_command()
br label %1
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
define void @run_shell() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @process_one_command()
br label %1
}
/* Variables and functions */
int /*<<< orphan*/ pixel_pack_s16u8_uv(short *, unsigned char *, unsigned int);
int /*<<< orphan*/ pixel_pack_s16u8_y(short *, unsigned char *, unsigned int);
void llconv_yvu_planar_s16u8(short int *src, unsigned char *dst,
                             unsigned int nbpixels) {
  pixel_pack_s16u8_y(src, dst, nbpixels >> 3);
  pixel_pack_s16u8_uv(src + nbpixels, dst + nbpixels, nbpixels >> 4);
}


x86 assembly (clang, -O0):
<llconv_yvu_planar_s16u8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
shr    $0x3,%edx
call   1040 <pixel_pack_s16u8_y@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
shr    $0x4,%edx
call   1030 <pixel_pack_s16u8_uv@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llconv_yvu_planar_s16u8>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
shr    $0x3,%edx
call   1040 <pixel_pack_s16u8_y@plt>
mov    %ebx,%eax
lea    (%r15,%rax,2),%rdi
add    %rax,%r14
shr    $0x4,%ebx
mov    %r14,%rsi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <pixel_pack_s16u8_uv@plt>

LLVM IR (-O0):
define void @llconv_yvu_planar_s16u8(i16* %0, i8* %1, i32 %2) {
%4 = alloca i16*
%5 = alloca i8*
%6 = alloca i32
store i16* %0, i16** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i16*, i16** %4
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = lshr i32 %9, 3
%11 = call i32 @pixel_pack_s16u8_y(i16* %7, i8* %8, i32 %10)
%12 = load i16*, i16** %4
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i16, i16* %12, i64 %14
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i32, i32* %6
%21 = lshr i32 %20, 4
%22 = call i32 @pixel_pack_s16u8_uv(i16* %15, i8* %19, i32 %21)
ret void
}

LLVM IR (-O2):
define void @llconv_yvu_planar_s16u8(i16* %0, i8* %1, i32 %2) {
%4 = lshr i32 %2, 3
%5 = tail call i32 @pixel_pack_s16u8_y(i16* %0, i8* %1, i32 %4)
%6 = zext i32 %2 to i64
%7 = getelementptr inbounds i16, i16* %0, i64 %6
%8 = getelementptr inbounds i8, i8* %1, i64 %6
%9 = lshr i32 %2, 4
%10 = tail call i32 @pixel_pack_s16u8_uv(i16* %7, i8* %8, i32 %9)
ret void
}
/* Variables and functions */
char *libamg_sip_get_session_timers_refresher_name(
    int session_timers_refresher_code) {
  switch (session_timers_refresher_code) {
  case 0x2:
    return "uac";
    break;
  case 0x1:
    return "uas";
    break;
  default:
    return NULL;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<libamg_sip_get_session_timers_refresher_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     113c <libamg_sip_get_session_timers_refresher_name+0x3c>
jmp    111b <libamg_sip_get_session_timers_refresher_name+0x1b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
jne    114c <libamg_sip_get_session_timers_refresher_name+0x4c>
jmp    112c <libamg_sip_get_session_timers_refresher_name+0x2c>
lea    0xecd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1154 <libamg_sip_get_session_timers_refresher_name+0x54>
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1154 <libamg_sip_get_session_timers_refresher_name+0x54>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<libamg_sip_get_session_timers_refresher_name>:
xor    %ecx,%ecx
cmp    $0x1,%edi
lea    0xef8(%rip),%rax
cmove  %rax,%rcx
cmp    $0x2,%edi
lea    0xee6(%rip),%rax
cmovne %rcx,%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"uac\00"
@.str.1 = [4 x i8] c"uas\00"
define i8* @libamg_sip_get_session_timers_refresher_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %7 [
i32 2, label %5
i32 1, label %6
]
5: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %8
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %8
7: ; preds = %1
store i8* null, i8** %2
br label %8
8: ; preds = %7, %6, %5
%9 = load i8*, i8** %2
ret i8* %9
}

LLVM IR (-O2):
@.str = [4 x i8] c"uac\00"
@.str.1 = [4 x i8] c"uas\00"
define i8* @libamg_sip_get_session_timers_refresher_name(i32 %0) {
%2 = icmp eq i32 %0, 1
%3 = select i1 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* null
%4 = icmp eq i32 %0, 2
%5 = select i1 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3
ret i8* %5
}
/* Type definitions */
struct hostent {
  int dummy;
};
typedef enum nss_status { ____Placeholder_nss_status } nss_status;

/* Variables and functions */
int NSS_STATUS_UNAVAIL;
enum nss_status _nss_hostslocal_gethostbyaddr_r(const void *addr, int len,
                                                int af, struct hostent *result,
                                                char *buffer, size_t buflen,
                                                int *errnop, int *h_errnop) {
  enum nss_status status = NSS_STATUS_UNAVAIL;
  return status;
}


x86 assembly (clang, -O0):
<_nss_hostslocal_gethostbyaddr_r>:
push   %rbp
mov    %rsp,%rbp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    0x2ebf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nss_hostslocal_gethostbyaddr_r>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
@NSS_STATUS_UNAVAIL = global i32 0
define i32 @_nss_hostslocal_gethostbyaddr_r(i8* %0, i32 %1, i32 %2, %struct.hostent* %3, i8* %4, i64 %5, i32* %6, i32* %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.hostent*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store %struct.hostent* %3, %struct.hostent** %12
store i8* %4, i8** %13
store i64 %5, i64* %14
store i32* %6, i32** %15
store i32* %7, i32** %16
%18 = load i32, i32* @NSS_STATUS_UNAVAIL
store i32 %18, i32* %17
%19 = load i32, i32* %17
ret i32 %19
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
@NSS_STATUS_UNAVAIL = global i32 0
define i32 @_nss_hostslocal_gethostbyaddr_r(i8* nocapture readnone %0, i32 %1, i32 %2, %struct.hostent* nocapture readnone %3, i8* nocapture readnone %4, i64 %5, i32* nocapture readnone %6, i32* nocapture readnone %7) {
%9 = load i32, i32* @NSS_STATUS_UNAVAIL
ret i32 %9
}
int isvalidipaddress(const char *st) {
  st = st;
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @isvalidipaddress(i8* nocapture readnone %0) {
ret i32 0
}
int fix_cond(int flg) {
  if (flg > 0) {
    return 1;
  } else if (flg < 0) {
    return -1;
  };
  return 0;
}


x86 assembly (clang, -O0):
<fix_cond>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    111d <fix_cond+0x1d>
movl   $0x1,-0x4(%rbp)
jmp    113f <fix_cond+0x3f>
cmpl   $0x0,-0x8(%rbp)
jge    1133 <fix_cond+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    113f <fix_cond+0x3f>
jmp    1138 <fix_cond+0x38>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_cond>:
mov    %edi,%ecx
sar    $0x1f,%ecx
test   %edi,%edi
mov    $0x1,%eax
cmovle %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @fix_cond(i32 %0) {
%2 = ashr i32 %0, 31
%3 = icmp slt i32 %0, 1
%4 = select i1 %3, i32 %2, i32 1
ret i32 %4
}
int isprime(int n) {
  int factor = 3;
  if (n == 2) {
    return 1;
  }
  if ((n % 2) == 0) {
    return 0;
  }
  while (factor * factor < n) {
    if ((n % factor) == 0) {
      return 0;
    }
    factor += 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isprime>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1124 <isprime+0x24>
movl   $0x1,-0x4(%rbp)
jmp    118a <isprime+0x8a>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1144 <isprime+0x44>
movl   $0x0,-0x4(%rbp)
jmp    118a <isprime+0x8a>
jmp    1149 <isprime+0x49>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1183 <isprime+0x83>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1175 <isprime+0x75>
movl   $0x0,-0x4(%rbp)
jmp    118a <isprime+0x8a>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <isprime+0x49>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isprime>:
mov    $0x1,%ecx
cmp    $0x2,%edi
je     1135 <isprime+0x35>
test   $0x1,%dil
jne    1114 <isprime+0x14>
xor    %ecx,%ecx
jmp    1135 <isprime+0x35>
cmp    $0xa,%edi
jl     1135 <isprime+0x35>
mov    $0x3,%esi
xchg   %ax,%ax
mov    %edi,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1110 <isprime+0x10>
add    $0x2,%esi
mov    %esi,%eax
imul   %esi,%eax
cmp    %edi,%eax
jl     1120 <isprime+0x20>
mov    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @isprime(i32 %0) {
%2 = icmp eq i32 %0, 2
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = and i32 %0, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = icmp sgt i32 %0, 9
br i1 %7, label %11, label %16
8: ; preds = %11
%9 = mul nsw i32 %15, %15
%10 = icmp slt i32 %9, %0
br i1 %10, label %11, label %16
11: ; preds = %6, %8
%12 = phi i32 [ %15, %8 ], [ 3, %6 ]
%13 = srem i32 %0, %12
%14 = icmp eq i32 %13, 0
%15 = add nuw nsw i32 %12, 2
br i1 %14, label %16, label %8
16: ; preds = %11, %8, %6, %3, %1
%17 = phi i32 [ 1, %1 ], [ 0, %3 ], [ 1, %6 ], [ 0, %11 ], [ 1, %8 ]
ret i32 %17
}
/* Variables and functions */
int /*<<< orphan*/ mouseshow();
int /*<<< orphan*/ pushNumber(int /*<<< orphan*/);
void basMouseShow() { pushNumber(mouseshow()); }


x86 assembly (clang, -O0):
<basMouseShow>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <mouseshow@plt>
mov    %eax,%edi
call   1040 <pushNumber@plt>
pop    %rbp
ret

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

LLVM IR (-O0):
define void @basMouseShow() {
%1 = call i32 (...) @mouseshow()
%2 = call i32 @pushNumber(i32 %1)
ret void
}

LLVM IR (-O2):
define void @basMouseShow() {
%1 = tail call i32 (...) @mouseshow()
%2 = tail call i32 @pushNumber(i32 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test(int);
int main(int argc, char *argv[]) {
  printf("test-");
  test(42);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2a,%edi
call   1040 <test@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2a,%edi
call   1040 <test@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"test-\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @test(i32 42)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const);
int main() {
  const int LENGTH = 10;
  const int WIDTH = 5;
  const char NEWLINE = '\n';
  int area;
  area = LENGTH * WIDTH;
  printf("Value of area : %d", area);
  printf("%c", NEWLINE);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
movb   $0xa,-0xd(%rbp)
movl   $0x32,-0x14(%rbp)
mov    -0x14(%rbp),%eax
lea    0xebe(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x32,%esi
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Value of area : %d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 5, i32* %3
store i8 10, i8* %4
store i32 50, i32* %5
%6 = load i32, i32* %5
%7 = trunc i32 %6 to i8
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Value of area : %d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext 50)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext 10)
ret i32 0
}
/* Type definitions */
typedef int int32_t;

/* Variables and functions */
int32_t rol(int32_t x, int i) { return (x << i) | (x >> (32 - i)); }


x86 assembly (clang, -O0):
<rol>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    %cl,%eax
mov    -0x4(%rbp),%edx
mov    $0x20,%ecx
sub    -0x8(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rol>:
mov    %esi,%ecx
mov    %edi,%eax
shl    %cl,%eax
neg    %cl
sar    %cl,%edi
or     %edi,%eax
ret

LLVM IR (-O0):
define i32 @rol(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 = shl i32 %5, %6
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = sub nsw i32 32, %9
%11 = ashr i32 %8, %10
%12 = or i32 %7, %11
ret i32 %12
}

LLVM IR (-O2):
define i32 @rol(i32 %0, i32 %1) {
%3 = shl i32 %0, %1
%4 = sub nsw i32 32, %1
%5 = ashr i32 %0, %4
%6 = or i32 %5, %3
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ print_board();
int /*<<< orphan*/ printf(char *, char);
int rand();
int /*<<< orphan*/ update(char, char);
void artificial1(void) {
  char colors[] = "ABCDEFG";
  char color;
  color = colors[rand() % 7];
  printf("IA chose %c\n", color);
  update('^', color);
  print_board();
}


x86 assembly (clang, -O0):
<artificial1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x7,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x8(%rbp,%rax,1),%al
mov    %al,-0x9(%rbp)
lea    0xe95(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <printf@plt>
mov    $0x5e,%edi
movsbl -0x9(%rbp),%esi
call   1030 <update@plt>
mov    $0x0,%al
call   1050 <print_board@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<artificial1>:
push   %rbx
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
lea    0xe8a(%rip),%rcx
movsbl (%rax,%rcx,1),%ebx
lea    0xe87(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    $0x5e,%edi
mov    %ebx,%esi
call   1030 <update@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <print_board@plt>

LLVM IR (-O0):
@__const.artificial1.colors = [8 x i8] c"ABCDEFG\00"
@.str = [13 x i8] c"IA chose %c\0A\00"
define void @artificial1() {
%1 = alloca [8 x i8]
%2 = alloca i8
%3 = bitcast [8 x i8]* %1 to i8*
%4 = call i32 (...) @rand()
%5 = srem i32 %4, 7
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
store i8 %8, i8* %2
%9 = load i8, i8* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%11 = load i8, i8* %2
%12 = call i32 @update(i8 signext 94, i8 signext %11)
%13 = call i32 (...) @print_board()
ret void
}

LLVM IR (-O2):
@__const.artificial1.colors = [8 x i8] c"ABCDEFG\00"
@.str = [13 x i8] c"IA chose %c\0A\00"
define void @artificial1() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 7
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds [8 x i8], [8 x i8]* @__const.artificial1.colors, i64 0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%7 = tail call i32 @update(i8 signext 94, i8 signext %5)
%8 = tail call i32 (...) @print_board()
ret void
}
unsigned long long sumSelfPowers(int x) {
  unsigned long long power(int x, int y);
  unsigned long long lastTen = 0;
  while (x > 0) {
    lastTen += power(x, x);
    x--;
  }
  return lastTen % 10000000000;
}


x86 assembly (clang, -O0):
<sumSelfPowers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    114e <sumSelfPowers+0x3e>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <power@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1123 <sumSelfPowers+0x13>
mov    -0x10(%rbp),%rax
movabs $0x2540be400,%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumSelfPowers>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    115d <sumSelfPowers+0x4d>
mov    %edi,%ebx
xor    %r14d,%r14d
nopl   (%rax)
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <power@plt>
add    %rax,%r14
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1120 <sumSelfPowers+0x10>
movabs $0xdbe6fecebdedd5bf,%rcx
fe e6 db
mov    %r14,%rax
mul    %rcx
shr    $0x21,%rdx
movabs $0x2540be400,%rax
imul   %rdx,%rax
sub    %rax,%r14
jmp    1160 <sumSelfPowers+0x50>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @sumSelfPowers(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
store i64 0, i64* %3
br label %4
4: ; preds = %7, %1
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %2
%10 = call i64 @power(i32 %8, i32 %9)
%11 = load i64, i64* %3
%12 = add i64 %11, %10
store i64 %12, i64* %3
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
%16 = load i64, i64* %3
%17 = urem i64 %16, 10000000000
ret i64 %17
}

LLVM IR (-O2):
define i64 @sumSelfPowers(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %12
3: ; preds = %1, %3
%4 = phi i64 [ %7, %3 ], [ 0, %1 ]
%5 = phi i32 [ %8, %3 ], [ %0, %1 ]
%6 = tail call i64 @power(i32 %5, i32 %5)
%7 = add i64 %6, %4
%8 = add nsw i32 %5, -1
%9 = icmp ugt i32 %5, 1
br i1 %9, label %3, label %10
10: ; preds = %3
%11 = urem i64 %7, 10000000000
br label %12
12: ; preds = %10, %1
%13 = phi i64 [ 0, %1 ], [ %11, %10 ]
ret i64 %13
}
/* Variables and functions */
scalar_t__ malloc(int);
int *test() {
  int *a2 = (int *)malloc(sizeof(int));
  return a2;
}


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

x86 assembly (clang, -O2):
<test>:
mov    $0x4,%edi
jmp    1030 <malloc@plt>

LLVM IR (-O0):
define i32* @test() {
%1 = alloca i32*
%2 = call i64 @malloc(i32 4)
%3 = inttoptr i64 %2 to i32*
store i32* %3, i32** %1
%4 = load i32*, i32** %1
ret i32* %4
}

LLVM IR (-O2):
define i32* @test() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to i32*
ret i32* %2
}