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

/* Variables and functions */
int /*<<< orphan*/ ff_bfin_put_pixels16uc(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ const *,
                                          int /*<<< orphan*/ const *,
                                          int /*<<< orphan*/,
                                          int /*<<< orphan*/, int);
void bfin_put_pixels16_x2(uint8_t *block, const uint8_t *pixels,
                          ptrdiff_t line_size, int h) {
  ff_bfin_put_pixels16uc(block, pixels, pixels + 1, line_size, line_size, h);
}


x86 assembly (clang, -O0):
<bfin_put_pixels16_x2>:
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    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
add    $0x4,%rdx
mov    -0x14(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
call   1030 <ff_bfin_put_pixels16uc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfin_put_pixels16_x2>:
mov    %ecx,%r9d
mov    %edx,%ecx
lea    0x4(%rsi),%rdx
mov    %ecx,%r8d
jmp    1030 <ff_bfin_put_pixels16uc@plt>

LLVM IR (-O0):
define void @bfin_put_pixels16_x2(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** %6
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %7
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @ff_bfin_put_pixels16uc(i32* %9, i32* %10, i32* %12, i32 %13, i32 %14, i32 %15)
ret void
}

LLVM IR (-O2):
define void @bfin_put_pixels16_x2(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds i32, i32* %1, i64 1
%6 = tail call i32 @ff_bfin_put_pixels16uc(i32* %0, i32* %1, i32* %5, i32 %2, i32 %2, i32 %3)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ init_3270();
int /*<<< orphan*/ init_network();
int /*<<< orphan*/ init_sys();
int /*<<< orphan*/ init_telnet();
int /*<<< orphan*/ init_terminal();
void tninit() {
  init_terminal();
  init_network();
  init_telnet();
  init_sys();
  init_3270();
}


x86 assembly (clang, -O0):
<tninit>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <init_terminal@plt>
mov    $0x0,%al
call   1030 <init_network@plt>
mov    $0x0,%al
call   1070 <init_telnet@plt>
mov    $0x0,%al
call   1050 <init_sys@plt>
mov    $0x0,%al
call   1060 <init_3270@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<tninit>:
push   %rax
xor    %eax,%eax
call   1040 <init_terminal@plt>
xor    %eax,%eax
call   1030 <init_network@plt>
xor    %eax,%eax
call   1070 <init_telnet@plt>
xor    %eax,%eax
call   1050 <init_sys@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <init_3270@plt>

LLVM IR (-O0):
define void @tninit() {
%1 = call i32 (...) @init_terminal()
%2 = call i32 (...) @init_network()
%3 = call i32 (...) @init_telnet()
%4 = call i32 (...) @init_sys()
%5 = call i32 (...) @init_3270()
ret void
}

LLVM IR (-O2):
define void @tninit() {
%1 = tail call i32 (...) @init_terminal()
%2 = tail call i32 (...) @init_network()
%3 = tail call i32 (...) @init_telnet()
%4 = tail call i32 (...) @init_sys()
%5 = tail call i32 (...) @init_3270()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void usage(void) {
  printf(
      "Usage: c [options] file...\n"
      "Options:\n"
      "  --help\tPrint help screen description.\n"
      "  --version\tPrint version number.\n"
      "  --verbose\tPrint extra information.\n"
      "  -o <file>\tSpecify an output file name.\n"
      "  -Sc      \tSpecify the size of the Code Segment (Not Implemented "
      "Yet).\n"
      "  -Sd      \tSpecify the size of the Data Segment (Not Implemented "
      "Yet).\n"
      "  -Ss      \tSpecify String Symbol Table Hash (Not Implemented Yet).\n"
      "  -Si      \tSpecify ID Symbol Table Hash (Not Implemented Yet).\n"
      "  -So      \tPrint VM Assembly to stdout.\n"
      "\n");
}


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

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

LLVM IR (-O0):
@.str = [507 x i8] c"Usage: c [options] file...\0AOptions:\0A --help\09Print help screen description.\0A --version\09Print version number.\0A --verbose\09Print extra information.\0A -o <file>\09Specify an output file name.\0A -Sc \09Specify the size of the Code Segment (Not Implemented Yet).\0A -Sd \09Specify the size of the Data Segment (Not Implemented Yet).\0A -Ss \09Specify String Symbol Table Hash (Not Implemented Yet).\0A -Si \09Specify ID Symbol Table Hash (Not Implemented Yet).\0A -So \09Print VM Assembly to stdout.\0A\0A\00"
define void @usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([507 x i8], [507 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [506 x i8] c"Usage: c [options] file...\0AOptions:\0A --help\09Print help screen description.\0A --version\09Print version number.\0A --verbose\09Print extra information.\0A -o <file>\09Specify an output file name.\0A -Sc \09Specify the size of the Code Segment (Not Implemented Yet).\0A -Sd \09Specify the size of the Data Segment (Not Implemented Yet).\0A -Ss \09Specify String Symbol Table Hash (Not Implemented Yet).\0A -Si \09Specify ID Symbol Table Hash (Not Implemented Yet).\0A -So \09Print VM Assembly to stdout.\0A\00"
define void @usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([506 x i8], [506 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int printf(char *, unsigned char);
int print_uchar(unsigned char v) { return printf("%u", v); }


x86 assembly (clang, -O0):
<print_uchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
lea    0xedb(%rip),%rdi
movzbl -0x1(%rbp),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_uchar>:
mov    %edi,%esi
lea    0xee7(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
define i32 @print_uchar(i8 zeroext %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ frexp(double, int *);
int /*<<< orphan*/ frexpf(float, int *);
int /*<<< orphan*/ frexpl(long double, int *);
void uninitvar_frexp(void) {
  float f1;
  int *i1;
  (void)frexpf(f1, i1);
  double d1;
  int *i2;
  (void)frexp(d1, i2);
  long double ld1;
  int *i3;
  (void)frexpl(ld1, i3);
}


x86 assembly (clang, -O0):
<uninitvar_frexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1050 <frexpf@plt>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rdi
call   1030 <frexp@plt>
fldt   -0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <frexpl@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uninitvar_frexp>:
sub    $0x18,%rsp
call   1050 <frexpf@plt>
call   1030 <frexp@plt>
call   1040 <frexpl@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @uninitvar_frexp() {
%1 = alloca float
%2 = alloca i32*
%3 = alloca double
%4 = alloca i32*
%5 = alloca x86_fp80
%6 = alloca i32*
%7 = load float, float* %1
%8 = load i32*, i32** %2
%9 = call i32 @frexpf(float %7, i32* %8)
%10 = load double, double* %3
%11 = load i32*, i32** %4
%12 = call i32 @frexp(double %10, i32* %11)
%13 = load x86_fp80, x86_fp80* %5
%14 = load i32*, i32** %6
%15 = call i32 @frexpl(x86_fp80 %13, i32* %14)
ret void
}

LLVM IR (-O2):
define void @uninitvar_frexp() {
%1 = tail call i32 @frexpf(float undef, i32* undef)
%2 = tail call i32 @frexp(double undef, i32* undef)
%3 = tail call i32 @frexpl(x86_fp80 undef, i32* undef)
ret void
}
void op_code_normal_case0x64(void) {}


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

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

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

LLVM IR (-O2):
define void @op_code_normal_case0x64() {
ret void
}
int false(int *bits, int *known, int b) {
  return !get_bit(bits, b) && get_bit(known, b);
}


x86 assembly (clang, -O0):
<false>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1030 <get_bit@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
jne    1158 <false+0x48>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1030 <get_bit@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<false>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
xor    %ebp,%ebp
mov    %edx,%esi
xor    %eax,%eax
call   1030 <get_bit@plt>
test   %eax,%eax
jne    113c <false+0x2c>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <get_bit@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @false(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %6
%9 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @get_bit to i32 (i32*, i32, ...)*)(i32* %7, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %3
%12 = load i32*, i32** %5
%13 = load i32, i32* %6
%14 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @get_bit to i32 (i32*, i32, ...)*)(i32* %12, i32 %13)
%15 = icmp ne i32 %14, 0
br label %16
16: ; preds = %11, %3
%17 = phi i1 [ false, %3 ], [ %15, %11 ]
%18 = zext i1 %17 to i32
ret i32 %18
}

LLVM IR (-O2):
define i32 @false(i32* %0, i32* %1, i32 %2) {
%4 = tail call i32 (i32*, i32, ...) bitcast (i32 (...)* @get_bit to i32 (i32*, i32, ...)*)(i32* %0, i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 (i32*, i32, ...) bitcast (i32 (...)* @get_bit to i32 (i32*, i32, ...)*)(i32* %1, i32 %2)
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %6, %3
%11 = phi i32 [ 0, %3 ], [ %9, %6 ]
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ maxHeapify(int *, int, int);
void buildMaxHeap(int *data, int size) {
  int i;
  for (i = size / 2; i >= 0; --i) {
    maxHeapify(data, i, size);
  }
}


x86 assembly (clang, -O0):
<buildMaxHeap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1154 <buildMaxHeap+0x44>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <maxHeapify@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <buildMaxHeap+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildMaxHeap>:
push   %rbp
push   %r14
push   %rbx
cmp    $0xffffffff,%esi
jl     1141 <buildMaxHeap+0x31>
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%ebp
shr    $0x1f,%ebp
add    %esi,%ebp
sar    %ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <maxHeapify@plt>
add    $0xffffffff,%ebp
jb     1130 <buildMaxHeap+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @buildMaxHeap(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, -2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = sdiv i32 %1, 2
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %9, %6 ], [ %5, %4 ]
%8 = tail call i32 @maxHeapify(i32* %0, i32 %7, i32 %1)
%9 = add nsw i32 %7, -1
%10 = icmp eq i32 %7, 0
br i1 %10, label %11, label %6
11: ; preds = %6, %2
ret void
}
/* Type definitions */
struct stat {
  int dummy;
};

/* Variables and functions */
int stat(char const *, struct stat *);
int file_exist(const char *filename) {
  struct stat st;
  int result = stat(filename, &st);
  return result == 0;
}


x86 assembly (clang, -O0):
<file_exist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <stat@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_exist>:
push   %rax
mov    %rsp,%rsi
call   1030 <stat@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @file_exist(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @stat(i8* %5, %struct.stat* %3)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @file_exist(i8* nocapture %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
ret i32 %6
}
/* Type definitions */
typedef scalar_t__ const uint16_t;

/* Variables and functions */
const uint16_t *find_last_uint16_t(const uint16_t *it, const uint16_t *end,
                                   uint16_t val) {
  while (it != end) {
    --end;
    if (*end == val)
      return end;
  }
  return 0;
}


x86 assembly (clang, -O0):
<find_last_uint16_t>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     114d <find_last_uint16_t+0x4d>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
jne    1148 <find_last_uint16_t+0x48>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1155 <find_last_uint16_t+0x55>
jmp    1110 <find_last_uint16_t+0x10>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_last_uint16_t>:
cmp    %rdi,%rsi
je     1113 <find_last_uint16_t+0x13>
lea    -0x8(%rsi),%rax
cmp    %rdx,-0x8(%rsi)
mov    %rax,%rsi
jne    1100 <find_last_uint16_t>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i64* @find_last_uint16_t(i64* readnone %0, i64* %1, i64 %2) {
br label %4
4: ; preds = %7, %3
%5 = phi i64* [ %1, %3 ], [ %8, %7 ]
%6 = icmp eq i64* %5, %0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = getelementptr inbounds i64, i64* %5, i64 -1
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, %2
br i1 %10, label %11, label %4
11: ; preds = %4, %7
%12 = phi i64* [ %8, %7 ], [ null, %4 ]
ret i64* %12
}
/* Type definitions */
typedef int /*<<< orphan*/ XFontStruct;
typedef int /*<<< orphan*/ XCharStruct;

/* Variables and functions */
int /*<<< orphan*/ XTextExtents(int /*<<< orphan*/ *, char *, int, int *, int *,
                                int *, int /*<<< orphan*/ *);
scalar_t__ strlen(char *);
int get_ascent(char *text, XFontStruct *font) {
  int direction;
  int ascent;
  int descent;
  XCharStruct overall;
  XTextExtents(font, text, (int)strlen(text), &direction, &ascent, &descent,
               &overall);
  return ascent;
}


x86 assembly (clang, -O0):
<get_ascent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
lea    -0x1c(%rbp),%r9
lea    -0x20(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <XTextExtents@plt>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ascent>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0xc(%rsp),%rcx
mov    %rcx,(%rsp)
lea    0x14(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <XTextExtents@plt>
mov    0x8(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @get_ascent(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%9 = load i32*, i32** %4
%10 = load i8*, i8** %3
%11 = load i8*, i8** %3
%12 = call i64 @strlen(i8* %11)
%13 = trunc i64 %12 to i32
%14 = call i32 @XTextExtents(i32* %9, i8* %10, i32 %13, i32* %5, i32* %6, i32* %7, i32* %8)
%15 = load i32, i32* %6
ret i32 %15
}

LLVM IR (-O2):
define i32 @get_ascent(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%12 = trunc i64 %11 to i32
%13 = call i32 @XTextExtents(i32* %1, i8* %0, i32 %12, i32* %3, i32* %4, i32* %5, i32* %6)
%14 = load i32, i32* %4
ret i32 %14
}
/* Type definitions */
typedef void HMAC_CTX;

/* Variables and functions */
int /*<<< orphan*/ EVP_sha256();
void *HMAC_CTX_new();
int /*<<< orphan*/ HMAC_Init_ex(void *, char const *, size_t,
                                int /*<<< orphan*/, int /*<<< orphan*/ *);
void *HMAC_initkey(const char *key, size_t keylen) {
  HMAC_CTX *pctx = HMAC_CTX_new();
  HMAC_Init_ex(pctx, key, keylen, EVP_sha256(), NULL);
  return pctx;
}


x86 assembly (clang, -O0):
<HMAC_initkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <HMAC_CTX_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <EVP_sha256@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <HMAC_Init_ex@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HMAC_initkey>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <HMAC_CTX_new@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <EVP_sha256@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1040 <HMAC_Init_ex@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @HMAC_initkey(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = call i8* (...) @HMAC_CTX_new()
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = load i8*, i8** %3
%9 = load i64, i64* %4
%10 = call i32 (...) @EVP_sha256()
%11 = call i32 @HMAC_Init_ex(i8* %7, i8* %8, i64 %9, i32 %10, i32* null)
%12 = load i8*, i8** %5
ret i8* %12
}

LLVM IR (-O2):
define i8* @HMAC_initkey(i8* %0, i64 %1) {
%3 = tail call i8* (...) @HMAC_CTX_new()
%4 = tail call i32 (...) @EVP_sha256()
%5 = tail call i32 @HMAC_Init_ex(i8* %3, i8* %0, i64 %1, i32 %4, i32* null)
ret i8* %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void usage() {
  printf("Usage:\n"
         "serialsniff [OPTIONS]\n"
         "Where OPTIONS are:\n"
         "\n"
         "      -A,--pathA=DEV 	Path to device A (or 'pty')\n"
         "      -B,--pathB=DEV 	Path to device B (or 'pty')\n"
         "         --logA=FILE 	Log pathA (raw) to FILE\n"
         "         --logB=FILE 	Log pathB (raw) to FILE\n"
         "         --nameA=NAME	Set pathA name to NAME\n"
         "         --nameB=NAME	Set pathB name to NAME\n"
         "  --q,-q,--quiescent	Run in quiescent mode\n"
         "  --d,-d,--digits	Number of hex digits to print in one line\n\n"
         "  --d=nn or -d nn or --digits nn\n"
         "\n");
}


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

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

LLVM IR (-O0):
@.str = [470 x i8] c"Usage:\0Aserialsniff [OPTIONS]\0AWhere OPTIONS are:\0A\0A -A,--pathA=DEV \09Path to device A (or 'pty')\0A -B,--pathB=DEV \09Path to device B (or 'pty')\0A --logA=FILE \09Log pathA (raw) to FILE\0A --logB=FILE \09Log pathB (raw) to FILE\0A --nameA=NAME\09Set pathA name to NAME\0A --nameB=NAME\09Set pathB name to NAME\0A --q,-q,--quiescent\09Run in quiescent mode\0A --d,-d,--digits\09Number of hex digits to print in one line\0A\0A --d=nn or -d nn or --digits nn\0A\0A\00"
define void @usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([470 x i8], [470 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [469 x i8] c"Usage:\0Aserialsniff [OPTIONS]\0AWhere OPTIONS are:\0A\0A -A,--pathA=DEV \09Path to device A (or 'pty')\0A -B,--pathB=DEV \09Path to device B (or 'pty')\0A --logA=FILE \09Log pathA (raw) to FILE\0A --logB=FILE \09Log pathB (raw) to FILE\0A --nameA=NAME\09Set pathA name to NAME\0A --nameB=NAME\09Set pathB name to NAME\0A --q,-q,--quiescent\09Run in quiescent mode\0A --d,-d,--digits\09Number of hex digits to print in one line\0A\0A --d=nn or -d nn or --digits nn\0A\00"
define void @usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([469 x i8], [469 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pthread_self();
int pthread_setname_np(int /*<<< orphan*/, char const *);
void set_thread_name(const char *name) {
  int ret;
  ret = pthread_setname_np(pthread_self(), name);
  if (ret != 0)
    perror("Failed to set thread name");
}


x86 assembly (clang, -O0):
<set_thread_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <pthread_self@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <pthread_setname_np@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1167 <set_thread_name+0x37>
lea    0xe9e(%rip),%rdi
call   1050 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_thread_name>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <pthread_self@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <pthread_setname_np@plt>
test   %eax,%eax
jne    114b <set_thread_name+0x1b>
pop    %rbx
ret
lea    0xeae(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Failed to set thread name\00"
define void @set_thread_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @pthread_self()
%5 = load i8*, i8** %2
%6 = call i32 @pthread_setname_np(i32 %4, i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Failed to set thread name\00"
define void @set_thread_name(i8* %0) {
%2 = tail call i32 (...) @pthread_self()
%3 = tail call i32 @pthread_setname_np(i32 %2, i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
ret void
}
/* Variables and functions */
int mult(unsigned long, int);
unsigned long linrand(unsigned long r) {
  static unsigned long a = 1234567;
  a = (mult(a, 31415821) + 1) % 100000000;
  return (((a / 10000) * r) / 10000);
}


x86 assembly (clang, -O0):
<linrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2f05(%rip),%rdi
mov    $0x1df5e0d,%esi
call   1030 <mult@plt>
add    $0x1,%eax
mov    $0x5f5e100,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,0x2ee6(%rip)
mov    0x2edf(%rip),%rax
mov    $0x2710,%ecx
xor    %edx,%edx
div    %rcx
imul   -0x8(%rbp),%rax
mov    $0x2710,%ecx
xor    %edx,%edx
div    %rcx
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linrand>:
push   %rbx
mov    %rdi,%rbx
mov    0x2f0d(%rip),%rdi
mov    $0x1df5e0d,%esi
call   1030 <mult@plt>
lea    0x1(%rax),%ecx
movslq %ecx,%rcx
imul   $0x55e63b89,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x39,%rcx
add    %edx,%ecx
imul   $0x5f5e100,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,0x2ed3(%rip)
movabs $0x346dc5d63886594b,%rcx
c5 6d 34
mul    %rcx
shr    $0xb,%rdx
imul   %rdx,%rbx
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rax
shr    $0xb,%rax
pop    %rbx
ret

LLVM IR (-O0):
@linrand.a = internal global i64 1234567
define i64 @linrand(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* @linrand.a
%4 = call i32 @mult(i64 %3, i32 31415821)
%5 = add nsw i32 %4, 1
%6 = srem i32 %5, 100000000
%7 = sext i32 %6 to i64
store i64 %7, i64* @linrand.a
%8 = load i64, i64* @linrand.a
%9 = udiv i64 %8, 10000
%10 = load i64, i64* %2
%11 = mul i64 %9, %10
%12 = udiv i64 %11, 10000
ret i64 %12
}

LLVM IR (-O2):
@linrand.a = internal unnamed_addr global i64 1234567
define i64 @linrand(i64 %0) {
%2 = load i64, i64* @linrand.a
%3 = tail call i32 @mult(i64 %2, i32 31415821)
%4 = add nsw i32 %3, 1
%5 = srem i32 %4, 100000000
%6 = sext i32 %5 to i64
store i64 %6, i64* @linrand.a
%7 = udiv i64 %6, 10000
%8 = mul i64 %7, %0
%9 = udiv i64 %8, 10000
ret i64 %9
}
int null_string(char *str) {
  while (*str != '\0') {
    if ((*str) != 0x20) {
      return 0;
    }
    str++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<null_string>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1145 <null_string+0x45>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1134 <null_string+0x34>
movl   $0x0,-0x4(%rbp)
jmp    114c <null_string+0x4c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1108 <null_string+0x8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<null_string>:
movzbl (%rdi),%eax
cmp    $0x20,%al
jne    110d <null_string+0xd>
add    $0x1,%rdi
jmp    1100 <null_string>
test   %al,%al
jne    1117 <null_string+0x17>
mov    $0x1,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @null_string(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 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 32
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 0, i32* %2
br label %19
15: ; preds = %9
%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 1, i32* %2
br label %19
19: ; preds = %18, %14
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @null_string(i8* nocapture %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %7 [
i8 0, label %8
i8 32, label %5
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2
br label %8
8: ; preds = %2, %7
%9 = phi i32 [ 0, %7 ], [ 1, %2 ]
ret i32 %9
}
__attribute__((noipa)) void foo(int *p) {
  *p = 0;
  *((char *)p + 3) = 1;
  *((char *)p + 1) = 2;
  *((char *)p + 2) = *((char *)p + 6);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x1,0x3(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2,0x1(%rax)
mov    -0x8(%rbp),%rax
mov    0x6(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
movl   $0x1000200,(%rdi)
mov    0x6(%rdi),%al
mov    %al,0x2(%rdi)
ret

LLVM IR (-O0):
define void @foo(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
store i32 0, i32* %3
%4 = load i32*, i32** %2
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds i8, i8* %5, i64 3
store i8 1, i8* %6
%7 = load i32*, i32** %2
%8 = bitcast i32* %7 to i8*
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8 2, i8* %9
%10 = load i32*, i32** %2
%11 = bitcast i32* %10 to i8*
%12 = getelementptr inbounds i8, i8* %11, i64 6
%13 = load i8, i8* %12
%14 = load i32*, i32** %2
%15 = bitcast i32* %14 to i8*
%16 = getelementptr inbounds i8, i8* %15, i64 2
store i8 %13, i8* %16
ret void
}

LLVM IR (-O2):
define void @foo(i32* nocapture %0) {
store i32 16777728, i32* %0
%2 = bitcast i32* %0 to i8*
%3 = getelementptr inbounds i8, i8* %2, i64 6
%4 = load i8, i8* %3
%5 = getelementptr inbounds i8, i8* %2, i64 2
store i8 %4, i8* %5
ret void
}
/* Variables and functions */
int main_real(int, char **);
int main(int argc, char *argv[argc]) { return main_real(argc, argv); }


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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <main_real@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
jmp    1030 <main_real@plt>

LLVM IR (-O0):
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 = load i32, i32* %4
%7 = zext i32 %6 to i64
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @main_real(i32 %8, i8** %9)
ret i32 %10
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @main_real(i32 %0, i8** %1)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void handler(int signo __attribute__((unused))) { printf("In handler\n"); }


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

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

LLVM IR (-O0):
@.str = [12 x i8] c"In handler\0A\00"
define void @handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [11 x i8] c"In handler\00"
define void @handler(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret void
}
int test_imm_2Buint16_mem(unsigned short *val) {
  return ((*val) & (-0x2B << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_2Buint16_mem>:
movzwl (%rdi),%eax
test   $0xffd5,%eax
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_2Buint16_mem(i16* %0) {
%2 = alloca i16*
store i16* %0, i16** %2
%3 = load i16*, i16** %2
%4 = load i16, i16* %3
%5 = zext i16 %4 to i32
%6 = and i32 %5, -43
%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_2Buint16_mem(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = and i16 %2, -43
%4 = icmp eq i16 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int test_abs(int num) {
  if (num < 0) {
    return -num;
  }
  return num;
}


x86 assembly (clang, -O0):
<test_abs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    111e <test_abs+0x1e>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1124 <test_abs+0x24>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @test_abs(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
ret i32 %2
}
/* Type definitions */
struct stat {
  int st_size;
};
typedef int off_t;

/* Variables and functions */
scalar_t__ fstat(int, struct stat *);
int /*<<< orphan*/ perror(char *);
off_t filesize(int fd) {
  struct stat buf;
  if (fstat(fd, &buf) < 0) {
    perror("fstat");
    return -1;
  }
  return buf.st_size;
}


x86 assembly (clang, -O0):
<filesize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1040 <fstat@plt>
cmp    $0x0,%rax
jge    1159 <filesize+0x39>
lea    0xeb8(%rip),%rdi
call   1030 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    115f <filesize+0x3f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filesize>:
push   %rax
mov    %rsp,%rsi
call   1040 <fstat@plt>
test   %rax,%rax
js     1133 <filesize+0x13>
mov    (%rsp),%eax
pop    %rcx
ret
lea    0xec6(%rip),%rdi
call   1030 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [6 x i8] c"fstat\00"
define i32 @filesize(i32 %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @fstat(i32 %0, %struct.stat* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%10 = load i32, i32* %9
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ -1, %6 ], [ %10, %8 ]
ret i32 %12
}
/* Variables and functions */
int setlogmask(int);
int xc_log_set_mask(int mask) { return setlogmask(mask); }


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

x86 assembly (clang, -O2):
<xc_log_set_mask>:
jmp    1030 <setlogmask@plt>

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

LLVM IR (-O2):
define i32 @xc_log_set_mask(i32 %0) {
%2 = tail call i32 @setlogmask(i32 %0)
ret i32 %2
}
/* Type definitions */
struct rtavl_table {
  int dummy;
};

/* Variables and functions */
void **rtavl_probe(struct rtavl_table *, void *);
void *rtavl_replace(struct rtavl_table *table, void *item) {
  void **p = rtavl_probe(table, item);
  if (p == NULL || *p == item)
    return NULL;
  else {
    void *r = *p;
    *p = item;
    return r;
  }
}


x86 assembly (clang, -O0):
<rtavl_replace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <rtavl_probe@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     114d <rtavl_replace+0x3d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jne    115a <rtavl_replace+0x4a>
movq   $0x0,-0x8(%rbp)
jmp    1178 <rtavl_replace+0x68>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtavl_replace>:
push   %rbx
mov    %rsi,%rbx
call   1030 <rtavl_probe@plt>
test   %rax,%rax
je     112e <rtavl_replace+0x1e>
mov    %rax,%rcx
mov    (%rax),%rax
cmp    %rbx,%rax
je     112e <rtavl_replace+0x1e>
mov    %rbx,(%rcx)
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.rtavl_table = type { i32 }
define i8* @rtavl_replace(%struct.rtavl_table* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.rtavl_table*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8*
store %struct.rtavl_table* %0, %struct.rtavl_table** %4
store i8* %1, i8** %5
%8 = load %struct.rtavl_table*, %struct.rtavl_table** %4
%9 = load i8*, i8** %5
%10 = call i8** @rtavl_probe(%struct.rtavl_table* %8, i8* %9)
store i8** %10, i8*** %6
%11 = load i8**, i8*** %6
%12 = icmp eq i8** %11, null
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = load i8**, i8*** %6
%15 = load i8*, i8** %14
%16 = load i8*, i8** %5
%17 = icmp eq i8* %15, %16
br i1 %17, label %18, label %19
18: ; preds = %13, %2
store i8* null, i8** %3
br label %25
19: ; preds = %13
%20 = load i8**, i8*** %6
%21 = load i8*, i8** %20
store i8* %21, i8** %7
%22 = load i8*, i8** %5
%23 = load i8**, i8*** %6
store i8* %22, i8** %23
%24 = load i8*, i8** %7
store i8* %24, i8** %3
br label %25
25: ; preds = %19, %18
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
%struct.rtavl_table = type { i32 }
define i8* @rtavl_replace(%struct.rtavl_table* %0, i8* %1) {
%3 = tail call i8** @rtavl_probe(%struct.rtavl_table* %0, i8* %1)
%4 = icmp eq i8** %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
br i1 %7, label %9, label %8
8: ; preds = %5
store i8* %1, i8** %3
br label %9
9: ; preds = %2, %5, %8
%10 = phi i8* [ %6, %8 ], [ null, %5 ], [ null, %2 ]
ret i8* %10
}
/* Variables and functions */
int /*<<< orphan*/ putchar(char);
int putstring(char *s) {
  char c;
  while ((c = *s)) {
    if (c == '\n')
      putchar('\r');
    putchar(c);
    s++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<putstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
cmp    $0x0,%al
je     115e <putstring+0x4e>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    1144 <putstring+0x34>
mov    $0xd,%edi
call   1030 <putchar@plt>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <putstring+0xc>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putstring>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
jmp    1136 <putstring+0x26>
nopl   0x0(%rax)
mov    $0xd,%edi
call   1030 <putchar@plt>
movsbl %bl,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
movzbl (%r14),%ebx
cmp    $0xa,%bl
je     1120 <putstring+0x10>
test   %bl,%bl
jne    112a <putstring+0x1a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @putstring(i8* nocapture %0) {
br label %2
2: ; preds = %7, %1
%3 = phi i8* [ %0, %1 ], [ %9, %7 ]
%4 = load i8, i8* %3
switch i8 %4, label %7 [
i8 0, label %10
i8 10, label %5
]
5: ; preds = %2
%6 = tail call i32 @putchar(i8 signext 13)
br label %7
7: ; preds = %2, %5
%8 = tail call i32 @putchar(i8 signext %4)
%9 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
10: ; preds = %2
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ error_message_exit(int /*<<< orphan*/, char *);
void no_mem_exit(void) { error_message_exit(0, "Out of memory."); }


x86 assembly (clang, -O0):
<no_mem_exit>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
lea    0xee3(%rip),%rsi
call   1030 <error_message_exit@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<no_mem_exit>:
lea    0xee9(%rip),%rsi
xor    %edi,%edi
jmp    1030 <error_message_exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Out of memory.\00"
define void @no_mem_exit() {
%1 = call i32 @error_message_exit(i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Out of memory.\00"
define void @no_mem_exit() {
%1 = tail call i32 @error_message_exit(i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret void
}
unsigned long sample(const unsigned long currentSeed) {
  return (unsigned long)(((currentSeed * 4495139485377102241) -
                          (908196443315401744)) %
                         3121041941);
}


x86 assembly (clang, -O0):
<sample>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movabs $0x3e61f18bb1bc01a1,%rax
f1 61 3e
imul   -0x8(%rbp),%rax
movabs $0xc9a8fda76167410,%rcx
8f 9a 0c
sub    %rcx,%rax
mov    $0xba075215,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample>:
movabs $0x3e61f18bb1bc01a1,%rax
f1 61 3e
imul   %rdi,%rax
movabs $0xf365702589e98bf0,%rcx
70 65 f3
add    %rax,%rcx
movabs $0xb0251c39a8612fbb,%rdx
1c 25 b0
mov    %rcx,%rax
mul    %rdx
shr    $0x1f,%rdx
mov    $0xba075215,%eax
imul   %rdx,%rax
sub    %rax,%rcx
mov    %rcx,%rax
ret

LLVM IR (-O0):
define i64 @sample(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = mul i64 %3, 4495139485377102241
%5 = sub i64 %4, 908196443315401744
%6 = urem i64 %5, 3121041941
ret i64 %6
}

LLVM IR (-O2):
define i64 @sample(i64 %0) {
%2 = mul i64 %0, 4495139485377102241
%3 = add i64 %2, -908196443315401744
%4 = urem i64 %3, 3121041941
ret i64 %4
}
char testClosureVrB(char (*closure)(void)) { return (*closure)(); }


x86 assembly (clang, -O0):
<testClosureVrB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
call   *-0x8(%rbp)
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testClosureVrB>:
jmp    *%rdi

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

LLVM IR (-O2):
define signext i8 @testClosureVrB(i8 ()* nocapture %0) {
%2 = tail call signext i8 %0()
ret i8 %2
}
/* Type definitions */
typedef int /*<<< orphan*/ volatile uint16_t;

/* Variables and functions */
uint16_t read16(volatile void *addr) { return *(volatile uint16_t *)addr; }


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

x86 assembly (clang, -O2):
<read16>:
mov    (%rdi),%eax
ret

LLVM IR (-O0):
define i32 @read16(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = bitcast i8* %3 to i32*
%5 = load volatile i32, i32* %4
ret i32 %5
}

LLVM IR (-O2):
define i32 @read16(i8* %0) {
%2 = bitcast i8* %0 to i32*
%3 = load volatile i32, i32* %2
ret i32 %3
}
void qcom_glink_driver_unregister(void *drv) {}


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

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

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

LLVM IR (-O2):
define void @qcom_glink_driver_unregister(i8* nocapture %0) {
ret void
}