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

/* Variables and functions */
int _binary_search(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, int);
int binary_search(int *array, int val) {
  int len = sizeof(array) / sizeof(int);
  printf("Array length = %d\n", len);
  int pos = _binary_search(array, 0, len - 1, 5);
  printf("position of 5 is : %d\n", pos);
  return 0;
}


x86 assembly (clang, -O0):
<binary_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
mov    $0x5,%ecx
call   1040 <_binary_search@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary_search>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x5,%ecx
call   1040 <_binary_search@plt>
lea    0xec3(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Array length = %d\0A\00"
@.str.1 = [23 x i8] c"position of 5 is : %d\0A\00"
define i32 @binary_search(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 2, i32* %5
%7 = load i32, i32* %5
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32*, i32** %3
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1
%12 = call i32 @_binary_search(i32* %9, i32 0, i32 %11, i32 5)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Array length = %d\0A\00"
@.str.1 = [23 x i8] c"position of 5 is : %d\0A\00"
define i32 @binary_search(i32* %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 2)
%4 = tail call i32 @_binary_search(i32* %0, i32 0, i32 1, i32 5)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %4)
ret i32 0
}
/* Variables and functions */
size_t strlen(const char *s) {
  const char *eos = s;
  while (*eos++)
    ;
  return (int)(eos - s - 1);
}


x86 assembly (clang, -O0):
<strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,(%rax)
je     112d <strlen+0x2d>
jmp    1110 <strlen+0x10>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
cltq
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlen>:
movabs $0xffffffff00000000,%rax
ff ff ff
movabs $0x100000000,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %rcx,%rax
cmpb   $0x0,(%rdi)
lea    0x1(%rdi),%rdi
jne    1120 <strlen+0x20>
sar    $0x20,%rax
ret

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

LLVM IR (-O2):
define i64 @strlen(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %4, %2 ]
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %2
7: ; preds = %2
%8 = ptrtoint i8* %4 to i64
%9 = ptrtoint i8* %0 to i64
%10 = xor i64 %9, -1
%11 = add i64 %8, %10
%12 = shl i64 %11, 32
%13 = ashr exact i64 %12, 32
ret i64 %13
}
void __yotta_dummy_lib_symbol_minar_platform() {}


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

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

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

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

/* Variables and functions */
int /*<<< orphan*/ send_to_rsocket(int /*<<< orphan*/, void *,
                                   int /*<<< orphan*/, int /*<<< orphan*/);
int64_t send_to_socket(int64_t s, void *data, int64_t length) {
  return send_to_rsocket(s, data, length, 0);
}


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

x86 assembly (clang, -O2):
<send_to_socket>:
xor    %ecx,%ecx
jmp    1030 <send_to_rsocket@plt>

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

LLVM IR (-O2):
define i32 @send_to_socket(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @send_to_rsocket(i32 %0, i8* %1, i32 %2, i32 0)
ret i32 %4
}
int inc() { return 1; }


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

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

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

LLVM IR (-O2):
define i32 @inc() {
ret i32 1
}
extern char *strstr(const char *cs, const char *ct) {
  register char *__res __asm__("ax");
  __asm__("cld\n\t"
          "movl %4,%%edi\n\t"
          "repne\n\t"
          "scasb\n\t"
          "notl %%ecx\n\t"
          "decl %%ecx\n\t"
          "movl %%ecx,%%edx\n"
          "1:\tmovl %4,%%edi\n\t"
          "movl %%esi,%%eax\n\t"
          "movl %%edx,%%ecx\n\t"
          "repe\n\t"
          "cmpsb\n\t"
          "je 2f\n\t"
          "xchgl %%eax,%%esi\n\t"
          "incl %%esi\n\t"
          "cmpb $0,-1(%%eax)\n\t"
          "jne 1b\n\t"
          "xorl %%eax,%%eax\n\t"
          "2:"
          : "=a"(__res)
          : "0"(0), "c"(0xffffffff), "S"(cs), "g"(ct));
  return __res;
}


x86 assembly (clang, -O0):
<strstr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    $0xffffffff,%ecx
cld
mov    -0x20(%rbp),%edi
repnz scas %es:(%rdi),%al
not    %ecx
dec    %ecx
mov    %ecx,%edx
mov    -0x20(%rbp),%edi
mov    %esi,%eax
mov    %edx,%ecx
repz cmpsb %es:(%rdi),%ds:(%rsi)
je     114a <strstr+0x4a>
xchg   %eax,%esi
inc    %esi
cmpb   $0x0,-0x1(%eax)
jne    112b <strstr+0x2b>
xor    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
define i8* @strstr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i8* asm "cld\0A\09movl $4,%edi\0A\09repne\0A\09scasb\0A\09notl %ecx\0A\09decl %ecx\0A\09movl %ecx,%edx\0A1:\09movl $4,%edi\0A\09movl %esi,%eax\0A\09movl %edx,%ecx\0A\09repe\0A\09cmpsb\0A\09je 2f\0A\09xchgl %eax,%esi\0A\09incl %esi\0A\09cmpb $$0,-1(%eax)\0A\09jne 1b\0A\09xorl %eax,%eax\0A\092:", "={ax},0,{cx},{si},imr,~{dirflag},~{fpsr},~{flags}"(i64 0, i32 -1, i8* %6, i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
ret i8* %9
}

LLVM IR (-O2):
/* Variables and functions */
scalar_t__ term_putchar(char);
int term_puts(char *str) {
  for (; *str; ++str)
    if (term_putchar(*str))
      return -1;
  return 0;
}


x86 assembly (clang, -O0):
<term_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1161 <term_puts+0x51>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <term_putchar@plt>
cmp    $0x0,%rax
je     114b <term_puts+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1168 <term_puts+0x58>
jmp    1150 <term_puts+0x40>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    111c <term_puts+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_puts>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
xor    %ebp,%ebp
test   %al,%al
je     114f <term_puts+0x3f>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <term_putchar@plt>
test   %rax,%rax
jne    114a <term_puts+0x3a>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <term_puts+0x20>
jmp    114f <term_puts+0x3f>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @term_puts(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %15, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = call i64 @term_putchar(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 -1, i32* %2
br label %19
14: ; preds = %8
br label %15
15: ; preds = %14
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
br label %4
18: ; preds = %4
store i32 0, i32* %2
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @term_puts(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %7
4: ; preds = %7
%5 = load i8, i8* %12
%6 = icmp eq i8 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %1, %4
%8 = phi i8 [ %5, %4 ], [ %2, %1 ]
%9 = phi i8* [ %12, %4 ], [ %0, %1 ]
%10 = tail call i64 @term_putchar(i8 signext %8)
%11 = icmp eq i64 %10, 0
%12 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %11, label %4, label %13
13: ; preds = %7, %4, %1
%14 = phi i32 [ 0, %1 ], [ 0, %4 ], [ -1, %7 ]
ret i32 %14
}
int test_imm_E0int64_midword_mem(long long *val) {
  return ((*val >> 16) & (0xE0 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_E0int64_midword_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
sar    $0x10,%rdx
and    $0xe0,%rdx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @test_imm_E0int64_midword_mem(i64* %0) {
%2 = alloca i64*
store i64* %0, i64** %2
%3 = load i64*, i64** %2
%4 = load i64, i64* %3
%5 = ashr i64 %4, 16
%6 = and i64 %5, 224
%7 = icmp ne i64 %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_E0int64_midword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 14680064
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Type definitions */
typedef int uint32_t;
typedef int volatile int32_t;

/* Variables and functions */
int32_t UARTCharGetNonBlocking(uint32_t ui32Base) {
  ;
  if (!((*((volatile uint32_t *)(ui32Base + 0x00000018))) & 0x00000010)) {
    return ((*((volatile uint32_t *)(ui32Base + 0x00000000))));
  } else {
    return (-1);
  }
}


x86 assembly (clang, -O0):
<UARTCharGetNonBlocking>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x18,%eax
cltq
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
jne    112f <UARTCharGetNonBlocking+0x2f>
mov    -0x8(%rbp),%eax
add    $0x0,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1136 <UARTCharGetNonBlocking+0x36>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<UARTCharGetNonBlocking>:
movslq %edi,%rcx
mov    $0xffffffff,%eax
testl  $0x10,0x18(%rcx)
jne    1113 <UARTCharGetNonBlocking+0x13>
mov    (%rcx),%eax
ret

LLVM IR (-O0):
define i32 @UARTCharGetNonBlocking(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = add nsw i32 %4, 24
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = load volatile i32, i32* %7
%9 = and i32 %8, 16
%10 = icmp ne i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %1
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 0
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load volatile i32, i32* %15
store i32 %16, i32* %2
br label %18
17: ; preds = %1
store i32 -1, i32* %2
br label %18
18: ; preds = %17, %11
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
define i32 @UARTCharGetNonBlocking(i32 %0) {
%2 = add nsw i32 %0, 24
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i32*
%5 = load volatile i32, i32* %4
%6 = and i32 %5, 16
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = sext i32 %0 to i64
%10 = inttoptr i64 %9 to i32*
%11 = load volatile i32, i32* %10
br label %12
12: ; preds = %1, %8
%13 = phi i32 [ %11, %8 ], [ -1, %1 ]
ret i32 %13
}
int two_loops() {
  int p = 10;
  int k = 3;
  int t = 2 + k;
  for (int j = 0; j < 6; j++) {
    k++;
  }
  for (int i = 0; i < 100; i++) {
    p = 3;
  }
  return p;
}


x86 assembly (clang, -O0):
<two_loops>:
push   %rbp
mov    %rsp,%rbp
movl   $0xa,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    1143 <two_loops+0x43>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1122 <two_loops+0x22>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1169 <two_loops+0x69>
movl   $0x3,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <two_loops+0x4a>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @two_loops() {
ret i32 3
}
_hlt(nr) int nr;
{ exit(nr); }


x86 assembly (clang, -O0):
<_hlt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <exit@plt>

x86 assembly (clang, -O2):
<_hlt>:
push   %rax
call   1030 <exit@plt>

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

LLVM IR (-O2):
define i32 @_hlt(i32 %0) {
tail call void @exit(i32 %0)
unreachable
}
/* Type definitions */
struct thread_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ common_unauthorized(struct thread_data *, int);
void proxy_unauthorized(struct thread_data *td) {
  common_unauthorized(td, 407);
}


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

x86 assembly (clang, -O2):
<proxy_unauthorized>:
mov    $0x197,%esi
jmp    1030 <common_unauthorized@plt>

LLVM IR (-O0):
%struct.thread_data = type { i32 }
define void @proxy_unauthorized(%struct.thread_data* %0) {
%2 = alloca %struct.thread_data*
store %struct.thread_data* %0, %struct.thread_data** %2
%3 = load %struct.thread_data*, %struct.thread_data** %2
%4 = call i32 @common_unauthorized(%struct.thread_data* %3, i32 407)
ret void
}

LLVM IR (-O2):
%struct.thread_data = type { i32 }
define void @proxy_unauthorized(%struct.thread_data* %0) {
%2 = tail call i32 @common_unauthorized(%struct.thread_data* %0, i32 407)
ret void
}
int sys$asctoid(void *name, unsigned int *id, unsigned int *attrib) {
  return ({
    unsigned long resultvar;
    register long int _a3 asm("rdx") = (long)(attrib);
    register long int _a2 asm("rsi") = (long)(id);
    register long int _a1 asm("rdi") = (long)(name);
    asm volatile("movq %1, %%rax\n\t"
                 "int $0x81\n\t"
                 : "=a"(resultvar)
                 : "i"(90), "r"(_a1), "r"(_a2), "r"(_a3)
                 : "memory", "cc", "r11", "cx");
    (long)resultvar;
  });
}


x86 assembly (clang, -O0):
<sys$asctoid>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x5a,%rax
int    $0x81
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys$asctoid>:
mov    $0x5a,%rax
int    $0x81
ret

LLVM IR (-O0):
define i32 @"sys$asctoid"(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%12 = load i32*, i32** %6
%13 = ptrtoint i32* %12 to i64
store i64 %13, i64* %8
%14 = load i32*, i32** %5
%15 = ptrtoint i32* %14 to i64
store i64 %15, i64* %9
%16 = load i8*, i8** %4
%17 = ptrtoint i8* %16 to i64
store i64 %17, i64* %10
%18 = load i64, i64* %10
%19 = load i64, i64* %9
%20 = load i64, i64* %8
%21 = call i64 asm sideeffect "movq $1, %rax\0A\09int $$0x81\0A\09", "={ax},i,{rdi},{rsi},{rdx},~{memory},~{cc},~{r11},~{cx},~{dirflag},~{fpsr},~{flags}"(i32 90, i64 %18, i64 %19, i64 %20)
store i64 %21, i64* %7
%22 = load i64, i64* %7
store i64 %22, i64* %11
%23 = load i64, i64* %11
%24 = trunc i64 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
define i32 @"sys$asctoid"(i8* %0, i32* %1, i32* %2) {
%4 = ptrtoint i32* %2 to i64
%5 = ptrtoint i32* %1 to i64
%6 = ptrtoint i8* %0 to i64
%7 = tail call i64 asm sideeffect "movq $1, %rax\0A\09int $$0x81\0A\09", "={ax},i,{rdi},{rsi},{rdx},~{memory},~{cc},~{r11},~{cx},~{dirflag},~{fpsr},~{flags}"(i32 90, i64 %6, i64 %5, i64 %4)
%8 = trunc i64 %7 to i32
ret i32 %8
}
/* Variables and functions */
int yogrt_get_interval2_start();
int iyogrt_get_interval2_start_(void) { return yogrt_get_interval2_start(); }


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

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

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

LLVM IR (-O2):
define i32 @iyogrt_get_interval2_start_() {
%1 = tail call i32 (...) @yogrt_get_interval2_start()
ret i32 %1
}
/* Variables and functions */
int __check_stack_integrity(unsigned int *);
int /*<<< orphan*/ __print_error_message();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ strcpy(char *, char *);
int __lets_play(char *param) {
  unsigned int canary[1];
  canary[0] = 0x1B1B1B1B;
  char buffer[2];
  strcpy(buffer, param);
  if (__check_stack_integrity(canary) == -1) {
    __print_error_message();
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<__lets_play>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1b1b1b1b,-0xc(%rbp)
lea    -0xe(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xc(%rbp),%rdi
call   1050 <__check_stack_integrity@plt>
cmp    $0xffffffff,%eax
jne    1183 <__lets_play+0x43>
mov    $0x0,%al
call   1040 <__print_error_message@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__lets_play>:
push   %rax
mov    %rdi,%rsi
movl   $0x1b1b1b1b,(%rsp)
lea    0x6(%rsp),%rdi
call   1030 <strcpy@plt>
mov    %rsp,%rdi
call   1050 <__check_stack_integrity@plt>
cmp    $0xffffffff,%eax
je     1166 <__lets_play+0x26>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1040 <__print_error_message@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
define i32 @__lets_play(i8* %0) {
%2 = alloca i8*
%3 = alloca [1 x i32]
%4 = alloca [2 x i8]
store i8* %0, i8** %2
%5 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
store i32 454761243, i32* %5
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%10 = call i32 @__check_stack_integrity(i32* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = call i32 (...) @__print_error_message()
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %1
ret i32 0
}

LLVM IR (-O2):
define i32 @__lets_play(i8* %0) {
%2 = alloca [1 x i32]
%3 = alloca [2 x i8]
%4 = bitcast [1 x i32]* %2 to i8*
%5 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 454761243, i32* %5
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* %0)
%8 = call i32 @__check_stack_integrity(i32* %5)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 (...) @__print_error_message()
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ putchar(int);
void put_stars(int ch, int no) {
  while (no-- > 0)
    putchar(ch);
}


x86 assembly (clang, -O0):
<put_stars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    113f <put_stars+0x2f>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    111e <put_stars+0xe>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_stars>:
push   %rbp
push   %rbx
push   %rax
test   %esi,%esi
jle    112f <put_stars+0x1f>
mov    %esi,%ebx
mov    %edi,%ebp
add    $0x1,%ebx
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1120 <put_stars+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @put_stars(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %9
4: ; preds = %2, %4
%5 = phi i32 [ %6, %4 ], [ %1, %2 ]
%6 = add nsw i32 %5, -1
%7 = tail call i32 @putchar(i32 %0)
%8 = icmp ugt i32 %5, 1
br i1 %8, label %4, label %9
9: ; preds = %4, %2
ret void
}
void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
           unsigned int *edx) {
  __asm__ __volatile__("cpuid\n\t"
                       : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
                       : "a"(*eax));
}


x86 assembly (clang, -O0):
<cpuid>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cpuid
mov    %eax,%r9d
mov    -0x38(%rbp),%rax
mov    %ecx,%esi
mov    -0x30(%rbp),%rcx
mov    %r9d,(%r8)
mov    %ebx,(%rdi)
mov    %esi,(%rcx)
mov    %edx,(%rax)
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuid>:
push   %rbx
mov    %rcx,%r8
mov    %rdx,%r9
mov    (%rdi),%eax
cpuid
mov    %eax,(%rdi)
mov    %ebx,(%rsi)
mov    %ecx,(%r9)
mov    %edx,(%r8)
pop    %rbx
ret

LLVM IR (-O0):
define void @cpuid(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load i32*, i32** %5
%10 = load i32*, i32** %6
%11 = load i32*, i32** %7
%12 = load i32*, i32** %8
%13 = load i32*, i32** %5
%14 = load i32, i32* %13
%15 = call { i32, i32, i32, i32 } asm sideeffect "cpuid\0A\09", "={ax},={bx},={cx},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 %14)
%16 = extractvalue { i32, i32, i32, i32 } %15, 0
%17 = extractvalue { i32, i32, i32, i32 } %15, 1
%18 = extractvalue { i32, i32, i32, i32 } %15, 2
%19 = extractvalue { i32, i32, i32, i32 } %15, 3
store i32 %16, i32* %9
store i32 %17, i32* %10
store i32 %18, i32* %11
store i32 %19, i32* %12
ret void
}

LLVM IR (-O2):
define void @cpuid(i32* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* %0
%6 = tail call { i32, i32, i32, i32 } asm sideeffect "cpuid\0A\09", "={ax},={bx},={cx},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 %5)
%7 = extractvalue { i32, i32, i32, i32 } %6, 0
%8 = extractvalue { i32, i32, i32, i32 } %6, 1
%9 = extractvalue { i32, i32, i32, i32 } %6, 2
%10 = extractvalue { i32, i32, i32, i32 } %6, 3
store i32 %7, i32* %0
store i32 %8, i32* %1
store i32 %9, i32* %2
store i32 %10, i32* %3
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void CopyFile(FILE *to, FILE *from) {
  int ch;
  rewind(from);
  while ((ch = getc(from)) != EOF)
    putc(ch, to);
}


x86 assembly (clang, -O0):
<CopyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     1175 <CopyFile+0x45>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <putc@plt>
jmp    1149 <CopyFile+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyFile>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <rewind@plt>
mov    %rbx,%rdi
call   1050 <getc@plt>
mov    0x2e96(%rip),%r15
cmp    (%r15),%eax
je     1177 <CopyFile+0x47>
nopw   0x0(%rax,%rax,1)
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
mov    %rbx,%rdi
call   1050 <getc@plt>
cmp    (%r15),%eax
jne    1160 <CopyFile+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @CopyFile(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = call i32 @rewind(i32* %6)
br label %8
8: ; preds = %13, %2
%9 = load i32*, i32** %4
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %5
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* %5
%15 = load i32*, i32** %3
%16 = call i32 @putc(i32 %14, i32* %15)
br label %8
17: ; preds = %8
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @CopyFile(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @rewind(i32* %1)
%4 = tail call i32 @getc(i32* %1)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %13, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %10, %7 ], [ %4, %2 ]
%9 = tail call i32 @putc(i32 %8, i32* %0)
%10 = tail call i32 @getc(i32* %1)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %7
13: ; preds = %7, %2
ret void
}
/* Variables and functions */
int errno;
int ofi_sockerr(void) { return errno; }


x86 assembly (clang, -O0):
<ofi_sockerr>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ed5(%rip),%rax
mov    (%rax),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@errno = global i32 0
define i32 @ofi_sockerr() {
%1 = load i32, i32* @errno
ret i32 %1
}

LLVM IR (-O2):
@errno = global i32 0
define i32 @ofi_sockerr() {
%1 = load i32, i32* @errno
ret i32 %1
}
int test_imm_42int16_mem(short *val) {
  return ((*val) & (0x42 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_42int16_mem(i16* %0) {
%2 = alloca i16*
store i16* %0, i16** %2
%3 = load i16*, i16** %2
%4 = load i16, i16* %3
%5 = sext i16 %4 to i32
%6 = and i32 %5, 66
%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_42int16_mem(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = and i16 %2, 66
%4 = icmp eq i16 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int test_imm_C6int8_reg(signed char val) {
  return ((val) & (0xC6 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_C6int8_reg>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edx
and    $0xc6,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_C6int8_reg>:
test   $0xc6,%dil
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_C6int8_reg(i8 signext %0) {
%2 = and i8 %0, -58
%3 = icmp eq i8 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
/* Type definitions */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int connect(int, struct sockaddr const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int Connect(int fd, const struct sockaddr *sa, socklen_t salen) {
  int result;
  if ((result = connect(fd, sa, salen)) < 0) {
    perror("connect error");
  }
  return (result);
}


x86 assembly (clang, -O0):
<Connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <connect@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1159 <Connect+0x39>
lea    0xeac(%rip),%rdi
call   1030 <perror@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Connect>:
push   %rbx
call   1040 <connect@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1130 <Connect+0x10>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xec9(%rip),%rdi
call   1030 <perror@plt>
jmp    112c <Connect+0xc>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"connect error\00"
define i32 @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load %struct.sockaddr*, %struct.sockaddr** %5
%10 = load i32, i32* %6
%11 = call i32 @connect(i32 %8, %struct.sockaddr* %9, i32 %10)
store i32 %11, i32* %7
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %3
%16 = load i32, i32* %7
ret i32 %16
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [14 x i8] c"connect error\00"
define i32 @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = tail call i32 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void usage() {
  printf("Usage: vct_flash BUS read|write FILE [SIZE]\n");
  printf(" BUS = I2C bus device file (/dev/i2c-N)\n");
  printf(" read  = read SIZE bytes from flash into FILE\n");
  printf(" write = write from FILE to flash (size = file size)\n");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
call   1030 <printf@plt>
lea    0xf46(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0xf46(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Usage: vct_flash BUS read|write FILE [SIZE]\0A\00"
@.str.1 = [41 x i8] c" BUS = I2C bus device file (/dev/i2c-N)\0A\00"
@.str.2 = [47 x i8] c" read = read SIZE bytes from flash into FILE\0A\00"
@.str.3 = [54 x i8] c" write = write from FILE to flash (size = file size)\0A\00"
define void @usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [44 x i8] c"Usage: vct_flash BUS read|write FILE [SIZE]\00"
@str.4 = [40 x i8] c" BUS = I2C bus device file (/dev/i2c-N)\00"
@str.5 = [46 x i8] c" read = read SIZE bytes from flash into FILE\00"
@str.6 = [53 x i8] c" write = write from FILE to flash (size = file size)\00"
define void @usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.4, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.5, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.6, i64 0, i64 0))
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ wchar_t;

/* Variables and functions */
size_t wcstombs(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/);
size_t mbslen(wchar_t x) {
  wchar_t wstr[] = {x, 0};
  return wcstombs(NULL, wstr, 0);
}


x86 assembly (clang, -O0):
<mbslen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
call   1030 <wcstombs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbslen>:
push   %rax
mov    %edi,(%rsp)
movl   $0x0,0x4(%rsp)
mov    %rsp,%rsi
xor    %edi,%edi
xor    %edx,%edx
call   1030 <wcstombs@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i64 @mbslen(i32 %0) {
%2 = alloca i32
%3 = alloca [2 x i32]
store i32 %0, i32* %2
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%5 = load i32, i32* %2
store i32 %5, i32* %4
%6 = getelementptr inbounds i32, i32* %4, i64 1
store i32 0, i32* %6
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%8 = call i64 @wcstombs(i32* null, i32* %7, i32 0)
ret i64 %8
}

LLVM IR (-O2):
define i64 @mbslen(i32 %0) {
%2 = alloca [2 x i32]
%3 = bitcast [2 x i32]* %2 to i8*
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
store i32 %0, i32* %4
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
store i32 0, i32* %5
%6 = call i64 @wcstombs(i32* null, i32* %4, i32 0)
ret i64 %6
}
void XcmsQueryWhite() {}


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

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

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

LLVM IR (-O2):
define void @XcmsQueryWhite() {
ret void
}
int isprime(int x) {
  int i;
  for (i = 0; i < x; i++) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isprime>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1149 <isprime+0x49>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1136 <isprime+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1150 <isprime+0x50>
jmp    113b <isprime+0x3b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110e <isprime+0xe>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isprime>:
mov    $0x1,%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 0, i32* %4
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = srem i32 %10, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 0, i32* %2
br label %20
15: ; preds = %9
br label %16
16: ; preds = %15
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %5
19: ; preds = %5
store i32 1, i32* %2
br label %20
20: ; preds = %19, %14
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @isprime(i32 %0) {
ret i32 1
}
int numdigit(long a) {
  int res;
  for (res = 1; (a /= 10) != 0; res++)
    ;
  return res;
}


x86 assembly (clang, -O0):
<numdigit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     113e <numdigit+0x3e>
jmp    1130 <numdigit+0x30>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <numdigit+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<numdigit>:
lea    0x9(%rdi),%rdx
mov    $0x1,%ecx
cmp    $0x13,%rdx
jb     1152 <numdigit+0x52>
mov    %rdi,%rax
mov    $0x1,%ecx
movabs $0x6666666666666667,%rsi
66 66 66
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
imul   %rsi
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x2,%rdx
lea    (%rdx,%rdi,1),%rax
add    $0x1,%ecx
add    %rdi,%rdx
add    $0x9,%rdx
cmp    $0x12,%rdx
ja     1130 <numdigit+0x30>
mov    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @numdigit(i64 %0) {
%2 = add i64 %0, 9
%3 = icmp ult i64 %2, 19
br i1 %3, label %11, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %8, %4 ], [ 1, %1 ]
%6 = phi i64 [ %7, %4 ], [ %0, %1 ]
%7 = sdiv i64 %6, 10
%8 = add nuw nsw i32 %5, 1
%9 = add nsw i64 %7, 9
%10 = icmp ult i64 %9, 19
br i1 %10, label %11, label %4
11: ; preds = %4, %1
%12 = phi i32 [ 1, %1 ], [ %8, %4 ]
ret i32 %12
}
/* Type definitions */
typedef int /*<<< orphan*/ EVP_MD_CTX;

/* Variables and functions */
int init(EVP_MD_CTX *ctx) { return 1; }


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

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

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

LLVM IR (-O2):
define i32 @init(i32* nocapture readnone %0) {
ret i32 1
}
/* Variables and functions */
int svc3(int, int, unsigned long, unsigned long);
int say(const char *text, unsigned long num_chars) {
  return svc3(4, 1, (unsigned long)text, num_chars);
}


x86 assembly (clang, -O0):
<say>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <svc3@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<say>:
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    $0x4,%edi
mov    $0x1,%esi
jmp    1030 <svc3@plt>

LLVM IR (-O0):
define i32 @say(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i8*, i8** %3
%6 = ptrtoint i8* %5 to i64
%7 = load i64, i64* %4
%8 = call i32 @svc3(i32 4, i32 1, i64 %6, i64 %7)
ret i32 %8
}

LLVM IR (-O2):
define i32 @say(i8* %0, i64 %1) {
%3 = ptrtoint i8* %0 to i64
%4 = tail call i32 @svc3(i32 4, i32 1, i64 %3, i64 %1)
ret i32 %4
}
void map2check_binop_add_uint(unsigned param1, unsigned param2, unsigned line,
                              unsigned scope, char *function_name) {}


x86 assembly (clang, -O0):
<map2check_binop_add_uint>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @map2check_binop_add_uint(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
ret void
}

LLVM IR (-O2):
define void @map2check_binop_add_uint(i32 %0, i32 %1, i32 %2, i32 %3, i8* nocapture %4) {
ret void
}
extern void call_twice(void (*foo)(int), int x, int y) {
  foo(x);
  foo(y);
}


x86 assembly (clang, -O0):
<call_twice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%edi
call   *%rax
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%edi
call   *%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_twice>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   *%rbx
mov    %ebp,%edi
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    *%rax

LLVM IR (-O0):
define void @call_twice(void (i32)* %0, i32 %1, i32 %2) {
%4 = alloca void (i32)*
%5 = alloca i32
%6 = alloca i32
store void (i32)* %0, void (i32)** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load void (i32)*, void (i32)** %4
%8 = load i32, i32* %5
%9 = load void (i32)*, void (i32)** %4
%10 = load i32, i32* %6
ret void
}

LLVM IR (-O2):
define void @call_twice(void (i32)* nocapture %0, i32 %1, i32 %2) {
tail call void %0(i32 %1)
tail call void %0(i32 %2)
ret void
}
void g_tree_destroy() {}


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

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

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

LLVM IR (-O2):
define void @g_tree_destroy() {
ret void
}
/* Variables and functions */
scalar_t__ sqrt(double);
float _sqrtf(float x) { return ((float)sqrt((double)x)); }


x86 assembly (clang, -O0):
<_sqrtf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sqrt@plt>
cvtsi2ss %rax,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sqrtf>:
push   %rax
cvtss2sd %xmm0,%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @_sqrtf(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fpext float %3 to double
%5 = call i64 @sqrt(double %4)
%6 = sitofp i64 %5 to float
ret float %6
}

LLVM IR (-O2):
define float @_sqrtf(float %0) {
%2 = fpext float %0 to double
%3 = tail call i64 @sqrt(double %2)
%4 = sitofp i64 %3 to float
ret float %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int main() {
  printf("Hello World! I was compiled at: %s", "17:53:29");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [35 x i8] c"Hello World! I was compiled at: %s\00"
@.str.1 = [9 x i8] c"17:53:29\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Hello World! I was compiled at: %s\00"
@.str.1 = [9 x i8] c"17:53:29\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}
void handle_MSG(int sig) {}


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

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

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

LLVM IR (-O2):
define void @handle_MSG(i32 %0) {
ret void
}