xunge/DecIR huggingface dataset:
void some_other_function(union a_union *u) {}


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

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

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

LLVM IR (-O2):
%union.a_union = type opaque
define void @some_other_function(%union.a_union* nocapture %0) {
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ version;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int);
const char *ulib_version() {
  static char version[256] = {0};
  snprintf(version, sizeof(version),
           "ULIB %d.%d\n"
           "Copyright (C) 2009-2012 Zilong Tan (eric.zltan@gmail.com)\n",
           1, 2);
  return version;
}


x86 assembly (clang, -O0):
<ulib_version>:
push   %rbp
mov    %rsp,%rbp
lea    0x2f25(%rip),%rdi
mov    $0x100,%esi
lea    0xed9(%rip),%rdx
mov    $0x1,%ecx
mov    $0x2,%r8d
call   1030 <snprintf@plt>
lea    0x2f02(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ulib_version>:
push   %rbx
lea    0x2f28(%rip),%rbx
lea    0xee1(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    $0x1,%ecx
mov    $0x2,%r8d
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@ulib_version.version = internal global [256 x i8] zeroinitializer
@.str = [70 x i8] c"ULIB %d.%d\0ACopyright (C) 2009-2012 Zilong Tan (eric.zltan@gmail.com)\0A\00"
define i8* @ulib_version() {
%1 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @ulib_version.version, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @ulib_version.version, i64 0, i64 0)
}

LLVM IR (-O2):
@ulib_version.version = internal global [256 x i8] zeroinitializer
@.str = [70 x i8] c"ULIB %d.%d\0ACopyright (C) 2009-2012 Zilong Tan (eric.zltan@gmail.com)\0A\00"
define i8* @ulib_version() {
%1 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @ulib_version.version, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @ulib_version.version, i64 0, i64 0)
}
/* Variables and functions */
int /*<<< orphan*/ init_libretro_cbs_plain();
void init_libretro_cbs(void) { init_libretro_cbs_plain(); }


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

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

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

LLVM IR (-O2):
define void @init_libretro_cbs() {
%1 = tail call i32 (...) @init_libretro_cbs_plain()
ret void
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
uint32_t __hsail_bitmask_u32(uint32_t src0, uint32_t src1) {
  uint32_t offset = src0 & (sizeof(uint32_t) * 8 - 1);
  uint32_t width = src1 & (sizeof(uint32_t) * 8 - 1);
  uint32_t mask = ((uint32_t)1 << width) - 1;
  return mask << offset;
}


x86 assembly (clang, -O0):
<__hsail_bitmask_u32>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
and    $0x1f,%rax
mov    %eax,-0xc(%rbp)
movslq -0x8(%rbp),%rax
and    $0x1f,%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__hsail_bitmask_u32>:
mov    %esi,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
not    %eax
mov    %edi,%ecx
shl    %cl,%eax
ret

LLVM IR (-O0):
define i32 @__hsail_bitmask_u32(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = and i64 %9, 31
%11 = trunc i64 %10 to i32
store i32 %11, i32* %5
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = and i64 %13, 31
%15 = trunc i64 %14 to i32
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = shl i32 1, %16
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = load i32, i32* %5
%21 = shl i32 %19, %20
ret i32 %21
}

LLVM IR (-O2):
define i32 @__hsail_bitmask_u32(i32 %0, i32 %1) {
%3 = and i32 %0, 31
%4 = and i32 %1, 31
%5 = shl nsw i32 -1, %4
%6 = xor i32 %5, -1
%7 = shl i32 %6, %3
ret i32 %7
}
/* Variables and functions */
int rearrange_stdio(int, int, int);
int make_null_stdio(void) { return rearrange_stdio(-1, -1, -1); }


x86 assembly (clang, -O0):
<make_null_stdio>:
push   %rbp
mov    %rsp,%rbp
mov    $0xffffffff,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1030 <rearrange_stdio@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_null_stdio>:
mov    $0xffffffff,%edi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
jmp    1030 <rearrange_stdio@plt>

LLVM IR (-O0):
define i32 @make_null_stdio() {
%1 = call i32 @rearrange_stdio(i32 -1, i32 -1, i32 -1)
ret i32 %1
}

LLVM IR (-O2):
define i32 @make_null_stdio() {
%1 = tail call i32 @rearrange_stdio(i32 -1, i32 -1, i32 -1)
ret i32 %1
}
void substring(char *dest, const char __source[], int begin, int end) {
  sprintf(dest, "%.*s", end - begin, &__source[begin]);
  strcat(dest, "\0");
}


x86 assembly (clang, -O0):
<substring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rax
add    %rax,%rcx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substring>:
sub    %edx,%ecx
movslq %edx,%rax
add    %rsi,%rax
lea    0xee1(%rip),%rsi
mov    %ecx,%edx
mov    %rax,%rcx
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%.*s\00"
@.str.1 = [2 x i8] zeroinitializer
define void @substring(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = sub nsw i32 %10, %11
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %16)
%18 = load i8*, i8** %5
%19 = call i8* @strcat(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.*s\00"
define void @substring(i8* nocapture writeonly %0, i8* %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %3, %2
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %7)
ret void
}
int str_cmp(const char *p, const char *t) {
  for (; *p == *t; p++, t++)
    if (*p == '\0')
      return 0;
  return *p - *t;
}


x86 assembly (clang, -O0):
<str_cmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1160 <str_cmp+0x60>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113e <str_cmp+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    1173 <str_cmp+0x73>
jmp    1143 <str_cmp+0x43>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    110c <str_cmp+0xc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_cmp>:
mov    (%rdi),%al
mov    (%rsi),%cl
cmp    %cl,%al
jne    1124 <str_cmp+0x24>
mov    $0x1,%edx
nopl   (%rax)
test   %al,%al
je     112d <str_cmp+0x2d>
movzbl (%rdi,%rdx,1),%eax
movzbl (%rsi,%rdx,1),%ecx
add    $0x1,%rdx
cmp    %cl,%al
je     1110 <str_cmp+0x10>
movsbl %al,%eax
movsbl %cl,%ecx
sub    %ecx,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @str_cmp(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %17
6: ; preds = %2, %11
%7 = phi i8 [ %14, %11 ], [ %3, %2 ]
%8 = phi i8* [ %13, %11 ], [ %1, %2 ]
%9 = phi i8* [ %12, %11 ], [ %0, %2 ]
%10 = icmp eq i8 %7, 0
br i1 %10, label %23, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %12
%15 = load i8, i8* %13
%16 = icmp eq i8 %14, %15
br i1 %16, label %6, label %17
17: ; preds = %11, %2
%18 = phi i8 [ %3, %2 ], [ %14, %11 ]
%19 = phi i8 [ %4, %2 ], [ %15, %11 ]
%20 = sext i8 %18 to i32
%21 = sext i8 %19 to i32
%22 = sub nsw i32 %20, %21
br label %23
23: ; preds = %6, %17
%24 = phi i32 [ %22, %17 ], [ 0, %6 ]
ret i32 %24
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, long);
long factorial(long number) {
  long i;
  if (number <= 1) {
    return 1;
  } else {
    i = number * factorial(number - 1);
    printf("\t\t**%ld**\n", i);
    return i;
  }
}


x86 assembly (clang, -O0):
<factorial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jg     1144 <factorial+0x24>
movq   $0x1,-0x8(%rbp)
jmp    1180 <factorial+0x60>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
call   1030 <factorial@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorial>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x1,%rdi
jle    1151 <factorial+0x31>
mov    %rdi,%r14
add    $0xffffffffffffffff,%rdi
call   1030 <factorial@plt>
mov    %rax,%rbx
imul   %r14,%rbx
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"\09\09**%ld**\0A\00"
define i64 @factorial(i64 %0) {
%2 = icmp slt i64 %0, 2
br i1 %2, label %3, label %5
3: ; preds = %1, %5
%4 = phi i64 [ %8, %5 ], [ 1, %1 ]
ret i64 %4
5: ; preds = %1
%6 = add nsw i64 %0, -1
%7 = tail call i64 @factorial(i64 %6)
%8 = mul nsw i64 %7, %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %8)
br label %3
}
/* Variables and functions */
int isQualifiedDevice(char const **, char *);
int isBluetoothDevice(const char **identifier) {
  return isQualifiedDevice(identifier, "bluetooth");
}


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

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

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

LLVM IR (-O2):
@.str = [10 x i8] c"bluetooth\00"
define i32 @isBluetoothDevice(i8** %0) {
%2 = tail call i32 @isQualifiedDevice(i8** %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret i32 %2
}
const char *deviceSonarGetName() { return "sonar"; }


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

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

LLVM IR (-O0):
@.str = [6 x i8] c"sonar\00"
define i8* @deviceSonarGetName() {
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [6 x i8] c"sonar\00"
define i8* @deviceSonarGetName() {
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
}
char *invoker(s)
register char *s;
{
  register int k;
  k = strlen(s);
  while (k--)
    if (s[k] == '/') {
      s += k;
      ++s;
      break;
    }
  return (s);
}


x86 assembly (clang, -O0):
<invoker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1178 <invoker+0x68>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1173 <invoker+0x63>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1178 <invoker+0x68>
jmp    1128 <invoker+0x18>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invoker>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    %rcx,%rax
nop
sub    $0x1,%rax
jb     1137 <invoker+0x27>
cmpb   $0x2f,-0x1(%rbx,%rcx,1)
mov    %rax,%rcx
jne    1120 <invoker+0x10>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @invoker(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = shl i64 %2, 32
%4 = ashr exact i64 %3, 32
br label %5
5: ; preds = %9, %1
%6 = phi i64 [ %7, %9 ], [ %4, %1 ]
%7 = add nsw i64 %6, -1
%8 = icmp eq i64 %6, 0
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 %7
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 47
br i1 %12, label %13, label %5
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %0, i64 %6
br label %15
15: ; preds = %5, %13
%16 = phi i8* [ %14, %13 ], [ %0, %5 ]
ret i8* %16
}
/* Variables and functions */
int fib(int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *);
int main() {
  int n = 0, res = 0;
  res = scanf("%d", &n);
  printf("%d", fib(n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <fib@plt>
mov    %eax,%esi
lea    0xe8f(%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
movl   $0x0,0xc(%rsp)
lea    0xebc(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
call   1050 <fib@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %2
%6 = call i32 @fib(i32 %5)
%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*
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @fib(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
int /*<<< orphan*/ stderr;
int usage(char const *prog_name) {
  fprintf(stderr, "[ERROR] %s: Usage: %s /path/to/optical/device\n", prog_name,
          prog_name);
  return 0;
}


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

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    %rdi,%rcx
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
mov    %rcx,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"[ERROR] %s: Usage: %s /path/to/optical/device\0A\00"
define i32 @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"[ERROR] %s: Usage: %s /path/to/optical/device\0A\00"
define i32 @usage(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %0)
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ pthread_attr_t;
typedef int /*<<< orphan*/ cs;
typedef int /*<<< orphan*/ cpu_set_t;

/* Variables and functions */
int /*<<< orphan*/ CPU_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_attr_init(int /*<<< orphan*/ *);
int pthread_attr_setaffinity_np(int /*<<< orphan*/ *, int,
                                int /*<<< orphan*/ *);
int main(void) {
  int ret = 0;
  pthread_attr_t thread_attr;
  cpu_set_t cs;
  pthread_attr_init(&thread_attr);
  CPU_ZERO(&cs);
  ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <pthread_attr_init@plt>
lea    -0x10(%rbp),%rdi
call   1050 <CPU_ZERO@plt>
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
lea    -0x10(%rbp),%rdx
call   1030 <pthread_attr_setaffinity_np@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <pthread_attr_init@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <CPU_ZERO@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1030 <pthread_attr_setaffinity_np@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 @pthread_attr_init(i32* %3)
%6 = call i32 @CPU_ZERO(i32* %4)
%7 = call i32 @pthread_attr_setaffinity_np(i32* %3, i32 4, i32* %4)
store i32 %7, i32* %2
%8 = load i32, i32* %2
ret i32 %8
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @pthread_attr_init(i32* %1)
%6 = call i32 @CPU_ZERO(i32* %2)
%7 = call i32 @pthread_attr_setaffinity_np(i32* %1, i32 4, i32* %2)
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  printf("Hello, World!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed3(%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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = 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(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}
int main(int argc, char *argv[]) {
  int i;
  for (i = 0; i < 10; i++) {
    int j;
    j = i;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1137 <main+0x37>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1119 <main+0x19>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
ret i32 0
}
int test_imm_ACuint8_mem(unsigned char *val) {
  return ((*val) & (0xAC << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_ACuint8_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edx
and    $0xac,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_ACuint8_mem>:
testb  $0xac,(%rdi)
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_ACuint8_mem(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = and i32 %5, 172
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i32 -20, i32 -40
ret i32 %9
}

LLVM IR (-O2):
define i32 @test_imm_ACuint8_mem(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = and i8 %2, -84
%4 = icmp eq i8 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ S6D2101_ExitEightColorMode();
int /*<<< orphan*/ S6D2101_ExitInternalMode();
int /*<<< orphan*/ WriteLDI_LTE246(int, int);
int /*<<< orphan*/ mdelay(int);
void S6D2101_ExitWindowScreenInternalEightColorMode(void) {
  S6D2101_ExitEightColorMode();
  WriteLDI_LTE246(0x44, 0xef00);
  mdelay(40);
  S6D2101_ExitInternalMode();
}


x86 assembly (clang, -O0):
<S6D2101_ExitWindowScreenInternalEightColorMode>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <S6D2101_ExitEightColorMode@plt>
mov    $0x44,%edi
mov    $0xef00,%esi
call   1050 <WriteLDI_LTE246@plt>
mov    $0x28,%edi
call   1030 <mdelay@plt>
mov    $0x0,%al
call   1060 <S6D2101_ExitInternalMode@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<S6D2101_ExitWindowScreenInternalEightColorMode>:
push   %rax
xor    %eax,%eax
call   1040 <S6D2101_ExitEightColorMode@plt>
mov    $0x44,%edi
mov    $0xef00,%esi
call   1050 <WriteLDI_LTE246@plt>
mov    $0x28,%edi
call   1030 <mdelay@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <S6D2101_ExitInternalMode@plt>

LLVM IR (-O0):
define void @S6D2101_ExitWindowScreenInternalEightColorMode() {
%1 = call i32 (...) @S6D2101_ExitEightColorMode()
%2 = call i32 @WriteLDI_LTE246(i32 68, i32 61184)
%3 = call i32 @mdelay(i32 40)
%4 = call i32 (...) @S6D2101_ExitInternalMode()
ret void
}

LLVM IR (-O2):
define void @S6D2101_ExitWindowScreenInternalEightColorMode() {
%1 = tail call i32 (...) @S6D2101_ExitEightColorMode()
%2 = tail call i32 @WriteLDI_LTE246(i32 68, i32 61184)
%3 = tail call i32 @mdelay(i32 40)
%4 = tail call i32 (...) @S6D2101_ExitInternalMode()
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
void eraseFile(const char *fileName) {
  FILE *pf;
  pf = fopen(fileName, "w+");
  fclose(pf);
}


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

x86 assembly (clang, -O2):
<eraseFile>:
push   %rax
lea    0xed8(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rdi
pop    %rax
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"w+\00"
define void @eraseFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @fclose(i32* %6)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"w+\00"
define void @eraseFile(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @fclose(i32* %2)
ret void
}
/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
char *line_reading();
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char *line = line_reading();
  printf("%s\n", line);
  free(line);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <line_reading@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <line_reading@plt>
mov    %rax,%rbx
lea    0xebe(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i8* (...) @line_reading()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = tail call i32 @free(i8* %1)
%4 = load i32, i32* @EXIT_SUCCESS
ret i32 %4
}
/* 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 = [14 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 ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [13 x i8] c"Hello World!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Type definitions */
struct timeval {
  scalar_t__ tv_usec;
};

/* Variables and functions */
scalar_t__ getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(unsigned int);
void randomize() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  srand(((unsigned int)(tv.tv_usec)) ^ ((unsigned int)getpid()));
}


x86 assembly (clang, -O0):
<randomize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%rax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%edi
xor    %eax,%edi
call   1050 <srand@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x8(%rsp),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
xor    %eax,%ebx
mov    %ebx,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <srand@plt>

LLVM IR (-O0):
%struct.timeval = type { i64 }
define void @randomize() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%4 = load i64, i64* %3
%5 = trunc i64 %4 to i32
%6 = call i64 (...) @getpid()
%7 = trunc i64 %6 to i32
%8 = xor i32 %5, %7
%9 = call i32 @srand(i32 %8)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
define void @randomize() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = tail call i64 (...) @getpid()
%7 = xor i64 %6, %5
%8 = trunc i64 %7 to i32
%9 = tail call i32 @srand(i32 %8)
ret void
}
int loadbychar(int ch) {
  switch (ch) {
  case 'r':
    return 3;
  case 'g':
    return 1;
  case 'c':
    return 2;
  case 'd':
    return 4;
  }
  return 3;
}


x86 assembly (clang, -O0):
<loadbychar>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xf,%eax
ja     1160 <loadbychar+0x60>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x3,-0x4(%rbp)
jmp    1167 <loadbychar+0x67>
movl   $0x1,-0x4(%rbp)
jmp    1167 <loadbychar+0x67>
movl   $0x2,-0x4(%rbp)
jmp    1167 <loadbychar+0x67>
movl   $0x4,-0x4(%rbp)
jmp    1167 <loadbychar+0x67>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadbychar>:
add    $0xffffff9d,%edi
mov    $0x3,%eax
cmp    $0x4,%edi
ja     111a <loadbychar+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @loadbychar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %9 [
i32 114, label %5
i32 103, label %6
i32 99, label %7
i32 100, label %8
]
5: ; preds = %1
store i32 3, i32* %2
br label %10
6: ; preds = %1
store i32 1, i32* %2
br label %10
7: ; preds = %1
store i32 2, i32* %2
br label %10
8: ; preds = %1
store i32 4, i32* %2
br label %10
9: ; preds = %1
store i32 3, i32* %2
br label %10
10: ; preds = %9, %8, %7, %6, %5
%11 = load i32, i32* %2
ret i32 %11
}

LLVM IR (-O2):
@switch.table.loadbychar = [5 x i32] [i32 2, i32 4, i32 3, i32 3, i32 1]
define i32 @loadbychar(i32 %0) {
%2 = add i32 %0, -99
%3 = icmp ult i32 %2, 5
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.loadbychar, i64 0, i64 %5
%7 = load i32, i32* %6
br label %8
8: ; preds = %4, %1
%9 = phi i32 [ 3, %1 ], [ %7, %4 ]
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int syscall_rand(int);
int main() {
  int i, r = 0;
  for (; i < 40; ++i) {
    r = syscall_rand(i);
    printf("syscall_rand(%d): %d\n", i, r);
    if (r >= i) {
      printf("ERROR: random is over range.");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    118c <main+0x6c>
mov    -0x8(%rbp),%edi
call   1040 <syscall_rand@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1179 <main+0x59>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117e <main+0x5e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ _send_char_report(int, int, int);
void send_char_raw_report(int ch, int mod) { _send_char_report(ch, mod, 2); }


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

x86 assembly (clang, -O2):
<send_char_raw_report>:
mov    $0x2,%edx
jmp    1030 <_send_char_report@plt>

LLVM IR (-O0):
define void @send_char_raw_report(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 @_send_char_report(i32 %5, i32 %6, i32 2)
ret void
}

LLVM IR (-O2):
define void @send_char_raw_report(i32 %0, i32 %1) {
%3 = tail call i32 @_send_char_report(i32 %0, i32 %1, i32 2)
ret void
}
void test2(int foo) {
  enum { a = 10, b = 15 } moe;
  int bar;
  printf("%s\n", bar);
  printf("%s%s\n", "bar");
  printf("%s\n", "bar", "bar");
  switch (moe) {
  case a:
    return;
  }
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0xc(%rbp),%esi
lea    0xedd(%rip),%rdi
mov    %rdi,-0x20(%rbp)
xor    %eax,%eax
mov    %al,-0xd(%rbp)
call   1030 <printf@plt>
mov    -0xd(%rbp),%al
lea    0xec3(%rip),%rdi
lea    0xec2(%rip),%rsi
mov    %rsi,-0x18(%rbp)
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0xd(%rbp),%al
mov    %rdx,%rsi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0xa,%eax
jne    1176 <test2+0x66>
jmp    1171 <test2+0x61>
jmp    1176 <test2+0x66>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
push   %rbx
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xec9(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [6 x i8] c"%s%s\0A\00"
@.str.2 = [4 x i8] c"bar\00"
define void @test2(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 undef)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}
/* Type definitions */
struct ioctl_entry {
  int dummy;
};
struct ioctl_args {
  int dummy;
};

/* Variables and functions */
int do_get_ioctl_int(struct ioctl_args *, struct ioctl_entry *);
int get_scan_period(struct ioctl_args *args, struct ioctl_entry *entry) {
  return do_get_ioctl_int(args, entry);
}


x86 assembly (clang, -O0):
<get_scan_period>:
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 <do_get_ioctl_int@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_scan_period>:
jmp    1030 <do_get_ioctl_int@plt>

LLVM IR (-O0):
%struct.ioctl_args = type { i32 }
%struct.ioctl_entry = type { i32 }
define i32 @get_scan_period(%struct.ioctl_args* %0, %struct.ioctl_entry* %1) {
%3 = alloca %struct.ioctl_args*
%4 = alloca %struct.ioctl_entry*
store %struct.ioctl_args* %0, %struct.ioctl_args** %3
store %struct.ioctl_entry* %1, %struct.ioctl_entry** %4
%5 = load %struct.ioctl_args*, %struct.ioctl_args** %3
%6 = load %struct.ioctl_entry*, %struct.ioctl_entry** %4
%7 = call i32 @do_get_ioctl_int(%struct.ioctl_args* %5, %struct.ioctl_entry* %6)
ret i32 %7
}

LLVM IR (-O2):
%struct.ioctl_args = type { i32 }
%struct.ioctl_entry = type { i32 }
define i32 @get_scan_period(%struct.ioctl_args* %0, %struct.ioctl_entry* %1) {
%3 = tail call i32 @do_get_ioctl_int(%struct.ioctl_args* %0, %struct.ioctl_entry* %1)
ret i32 %3
}
int cpuid_ecx(int op) {
  int eax, ecx = 0, edx;
  __asm__("pushq %%rbx\n\tcpuid\n\tpopq %%rbx"
          : "=a"(eax), "+c"(ecx), "=d"(edx)
          : "a"(op));
  return ecx;
}


x86 assembly (clang, -O0):
<cpuid_ecx>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
push   %rbx
cpuid
pop    %rbx
mov    %eax,-0x8(%rbp)
mov    %ecx,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuid_ecx>:
mov    %edi,%eax
xor    %ecx,%ecx
push   %rbx
cpuid
pop    %rbx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @cpuid_ecx(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = call { i32, i32, i32 } asm "pushq %rbx\0A\09cpuid\0A\09popq %rbx", "={ax},={cx},={dx},{ax},1,~{dirflag},~{fpsr},~{flags}"(i32 %7, i32 %6)
%9 = extractvalue { i32, i32, i32 } %8, 0
%10 = extractvalue { i32, i32, i32 } %8, 1
%11 = extractvalue { i32, i32, i32 } %8, 2
store i32 %9, i32* %3
store i32 %10, i32* %4
store i32 %11, i32* %5
%12 = load i32, i32* %4
ret i32 %12
}

LLVM IR (-O2):
define i32 @cpuid_ecx(i32 %0) {
%2 = tail call { i32, i32, i32 } asm "pushq %rbx\0A\09cpuid\0A\09popq %rbx", "={ax},={cx},={dx},{ax},1,~{dirflag},~{fpsr},~{flags}"(i32 %0, i32 0)
%3 = extractvalue { i32, i32, i32 } %2, 1
ret i32 %3
}
int execute_set_thread_area() { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @execute_set_thread_area() {
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
unsigned long ERR_get_error();
int RAND_bytes(unsigned char *, int);
int /*<<< orphan*/ printf(char *, unsigned char);
unsigned char getRandomByte() {
  unsigned char buffer;
  unsigned long err;
  int rc;
  rc = RAND_bytes(&buffer, sizeof(buffer));
  err = ERR_get_error();
  if (rc != 1) {
  }
  printf("random byte: %c", buffer);
  return buffer;
}


x86 assembly (clang, -O0):
<getRandomByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x1(%rbp),%rdi
mov    $0x1,%esi
call   1030 <RAND_bytes@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <ERR_get_error@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1163 <getRandomByte+0x33>
jmp    1163 <getRandomByte+0x33>
lea    0xe96(%rip),%rdi
movzbl -0x1(%rbp),%esi
call   1040 <printf@plt>
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRandomByte>:
push   %rax
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
call   1030 <RAND_bytes@plt>
xor    %eax,%eax
call   1050 <ERR_get_error@plt>
movzbl 0x7(%rsp),%esi
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
mov    0x7(%rsp),%al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"random byte: %c\00"
define zeroext i8 @getRandomByte() {
%1 = alloca i8
%2 = alloca i64
%3 = alloca i32
%4 = call i32 @RAND_bytes(i8* %1, i32 1)
store i32 %4, i32* %3
%5 = call i64 (...) @ERR_get_error()
store i64 %5, i64* %2
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
br label %9
9: ; preds = %8, %0
%10 = load i8, i8* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = load i8, i8* %1
ret i8 %12
}

LLVM IR (-O2):
@.str = [16 x i8] c"random byte: %c\00"
define zeroext i8 @getRandomByte() {
%1 = alloca i8
%2 = call i32 @RAND_bytes(i8* %1, i32 1)
%3 = call i64 (...) @ERR_get_error()
%4 = load i8, i8* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 zeroext %4)
%6 = load i8, i8* %1
ret i8 %6
}
/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ plazaui_destroy();
void term_handler(int signum) {
  plazaui_destroy();
  exit(0);
}


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

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

LLVM IR (-O0):
define void @term_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @plazaui_destroy()
%4 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define void @term_handler(i32 %0) {
%2 = tail call i32 (...) @plazaui_destroy()
%3 = tail call i32 @exit(i32 0)
unreachable
}
/* Type definitions */
struct Var {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ pA(char *, char const *, char const *, char const *,
                      char const *);
void __func_eq_sint(struct Var *avar, const char *areg, const char *lreg,
                    const char *rreg) {
  pA("if (%s == %s) {%s = 1;} else {%s = 0;}", lreg, rreg, areg, areg);
}


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

x86 assembly (clang, -O2):
<__func_eq_sint>:
mov    %rsi,%r8
lea    0xee6(%rip),%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8,%rcx
jmp    1030 <pA@plt>

LLVM IR (-O0):
%struct.Var = type { i32 }
@.str = [39 x i8] c"if (%s == %s) {%s = 1;} else {%s = 0;}\00"
define void @__func_eq_sint(%struct.Var* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca %struct.Var*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.Var* %0, %struct.Var** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %7
%10 = load i8*, i8** %8
%11 = load i8*, i8** %6
%12 = load i8*, i8** %6
%13 = call i32 @pA(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i8* %11, i8* %12)
ret void
}

LLVM IR (-O2):
%struct.Var = type { i32 }
@.str = [39 x i8] c"if (%s == %s) {%s = 1;} else {%s = 0;}\00"
define void @__func_eq_sint(%struct.Var* nocapture readnone %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @pA(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* %1, i8* %1)
ret void
}