xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int main() {
  extern char **environ;
  char **p;
  for (p = environ; *p != NULL; p++) {
    printf("%s\n", *p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     115f <main+0x4f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    112d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ecd(%rip),%rax
mov    (%rax),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1154 <main+0x44>
add    $0x8,%rbx
lea    0xecf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1140 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@environ = external global i8**
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
store i32 0, i32* %1
%3 = load i8**, i8*** @environ
store i8** %3, i8*** %2
br label %4
4: ; preds = %12, %0
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = load i8**, i8*** %2
%10 = load i8*, i8** %9
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %8
%13 = load i8**, i8*** %2
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %2
br label %4
15: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@environ = external global i8**
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = load i8**, i8*** @environ
%2 = load i8*, i8** %1
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %0, %4
%5 = phi i8* [ %9, %4 ], [ %2, %0 ]
%6 = phi i8** [ %8, %4 ], [ %1, %0 ]
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %4
11: ; preds = %4, %0
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
FILE *openOutputFile(char *path) {
  FILE *file = fopen(path, "w+b");
  if (file == NULL) {
    perror("Unable to write to output file.");
    exit(EXIT_FAILURE);
  }
  return file;
}


x86 assembly (clang, -O0):
<openOutputFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1175 <openOutputFile+0x45>
lea    0xea2(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openOutputFile>:
push   %rax
lea    0xec8(%rip),%rsi
call   1030 <fopen@plt>
test   %rax,%rax
je     1144 <openOutputFile+0x14>
pop    %rcx
ret
lea    0xeb9(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"w+b\00"
@.str.1 = [32 x i8] c"Unable to write to output file.\00"
@EXIT_FAILURE = global i32 0
define i32* @openOutputFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load i32*, i32** %3
ret i32* %13
}

LLVM IR (-O2):
@.str = [4 x i8] c"w+b\00"
@.str.1 = [32 x i8] c"Unable to write to output file.\00"
@EXIT_FAILURE = global i32 0
define noalias i32* @openOutputFile(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %1
ret i32* %2
}
/* Variables and functions */
int /*<<< orphan*/ b();
int main() { b(); }


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

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

LLVM IR (-O0):
define i32 @main() {
%1 = call i32 (...) @b()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @b()
ret i32 0
}
unsigned long long foo(float a) {
  const double dfa = a;
  const unsigned int hi = dfa / 0x1p32f;
  const unsigned int lo = dfa - (double)hi * 0x1p32f;
  return ((unsigned long long)hi << (4 * (8))) | lo;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xedc(%rip),%xmm2
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x20,%rax
mov    -0x18(%rbp),%ecx
or     %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
cvtss2sd %xmm0,%xmm0
movsd  0xef4(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
mov    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  0xee1(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
shl    $0x20,%rcx
mov    %eax,%eax
or     %rcx,%rax
ret

LLVM IR (-O0):
define i64 @foo(float %0) {
%2 = alloca float
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store float %0, float* %2
%6 = load float, float* %2
%7 = fpext float %6 to double
store double %7, double* %3
%8 = load double, double* %3
%9 = fdiv double %8, 0x41F0000000000000
%10 = fptoui double %9 to i32
store i32 %10, i32* %4
%11 = load double, double* %3
%12 = load i32, i32* %4
%13 = uitofp i32 %12 to double
%14 = fneg double %13
%15 = call double @llvm.fmuladd.f64(double %14, double 0x41F0000000000000, double %11)
%16 = fptoui double %15 to i32
store i32 %16, i32* %5
%17 = load i32, i32* %4
%18 = zext i32 %17 to i64
%19 = shl i64 %18, 32
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = or i64 %19, %21
ret i64 %22
}

LLVM IR (-O2):
define i64 @foo(float %0) {
%2 = fpext float %0 to double
%3 = fmul double %2, 0x3DF0000000000000
%4 = fptoui double %3 to i32
%5 = uitofp i32 %4 to double
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x41F0000000000000, double %2)
%8 = fptoui double %7 to i32
%9 = zext i32 %4 to i64
%10 = shl nuw i64 %9, 32
%11 = zext i32 %8 to i64
%12 = or i64 %10, %11
ret i64 %12
}
void gtk_text_iter_backward_cursor_position() {}


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

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

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

LLVM IR (-O2):
define void @gtk_text_iter_backward_cursor_position() {
ret void
}
void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer,
                      unsigned long ulValue) {
  ;

  ;
  ;
  if (ulTimer & 0x000000ff) {
    (*((volatile unsigned long *)(ulBase + 0x00000038))) = ulValue;
  }
  if (ulTimer & 0x0000ff00) {
    (*((volatile unsigned long *)(ulBase + 0x0000003C))) = ulValue;
  }
}


x86 assembly (clang, -O0):
<TimerPrescaleSet>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0xff,%rax
cmp    $0x0,%rax
je     1130 <TimerPrescaleSet+0x30>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    -0x10(%rbp),%rax
and    $0xff00,%rax
cmp    $0x0,%rax
je     1150 <TimerPrescaleSet+0x50>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x3c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerPrescaleSet>:
test   %sil,%sil
je     1109 <TimerPrescaleSet+0x9>
mov    %rdx,0x38(%rdi)
test   $0xff00,%esi
je     1115 <TimerPrescaleSet+0x15>
mov    %rdx,0x3c(%rdi)
ret

LLVM IR (-O0):
define void @TimerPrescaleSet(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %5
%8 = and i64 %7, 255
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load i64, i64* %6
%12 = load i64, i64* %4
%13 = add i64 %12, 56
%14 = inttoptr i64 %13 to i64*
store volatile i64 %11, i64* %14
br label %15
15: ; preds = %10, %3
%16 = load i64, i64* %5
%17 = and i64 %16, 65280
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i64, i64* %6
%21 = load i64, i64* %4
%22 = add i64 %21, 60
%23 = inttoptr i64 %22 to i64*
store volatile i64 %20, i64* %23
br label %24
24: ; preds = %19, %15
ret void
}

LLVM IR (-O2):
define void @TimerPrescaleSet(i64 %0, i64 %1, i64 %2) {
%4 = and i64 %1, 255
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = add i64 %0, 56
%8 = inttoptr i64 %7 to i64*
store volatile i64 %2, i64* %8
br label %9
9: ; preds = %6, %3
%10 = and i64 %1, 65280
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = add i64 %0, 60
%14 = inttoptr i64 %13 to i64*
store volatile i64 %2, i64* %14
br label %15
15: ; preds = %12, %9
ret void
}
/* Type definitions */
struct symbol {
  int dummy;
};

/* Variables and functions */
struct symbol *examine_base_type(struct symbol *);
struct symbol *examine_pointer_target(struct symbol *sym) {
  return examine_base_type(sym);
}


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

x86 assembly (clang, -O2):
<examine_pointer_target>:
jmp    1030 <examine_base_type@plt>

LLVM IR (-O0):
%struct.symbol = type { i32 }
define %struct.symbol* @examine_pointer_target(%struct.symbol* %0) {
%2 = alloca %struct.symbol*
store %struct.symbol* %0, %struct.symbol** %2
%3 = load %struct.symbol*, %struct.symbol** %2
%4 = call %struct.symbol* @examine_base_type(%struct.symbol* %3)
ret %struct.symbol* %4
}

LLVM IR (-O2):
%struct.symbol = type { i32 }
define %struct.symbol* @examine_pointer_target(%struct.symbol* %0) {
%2 = tail call %struct.symbol* @examine_base_type(%struct.symbol* %0)
ret %struct.symbol* %2
}
/* Variables and functions */
int /*<<< orphan*/ nmstermio_set_foregroundcolor(char *);
void nmseffect_set_foregroundcolor(char *color) {
  nmstermio_set_foregroundcolor(color);
}


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

x86 assembly (clang, -O2):
<nmseffect_set_foregroundcolor>:
jmp    1030 <nmstermio_set_foregroundcolor@plt>

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

LLVM IR (-O2):
define void @nmseffect_set_foregroundcolor(i8* %0) {
%2 = tail call i32 @nmstermio_set_foregroundcolor(i8* %0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ little_endian_read_16(int /*<<< orphan*/ const *, int);
uint16_t
hci_subevent_le_connection_complete_get_conn_interval(const uint8_t *event) {
  return little_endian_read_16(event, 14);
}


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

x86 assembly (clang, -O2):
<hci_subevent_le_connection_complete_get_conn_interval>:
mov    $0xe,%esi
jmp    1030 <little_endian_read_16@plt>

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

LLVM IR (-O2):
define i32 @hci_subevent_le_connection_complete_get_conn_interval(i32* %0) {
%2 = tail call i32 @little_endian_read_16(i32* %0, i32 14)
ret i32 %2
}
/* Variables and functions */
scalar_t__ ascii_numeric_cmp(char const *, char const *);
int num_ne(const char *pat, const char *text) {
  return (ascii_numeric_cmp(text, pat) != 0);
}


x86 assembly (clang, -O0):
<num_ne>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <ascii_numeric_cmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_ne>:
push   %rax
mov    %rdi,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <ascii_numeric_cmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @num_ne(i8* %0, i8* %1) {
%3 = tail call i64 @ascii_numeric_cmp(i8* %1, i8* %0)
%4 = icmp ne i64 %3, 0
%5 = zext i1 %4 to i32
ret i32 %5
}
void unit(void *nada) { (void)nada; }


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

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

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

LLVM IR (-O2):
define void @unit(i8* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ terminate(char *);
void sigterm_handler(int sig) {
  (void)(sig);
  terminate("terminated");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<sigterm_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <terminate@plt>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<sigterm_handler>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <terminate@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"terminated\00"
@EXIT_SUCCESS = global i32 0
define void @sigterm_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @terminate(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @EXIT_SUCCESS
%6 = call i32 @exit(i32 %5)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"terminated\00"
@EXIT_SUCCESS = global i32 0
define void @sigterm_handler(i32 %0) {
%2 = tail call i32 @terminate(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @EXIT_SUCCESS
%4 = tail call i32 @exit(i32 %3)
unreachable
}
/* Variables and functions */
int midi_clock_get_running();
int seq_ctrl_get_run_state(void) { return midi_clock_get_running(); }


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

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

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

LLVM IR (-O2):
define i32 @seq_ctrl_get_run_state() {
%1 = tail call i32 (...) @midi_clock_get_running()
ret i32 %1
}
int mpeg3_release() { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @mpeg3_release() {
ret i32 0
}
/* Variables and functions */
int O_NONBLOCK;
int O_RDWR;
int open(char *, int);
int /*<<< orphan*/ termConfigRaw(int);
int openStream(char *device) {
  int fd;
  if ((fd = open(device, O_NONBLOCK | O_RDWR)) != -1) {
    termConfigRaw(fd);
  }
  return fd;
}


x86 assembly (clang, -O0):
<openStream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea9(%rip),%rax
mov    (%rax),%esi
mov    0x2ea8(%rip),%rax
or     (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     115b <openStream+0x3b>
mov    -0xc(%rbp),%edi
call   1030 <termConfigRaw@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openStream>:
push   %rbx
mov    0x2eb8(%rip),%rax
mov    0x2eb9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   1040 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1146 <openStream+0x26>
mov    %ebx,%edi
call   1030 <termConfigRaw@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@O_NONBLOCK = global i32 0
@O_RDWR = global i32 0
define i32 @openStream(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @O_NONBLOCK
%6 = load i32, i32* @O_RDWR
%7 = or i32 %5, %6
%8 = call i32 @open(i8* %4, i32 %7)
store i32 %8, i32* %3
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i32 @termConfigRaw(i32 %11)
br label %13
13: ; preds = %10, %1
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
@O_NONBLOCK = global i32 0
@O_RDWR = global i32 0
define i32 @openStream(i8* nocapture %0) {
%2 = load i32, i32* @O_NONBLOCK
%3 = load i32, i32* @O_RDWR
%4 = or i32 %3, %2
%5 = tail call i32 @open(i8* %0, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @termConfigRaw(i32 %5)
br label %9
9: ; preds = %7, %1
ret i32 %5
}
/* Type definitions */
struct var_set {
  int dummy;
};
struct const_var_set {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ var_set_destroy(struct var_set *);
void const_var_set_destroy(struct const_var_set *vs) {
  var_set_destroy((struct var_set *)vs);
}


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

x86 assembly (clang, -O2):
<const_var_set_destroy>:
jmp    1030 <var_set_destroy@plt>

LLVM IR (-O0):
%struct.const_var_set = type { i32 }
%struct.var_set = type { i32 }
define void @const_var_set_destroy(%struct.const_var_set* %0) {
%2 = alloca %struct.const_var_set*
store %struct.const_var_set* %0, %struct.const_var_set** %2
%3 = load %struct.const_var_set*, %struct.const_var_set** %2
%4 = bitcast %struct.const_var_set* %3 to %struct.var_set*
%5 = call i32 @var_set_destroy(%struct.var_set* %4)
ret void
}

LLVM IR (-O2):
%struct.const_var_set = type { i32 }
%struct.var_set = type { i32 }
define void @const_var_set_destroy(%struct.const_var_set* %0) {
%2 = bitcast %struct.const_var_set* %0 to %struct.var_set*
%3 = tail call i32 @var_set_destroy(%struct.var_set* %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
void print_usage(void) {
  printf("usage: sembench [-t threads] [-w wake incr] [-r runtime]");
  printf("                [-o num] (0=ipc, 1=nanosleep, 2=futex)\n");
  exit(1);
}


x86 assembly (clang, -O0):
<print_usage>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<print_usage>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"usage: sembench [-t threads] [-w wake incr] [-r runtime]\00"
@.str.1 = [56 x i8] c" [-o num] (0=ipc, 1=nanosleep, 2=futex)\0A\00"
define void @print_usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [57 x i8] c"usage: sembench [-t threads] [-w wake incr] [-r runtime]\00"
@str = [55 x i8] c" [-o num] (0=ipc, 1=nanosleep, 2=futex)\00"
define void @print_usage() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
int main() {
  puts("Ողջո՛ւյն։");
  puts("Սա ես եմ՝ քո առաջին ծրագիրը։");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [19 x i8] c"\D5\88\D5\B2\D5\BB\D5\B8\D5\9B\D6\82\D5\B5\D5\B6\D6\89\00"
@.str.1 = [52 x i8] c"\D5\8D\D5\A1 \D5\A5\D5\BD \D5\A5\D5\B4\D5\9D \D6\84\D5\B8 \D5\A1\D5\BC\D5\A1\D5\BB\D5\AB\D5\B6 \D5\AE\D6\80\D5\A1\D5\A3\D5\AB\D6\80\D5\A8\D6\89\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"\D5\88\D5\B2\D5\BB\D5\B8\D5\9B\D6\82\D5\B5\D5\B6\D6\89\00"
@.str.1 = [52 x i8] c"\D5\8D\D5\A1 \D5\A5\D5\BD \D5\A5\D5\B4\D5\9D \D6\84\D5\B8 \D5\A1\D5\BC\D5\A1\D5\BB\D5\AB\D5\B6 \D5\AE\D6\80\D5\A1\D5\A3\D5\AB\D6\80\D5\A8\D6\89\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, unsigned int, double);
void tisk(double *arr, unsigned size) {
  for (unsigned i = 0; i < size; ++i) {
    printf("Hodnota prvku [%u] je %.2lf\n", i, arr[i]);
  }
}


x86 assembly (clang, -O0):
<tisk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    115b <tisk+0x4b>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <tisk+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tisk>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1149 <tisk+0x39>
mov    %rdi,%r14
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xed5(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsd  (%r14,%rbx,8),%xmm0
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <tisk+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Hodnota prvku [%u] je %.2lf\0A\00"
define void @tisk(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %18, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp ult i32 %7, %8
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = load i32, i32* %5
%12 = load double*, double** %3
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %11, double %16)
br label %18
18: ; preds = %10
%19 = load i32, i32* %5
%20 = add i32 %19, 1
store i32 %20, i32* %5
br label %6
21: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Hodnota prvku [%u] je %.2lf\0A\00"
define void @tisk(double* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %7
6: ; preds = %7, %2
ret void
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %13, %7 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = trunc i64 %8 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %11, double %10)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %6, label %7
}
double calSquare(double x, double y) {
  double r2 = x * x + y * y;
  return 3.14159265358979323846 * r2 / 2;
}


x86 assembly (clang, -O0):
<calSquare>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xed1(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<calSquare>:
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xeec(%rip),%xmm0
mulsd  0xeec(%rip),%xmm0
ret

LLVM IR (-O0):
define double @calSquare(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %3
%7 = load double, double* %3
%8 = load double, double* %4
%9 = load double, double* %4
%10 = fmul double %8, %9
%11 = call double @llvm.fmuladd.f64(double %6, double %7, double %10)
store double %11, double* %5
%12 = load double, double* %5
%13 = fmul double 0x400921FB54442D18, %12
%14 = fdiv double %13, 2.000000e+00
ret double %14
}

LLVM IR (-O2):
define double @calSquare(double %0, double %1) {
%3 = fmul double %1, %1
%4 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %3)
%5 = fmul double %4, 0x400921FB54442D18
%6 = fmul double %5, 5.000000e-01
ret double %6
}
/* Variables and functions */
int one_sensor_read(char *, int *);
int get_us_dist() {
  int result, value;
  result = one_sensor_read("US", &value);
  if (result < 0)
    return 500;
  return value;
}


x86 assembly (clang, -O0):
<get_us_dist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <one_sensor_read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1141 <get_us_dist+0x31>
movl   $0x1f4,-0x4(%rbp)
jmp    1147 <get_us_dist+0x37>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_us_dist>:
push   %rax
lea    0xee8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1030 <one_sensor_read@plt>
mov    %eax,%ecx
mov    $0x1f4,%eax
test   %ecx,%ecx
js     1131 <get_us_dist+0x21>
mov    0x4(%rsp),%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"US\00"
define i32 @get_us_dist() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @one_sensor_read(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp slt i32 %3, 0
%5 = load i32, i32* %1
%6 = select i1 %4, i32 500, i32 %5
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("hello, world \n");
  return 0;
}


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

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

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

LLVM IR (-O2):
@str = [14 x i8] c"hello, world \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}
double trap(double a, double b, int n, double h, double (*f_x)(double),
            double (*f_c)(int, double, double)) {
  return (h / 2) * ((f_x(a)) + (f_x(b)) + (f_c(n, h, a)));
}


x86 assembly (clang, -O0):
<trap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xed1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   *%rax
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trap>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movsd  %xmm2,0x20(%rsp)
mov    %edi,%ebp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movsd  0xed6(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x28(%rsp)
call   *%rsi
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   *%rbx
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   *%r14
addsd  0x8(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @trap(double %0, double %1, i32 %2, double %3, double (double)* %4, double (i32, double, double)* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double (double)*
%12 = alloca double (i32, double, double)*
store double %0, double* %7
store double %1, double* %8
store i32 %2, i32* %9
store double %3, double* %10
store double (double)* %4, double (double)** %11
store double (i32, double, double)* %5, double (i32, double, double)** %12
%13 = load double, double* %10
%14 = fdiv double %13, 2.000000e+00
%15 = load double (double)*, double (double)** %11
%16 = load double, double* %7
%17 = call double %15(double %16)
%18 = load double (double)*, double (double)** %11
%19 = load double, double* %8
%20 = call double %18(double %19)
%21 = fadd double %17, %20
%22 = load double (i32, double, double)*, double (i32, double, double)** %12
%23 = load i32, i32* %9
%24 = load double, double* %10
%25 = load double, double* %7
%26 = call double %22(i32 %23, double %24, double %25)
%27 = fadd double %21, %26
%28 = fmul double %14, %27
ret double %28
}

LLVM IR (-O2):
define double @trap(double %0, double %1, i32 %2, double %3, double (double)* nocapture %4, double (i32, double, double)* nocapture %5) {
%7 = fmul double %3, 5.000000e-01
%8 = tail call double %4(double %0)
%9 = tail call double %4(double %1)
%10 = fadd double %8, %9
%11 = tail call double %5(i32 %2, double %3, double %0)
%12 = fadd double %10, %11
%13 = fmul double %7, %12
ret double %13
}
/* Variables and functions */
int ceil(int);
int log(double);
int bigint_digits_bound(int n_digits_src, double src_base, double dst_base) {
  return ceil(n_digits_src * log(src_base) / log(dst_base)) + 1;
}


x86 assembly (clang, -O0):
<bigint_digits_bound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ceil@plt>
add    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bigint_digits_bound>:
push   %rbp
push   %rbx
push   %rax
movsd  %xmm1,(%rsp)
mov    %edi,%ebx
call   1040 <log@plt>
mov    %eax,%ebp
imul   %ebx,%ebp
movsd  (%rsp),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ceil@plt>
add    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @bigint_digits_bound(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%7 = load i32, i32* %4
%8 = load double, double* %5
%9 = call i32 @log(double %8)
%10 = mul nsw i32 %7, %9
%11 = load double, double* %6
%12 = call i32 @log(double %11)
%13 = sdiv i32 %10, %12
%14 = call i32 @ceil(i32 %13)
%15 = add nsw i32 %14, 1
ret i32 %15
}

LLVM IR (-O2):
define i32 @bigint_digits_bound(i32 %0, double %1, double %2) {
%4 = tail call i32 @log(double %1)
%5 = mul nsw i32 %4, %0
%6 = tail call i32 @log(double %2)
%7 = sdiv i32 %5, %6
%8 = tail call i32 @ceil(i32 %7)
%9 = add nsw i32 %8, 1
ret i32 %9
}
/* Variables and functions */
int process_add_internal(char **, int);
int process_log(char **x) { return process_add_internal(x, 1); }


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

x86 assembly (clang, -O2):
<process_log>:
mov    $0x1,%esi
jmp    1030 <process_add_internal@plt>

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

LLVM IR (-O2):
define i32 @process_log(i8** %0) {
%2 = tail call i32 @process_add_internal(i8** %0, i32 1)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void logger_debug(char *msg) { printf("DEBUG - %s\n", msg); }


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

x86 assembly (clang, -O2):
<logger_debug>:
mov    %rdi,%rsi
lea    0xee6(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [12 x i8] c"DEBUG - %s\0A\00"
define void @logger_debug(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ funcA(int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int i, j, k;
  printf("Enter the value of i,j:\n");
  scanf("%d %d", &i, &j);
  funcA(&i, &j, &k);
  printf("%d", k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <funcA@plt>
mov    -0x10(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%rdi
lea    0x14(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <scanf@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <funcA@plt>
mov    0xc(%rsp),%esi
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter the value of i,j:\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = call i32 @funcA(i32* %2, i32* %3, i32* %4)
%8 = load i32, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %8)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [24 x i8] c"Enter the value of i,j:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%9 = call i32 @funcA(i32* %1, i32* %2, i32* %3)
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ dlclose(void *);
void _dgles_platform_close(void *h) { dlclose(h); }


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

x86 assembly (clang, -O2):
<_dgles_platform_close>:
jmp    1030 <dlclose@plt>

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

LLVM IR (-O2):
define void @_dgles_platform_close(i8* %0) {
%2 = tail call i32 @dlclose(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  printf("Hello %s\n", ((argc > 1) ? argv[1] : "Mystery Person"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1141 <main+0x31>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1151 <main+0x41>
lea    0xec2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1151 <main+0x41>
mov    -0x18(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jl     111c <main+0xc>
mov    0x8(%rsi),%rsi
jmp    1123 <main+0x13>
lea    0xee7(%rip),%rsi
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Hello %s\0A\00"
@.str.1 = [15 x i8] c"Mystery Person\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
br label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %8
%14 = phi i8* [ %11, %8 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %12 ]
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"Hello %s\0A\00"
@.str.1 = [15 x i8] c"Mystery Person\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %2 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8)
ret i32 0
}
/* Variables and functions */
unsigned long get_pba_clk_rate();
unsigned long get_usart_clk_rate(unsigned int dev_id) {
  return get_pba_clk_rate();
}


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

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

LLVM IR (-O0):
define i64 @get_usart_clk_rate(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i64 (...) @get_pba_clk_rate()
ret i64 %3
}

LLVM IR (-O2):
define i64 @get_usart_clk_rate(i32 %0) {
%2 = tail call i64 (...) @get_pba_clk_rate()
ret i64 %2
}
/* Variables and functions */
int /*<<< orphan*/ phantom_scheduler_yield();
void YIELD() { phantom_scheduler_yield(); }


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

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

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

LLVM IR (-O2):
define void @YIELD() {
%1 = tail call i32 (...) @phantom_scheduler_yield()
ret void
}
int qsortInt(const void *a, const void *b) {
  int *ia = (int *)a;
  int *ib = (int *)b;
  if (*ia < *ib)
    return (-1);
  if (*ia > *ib)
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<qsortInt>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    113a <qsortInt+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    115f <qsortInt+0x5f>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jle    1158 <qsortInt+0x58>
movl   $0x1,-0x4(%rbp)
jmp    115f <qsortInt+0x5f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<qsortInt>:
mov    (%rdi),%eax
xor    %ecx,%ecx
cmp    (%rsi),%eax
setg   %cl
mov    $0xffffffff,%eax
cmovge %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @qsortInt(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i32*
%4 = bitcast i8* %1 to i32*
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = icmp slt i32 %5, %6
%8 = icmp sgt i32 %5, %6
%9 = zext i1 %8 to i32
%10 = select i1 %7, i32 -1, i32 %9
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, int, int);
int main() {
  struct stu {
    char *name;
    int age;
    int male;
  };
  struct stu stu1;
  stu1.name = "victor";
  stu1.age = 12;
  stu1.male = 1;
  printf("I am %s, %d years old, male? %d", stu1.name, stu1.age, stu1.male);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeef(%rip),%rdi
lea    0xee1(%rip),%rsi
mov    $0xc,%edx
mov    $0x1,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stu = type { i8*, i32, i32 }
@.str = [7 x i8] c"victor\00"
@.str.1 = [32 x i8] c"I am %s, %d years old, male? %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stu
store i32 0, i32* %1
%3 = getelementptr inbounds %struct.stu, %struct.stu* %2, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds %struct.stu, %struct.stu* %2, i32 0, i32 1
store i32 12, i32* %4
%5 = getelementptr inbounds %struct.stu, %struct.stu* %2, i32 0, i32 2
store i32 1, i32* %5
%6 = getelementptr inbounds %struct.stu, %struct.stu* %2, i32 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.stu, %struct.stu* %2, i32 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.stu, %struct.stu* %2, i32 0, i32 2
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %9, i32 %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"victor\00"
@.str.1 = [32 x i8] c"I am %s, %d years old, male? %d\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 12, i32 1)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ timer_stop();
void rtos_stop_operation(void) { timer_stop(); }


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

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

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

LLVM IR (-O2):
define void @rtos_stop_operation() {
%1 = tail call i32 (...) @timer_stop()
ret void
}