xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
scalar_t__ getpid();
int open(char const *const, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, char const *const);
int main(int argc, char *argv[]) {
  const char *const filename = argv[1];
  int fd = open(filename, O_RDONLY);
  printf("in process %d, file descriptor %d is opened to %s.\n", (int)getpid(),
         (int)fd, filename);
  while (1)
    ;
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
jmp    1183 <main+0x53>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rsi),%rbx
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <open@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea8(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
jmp    1170 <main+0x40>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [52 x i8] c"in process %d, file descriptor %d is opened to %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = load i32, i32* @O_RDONLY
%13 = call i32 @open(i8* %11, i32 %12)
store i32 %13, i32* %7
%14 = call i64 (...) @getpid()
%15 = trunc i64 %14 to i32
%16 = load i32, i32* %7
%17 = load i8*, i8** %6
%18 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i8* %17)
br label %19
19: ; preds = %2, %19
br label %19
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [52 x i8] c"in process %d, file descriptor %d is opened to %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* %4, i32 %5)
%7 = tail call i64 (...) @getpid()
%8 = trunc i64 %7 to i32
%9 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %6, i8* %4)
br label %10
10: ; preds = %10, %2
br label %10
}
int test_imm_17uint16_mem(unsigned short *val) {
  return ((*val) & (0x17 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_17uint16_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, 23
%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_17uint16_mem(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = and i16 %2, 23
%4 = icmp eq i16 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
regx0indreg1_set(r0, r1, x0, x1, p0, p1) int r0, r1;
int *p0, *p1;
{ (p0[x0]) = (*p1); }


x86 assembly (clang, -O0):
<regx0indreg1_set>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<regx0indreg1_set>:
mov    (%r9),%eax
movslq %edx,%rcx
mov    %eax,(%r8,%rcx,4)
ret

LLVM IR (-O0):
define i32 @regx0indreg1_set(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%14 = load i32*, i32** %13
%15 = load i32, i32* %14
%16 = load i32*, i32** %12
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
store i32 %15, i32* %19
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
define i32 @regx0indreg1_set(i32 %0, i32 %1, i32 %2, i32 %3, i32* nocapture writeonly %4, i32* nocapture %5) {
%7 = load i32, i32* %5
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i32, i32* %4, i64 %8
store i32 %7, i32* %9
ret i32 undef
}
/* Variables and functions */
int /*<<< orphan*/ opciones();
int main() { opciones(); }


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

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

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @opciones()
ret i32 0
}
void g_tree_lookup_extended() {}


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

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

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

LLVM IR (-O2):
define void @g_tree_lookup_extended() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Enable_1302();
int /*<<< orphan*/ Write_1302_Data(unsigned char *);
void Set_Time(unsigned char *TimeBuffer) {
  TimeBuffer[7] = '\x80';
  Enable_1302();
  Write_1302_Data(TimeBuffer);
}


x86 assembly (clang, -O0):
<Set_Time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x80,0x7(%rax)
mov    $0x0,%al
call   1030 <Enable_1302@plt>
mov    -0x8(%rbp),%rdi
call   1040 <Write_1302_Data@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Set_Time>:
push   %rbx
mov    %rdi,%rbx
movb   $0x80,0x7(%rdi)
xor    %eax,%eax
call   1030 <Enable_1302@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <Write_1302_Data@plt>

LLVM IR (-O0):
define void @Set_Time(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 7
store i8 -128, i8* %4
%5 = call i32 (...) @Enable_1302()
%6 = load i8*, i8** %2
%7 = call i32 @Write_1302_Data(i8* %6)
ret void
}

LLVM IR (-O2):
define void @Set_Time(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 7
store i8 -128, i8* %2
%3 = tail call i32 (...) @Enable_1302()
%4 = tail call i32 @Write_1302_Data(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ getch();
void pause() { getch(); }


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

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

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

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


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

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

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

LLVM IR (-O2):
define void @XcmsTekHVCClipC() {
ret void
}
int msm_dts_eagle_init_post(int port_id, int coppid, int topology) { return 0; }


x86 assembly (clang, -O0):
<msm_dts_eagle_init_post>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @msm_dts_eagle_init_post(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
ret i32 0
}

LLVM IR (-O2):
define i32 @msm_dts_eagle_init_post(i32 %0, i32 %1, i32 %2) {
ret i32 0
}
int jac_chain_nm5_free(void *mem) {
  (void)mem;
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @jac_chain_nm5_free(i8* nocapture readnone %0) {
ret i32 0
}
void foo779(int p) {}


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

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

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

LLVM IR (-O2):
define void @foo779(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ pop_subg();
void end_graph(void) { pop_subg(); }


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

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

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

LLVM IR (-O2):
define void @end_graph() {
%1 = tail call i32 (...) @pop_subg()
ret void
}
printf(fmt, args) char *fmt;
unsigned args;
{
  extern int putchar();
  format(putchar, fmt, &args);
}


x86 assembly (clang, -O0):
<printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2eae(%rip),%rdi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1030 <format@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf>:
push   %rax
mov    %rdi,%rax
mov    %esi,0x4(%rsp)
mov    0x2eb9(%rip),%rdi
lea    0x4(%rsp),%rdx
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <format@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @printf(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = call i32 (i32 (...)*, i8*, i32*, ...) bitcast (i32 (...)* @format to i32 (i32 (...)*, i8*, i32*, ...)*)(i32 (...)* @putchar, i8* %6, i32* %5)
%8 = load i32, i32* %3
ret i32 %8
}

LLVM IR (-O2):
define i32 @printf(i8* %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = call i32 (i32 (...)*, i8*, i32*, ...) bitcast (i32 (...)* @format to i32 (i32 (...)*, i8*, i32*, ...)*)(i32 (...)* @putchar, i8* %0, i32* %3)
ret i32 undef
}
/* Variables and functions */
int _sapi_inet_tcp_receive(int, void *, int);
int sapi_inet_tcp_receive(int sock, void *data, int datalen) {
  return _sapi_inet_tcp_receive(sock, data, datalen);
}


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

x86 assembly (clang, -O2):
<sapi_inet_tcp_receive>:
jmp    1030 <_sapi_inet_tcp_receive@plt>

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

LLVM IR (-O2):
define i32 @sapi_inet_tcp_receive(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @_sapi_inet_tcp_receive(i32 %0, i8* %1, i32 %2)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ pmu_set_sleep_clk(int, int, int, int);
void pmu_set_sleep_low() { pmu_set_sleep_clk(0x5, 0x1, 0x10, 0x2); }


x86 assembly (clang, -O0):
<pmu_set_sleep_low>:
push   %rbp
mov    %rsp,%rbp
mov    $0x5,%edi
mov    $0x1,%esi
mov    $0x10,%edx
mov    $0x2,%ecx
call   1030 <pmu_set_sleep_clk@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<pmu_set_sleep_low>:
mov    $0x5,%edi
mov    $0x1,%esi
mov    $0x10,%edx
mov    $0x2,%ecx
jmp    1030 <pmu_set_sleep_clk@plt>

LLVM IR (-O0):
define void @pmu_set_sleep_low() {
%1 = call i32 @pmu_set_sleep_clk(i32 5, i32 1, i32 16, i32 2)
ret void
}

LLVM IR (-O2):
define void @pmu_set_sleep_low() {
%1 = tail call i32 @pmu_set_sleep_clk(i32 5, i32 1, i32 16, i32 2)
ret void
}
int lock_obtain() { return 1; }


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

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

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

LLVM IR (-O2):
define i32 @lock_obtain() {
ret i32 1
}
writeerr() {
  return (1);
  ("ERROR: writerr was called\n");
}


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

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

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

LLVM IR (-O2):
define i32 @writeerr() {
ret i32 1
}
int config_READER_BULCRYPT(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @config_READER_BULCRYPT() {
ret i32 0
}
/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct tb_event {
  int dummy;
};

/* Variables and functions */
int wait_fill_event(struct tb_event *, struct timeval *);
int tb_peek_event(struct tb_event *event, int timeout) {
  struct timeval tv;
  tv.tv_sec = timeout / 1000;
  tv.tv_usec = (int)(timeout - (tv.tv_sec * 1000)) * 1000;
  return wait_fill_event(event, &tv);
}


x86 assembly (clang, -O0):
<tb_peek_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
imul   $0x3e8,-0x18(%rbp),%ecx
sub    %ecx,%eax
imul   $0x3e8,%eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <wait_fill_event@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tb_peek_event>:
push   %rax
movslq %esi,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
mov    %ecx,(%rsp)
imul   $0xfffffc18,%ecx,%ecx
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
mov    %eax,0x4(%rsp)
mov    %rsp,%rsi
call   1030 <wait_fill_event@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.tb_event = type { i32 }
%struct.timeval = type { i32, i32 }
define i32 @tb_peek_event(%struct.tb_event* %0, i32 %1) {
%3 = alloca %struct.tb_event*
%4 = alloca i32
%5 = alloca %struct.timeval
store %struct.tb_event* %0, %struct.tb_event** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sdiv i32 %6, 1000
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* %4
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%11 = load i32, i32* %10
%12 = mul nsw i32 %11, 1000
%13 = sub nsw i32 %9, %12
%14 = mul nsw i32 %13, 1000
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
store i32 %14, i32* %15
%16 = load %struct.tb_event*, %struct.tb_event** %3
%17 = call i32 @wait_fill_event(%struct.tb_event* %16, %struct.timeval* %5)
ret i32 %17
}

LLVM IR (-O2):
%struct.tb_event = type { i32 }
%struct.timeval = type { i32, i32 }
define i32 @tb_peek_event(%struct.tb_event* %0, i32 %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = sdiv i32 %1, 1000
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
store i32 %5, i32* %6
%7 = mul nsw i32 %5, -1000
%8 = add i32 %7, %1
%9 = mul nsw i32 %8, 1000
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
store i32 %9, i32* %10
%11 = call i32 @wait_fill_event(%struct.tb_event* %0, %struct.timeval* %3)
ret i32 %11
}
int facttail(int n, int a) {
  if (0 > n) {
    return 0;
  } else if (0 == n) {
    return 1;
  } else if (1 == n) {
    return a;
  } else {
    return facttail(n - 1, n * a);
  }
}


x86 assembly (clang, -O0):
<facttail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jle    1135 <facttail+0x25>
movl   $0x0,-0x4(%rbp)
jmp    117a <facttail+0x6a>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    114c <facttail+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    117a <facttail+0x6a>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    1165 <facttail+0x55>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117a <facttail+0x6a>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
call   1030 <facttail@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<facttail>:
test   %edi,%edi
js     1125 <facttail+0x25>
mov    %esi,%eax
test   %edi,%edi
je     111f <facttail+0x1f>
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%edi
je     1124 <facttail+0x24>
imul   %edi,%eax
add    $0xffffffff,%edi
test   %edi,%edi
jne    1110 <facttail+0x10>
mov    $0x1,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @facttail(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %11, label %4
4: ; preds = %2, %7
%5 = phi i32 [ %9, %7 ], [ %1, %2 ]
%6 = phi i32 [ %8, %7 ], [ %0, %2 ]
switch i32 %6, label %7 [
i32 0, label %10
i32 1, label %11
]
7: ; preds = %4
%8 = add nsw i32 %6, -1
%9 = mul nsw i32 %5, %6
br label %4
10: ; preds = %4
br label %11
11: ; preds = %4, %10, %2
%12 = phi i32 [ 0, %2 ], [ 1, %10 ], [ %5, %4 ]
ret i32 %12
}
/* Variables and functions */
int /*<<< orphan*/ puts(char const *);
void xputs(int ifindex, const char *s) {
  char which[] = "[serviceX] ";
  which[8] = '0' + ifindex;
  puts(which);
  puts(s);
}


x86 assembly (clang, -O0):
<xputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xputs>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movabs $0x656369767265735b,%rax
69 63 65
mov    %rax,(%rsp)
movl   $0x205d58,0x8(%rsp)
add    $0x30,%dil
mov    %dil,0x8(%rsp)
mov    %rsp,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@__const.xputs.which = [12 x i8] c"[serviceX] \00"
define void @xputs(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [12 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = bitcast [12 x i8]* %5 to i8*
%7 = load i32, i32* %3
%8 = add nsw i32 48, %7
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 8
store i8 %9, i8* %10
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%12 = call i32 @puts(i8* %11)
%13 = load i8*, i8** %4
%14 = call i32 @puts(i8* %13)
ret void
}

LLVM IR (-O2):
@__const.xputs.which = [12 x i8] c"[serviceX] \00"
define void @xputs(i32 %0, i8* nocapture %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = trunc i32 %0 to i8
%6 = add i8 %5, 48
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 8
store i8 %6, i8* %7
%8 = call i32 @puts(i8* %4)
%9 = tail call i32 @puts(i8* dereferenceable(1) %1)
ret void
}
char *stringTrunc(char *string, char *buffer) {
  int len = strlen(string);
  if (len <= 50)
    return string;
  snprintf(buffer, len, "%.*s...%.*s", 20, string, 20, &string[len - 20]);
  return buffer;
}


x86 assembly (clang, -O0):
<stringTrunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x32,-0x1c(%rbp)
jg     1153 <stringTrunc+0x33>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <stringTrunc+0x72>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rsi
mov    -0x10(%rbp),%r8
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x14,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
lea    0xe8a(%rip),%rdx
mov    $0x14,%r9d
mov    %r9d,%ecx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringTrunc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x33,%eax
jge    1139 <stringTrunc+0x19>
mov    %rbx,%r14
jmp    1165 <stringTrunc+0x45>
movslq %eax,%rsi
lea    -0x14(%rsi),%eax
add    %rbx,%rax
mov    %rax,(%rsp)
lea    0xeb3(%rip),%rdx
mov    %r14,%rdi
mov    $0x14,%ecx
mov    %rbx,%r8
mov    $0x14,%r9d
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%.*s...%.*s\00"
define i8* @stringTrunc(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
%9 = trunc i64 %8 to i32
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp sle i32 %10, 50
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i8*, i8** %4
store i8* %13, i8** %3
br label %26
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = load i32, i32* %6
%21 = sub nsw i32 %20, 20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %15, i64 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 20, i8* %18, i32 20, i8* %23)
%25 = load i8*, i8** %5
store i8* %25, i8** %3
br label %26
26: ; preds = %14, %12
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
@.str = [12 x i8] c"%.*s...%.*s\00"
define i8* @stringTrunc(i8* %0, i8* writeonly %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = icmp slt i32 %4, 51
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = shl i64 %3, 32
%8 = ashr exact i64 %7, 32
%9 = add i64 %3, 4294967276
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* %1, i64 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 20, i8* %0, i32 20, i8* %11)
br label %13
13: ; preds = %2, %6
%14 = phi i8* [ %1, %6 ], [ %0, %2 ]
ret i8* %14
}
void array(int *e) {
  int *d;
  int *__cil_tmp3;
  int *__cil_tmp4;
  int *__cil_tmp5;
  int __cil_tmp6;
  int *__cil_tmp7;
  {
    __cil_tmp3 = d + 0;
    *__cil_tmp3 = 3;
    __cil_tmp4 = e + 0;
    *__cil_tmp4 = 3;
    __cil_tmp5 = e + 0;
    __cil_tmp6 = *__cil_tmp5;
    __cil_tmp7 = d + __cil_tmp6;
    *__cil_tmp7 = 3;
    return;
  }
}


x86 assembly (clang, -O0):
<array>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movl   $0x3,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
define void @array(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %2
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32* %10, i32** %4
%11 = load i32*, i32** %4
store i32 3, i32* %11
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32* %13, i32** %5
%14 = load i32*, i32** %5
store i32 3, i32* %14
%15 = load i32*, i32** %2
%16 = getelementptr inbounds i32, i32* %15, i64 0
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
store i32 %18, i32* %7
%19 = load i32*, i32** %3
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32* %22, i32** %8
%23 = load i32*, i32** %8
store i32 3, i32* %23
ret void
}

LLVM IR (-O2):
/* Variables and functions */
unsigned int pkcs7_validate(unsigned char const *, unsigned int);
int pkcs7_strip(const unsigned char *input, unsigned int in_len) {
  unsigned int pad_len = pkcs7_validate(input, in_len);
  return (in_len - pad_len);
}


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

x86 assembly (clang, -O2):
<pkcs7_strip>:
push   %rbx
mov    %esi,%ebx
call   1030 <pkcs7_validate@plt>
sub    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @pkcs7_strip(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i32 @pkcs7_validate(i8* %6, i32 %7)
store i32 %8, i32* %5
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = sub i32 %9, %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @pkcs7_strip(i8* %0, i32 %1) {
%3 = tail call i32 @pkcs7_validate(i8* %0, i32 %1)
%4 = sub i32 %1, %3
ret i32 %4
}
int pioneer_buf_to_unsigned_int(unsigned char *buf) {
  int val = buf[0] + 256 * (0x7F & buf[1]);
  return val;
}


x86 assembly (clang, -O0):
<pioneer_buf_to_unsigned_int>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
and    $0x7f,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pioneer_buf_to_unsigned_int>:
movzbl (%rdi),%ecx
movzbl 0x1(%rdi),%eax
and    $0x7f,%eax
shl    $0x8,%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @pioneer_buf_to_unsigned_int(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = and i32 127, %11
%13 = mul nsw i32 256, %12
%14 = add nsw i32 %7, %13
store i32 %14, i32* %3
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
define i32 @pioneer_buf_to_unsigned_int(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = and i8 %5, 127
%7 = zext i8 %6 to i32
%8 = shl nuw nsw i32 %7, 8
%9 = or i32 %8, %3
ret i32 %9
}
void str_replace(char *s, const char c, const char w) {
  while (s && s[0] != '\0') {
    if (s[0] == c)
      s[0] = w;
    s++;
  }
  return;
}


x86 assembly (clang, -O0):
<str_replace>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0xb(%rbp)
je     1133 <str_replace+0x33>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
test   $0x1,%al
jne    1143 <str_replace+0x43>
jmp    1170 <str_replace+0x70>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    115f <str_replace+0x5f>
mov    -0xa(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1113 <str_replace+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_replace>:
test   %rdi,%rdi
je     1135 <str_replace+0x35>
mov    (%rdi),%al
test   %al,%al
je     1135 <str_replace+0x35>
add    $0x1,%rdi
jmp    112b <str_replace+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rdi),%eax
add    $0x1,%rdi
test   %al,%al
je     1135 <str_replace+0x35>
cmp    %sil,%al
jne    1120 <str_replace+0x20>
mov    %dl,-0x1(%rdi)
jmp    1120 <str_replace+0x20>
ret

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

LLVM IR (-O2):
define void @str_replace(i8* %0, i8 signext %1, i8 signext %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %17, label %5
5: ; preds = %3
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5, %13
%9 = phi i8 [ %15, %13 ], [ %6, %5 ]
%10 = phi i8* [ %14, %13 ], [ %0, %5 ]
%11 = icmp eq i8 %9, %1
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 %2, i8* %10
br label %13
13: ; preds = %12, %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %13, %5, %3
ret void
}
/* Variables and functions */
int partition(int *, int, int);
void quicksort(int *arr, int low, int upp) {
  if (low < upp) {
    int p = partition(arr, low, upp);
    quicksort(arr, low, p - 1);
    quicksort(arr, p + 1, upp);
  }
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1174 <quicksort+0x54>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <partition@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1040 <quicksort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <quicksort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    %edx,%esi
jge    1166 <quicksort+0x46>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <partition@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <quicksort@plt>
add    $0x1,%ebx
mov    %ebx,%ebp
cmp    %r14d,%ebx
jl     1140 <quicksort+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @quicksort(i32* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, %2
br i1 %4, label %5, label %11
5: ; preds = %3, %5
%6 = phi i32 [ %9, %5 ], [ %1, %3 ]
%7 = tail call i32 @partition(i32* %0, i32 %6, i32 %2)
%8 = add nsw i32 %7, -1
tail call void @quicksort(i32* %0, i32 %6, i32 %8)
%9 = add nsw i32 %7, 1
%10 = icmp slt i32 %9, %2
br i1 %10, label %5, label %11
11: ; preds = %5, %3
ret void
}
/* Type definitions */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
void set_bit_reg32(volatile uint32_t *reg, uint8_t bit) {
  (*(volatile unsigned int *)(((((uint32_t)reg & 0xF0000000) + 0x02000000 +
                                (((uint32_t)reg & 0xFFFFF) << 5) +
                                (bit << 2))))) = 0x1;
}


x86 assembly (clang, -O0):
<set_bit_reg32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf0000000,%eax
add    $0x2000000,%eax
mov    -0x8(%rbp),%rcx
and    $0xfffff,%ecx
shl    $0x5,%ecx
add    %ecx,%eax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    %eax,%eax
movl   $0x1,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_bit_reg32>:
mov    %edi,%eax
and    $0xf0000000,%eax
shl    $0x5,%edi
and    $0x1ffffe0,%edi
or     %eax,%edi
lea    (%rdi,%rsi,4),%eax
add    $0x2000000,%eax
movl   $0x1,(%rax)
ret

LLVM IR (-O0):
define void @set_bit_reg32(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32*, i32** %3
%6 = ptrtoint i32* %5 to i32
%7 = and i32 %6, -268435456
%8 = add i32 %7, 33554432
%9 = load i32*, i32** %3
%10 = ptrtoint i32* %9 to i32
%11 = and i32 %10, 1048575
%12 = shl i32 %11, 5
%13 = add i32 %8, %12
%14 = load i32, i32* %4
%15 = shl i32 %14, 2
%16 = add i32 %13, %15
%17 = zext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
store volatile i32 1, i32* %18
ret void
}

LLVM IR (-O2):
define void @set_bit_reg32(i32* %0, i32 %1) {
%3 = ptrtoint i32* %0 to i64
%4 = trunc i64 %3 to i32
%5 = and i32 %4, -268435456
%6 = shl i32 %4, 5
%7 = and i32 %6, 33554400
%8 = or i32 %5, %7
%9 = shl i32 %1, 2
%10 = add i32 %9, 33554432
%11 = add i32 %10, %8
%12 = zext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
store volatile i32 1, i32* %13
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
scalar_t__ test_dlopen();
int main() {
  printf("[BEGIN] dlopen-rpath-from-dylib\n");
  if (test_dlopen())
    printf("[PASS]  dlopen-rpath-from-dylib\n");
  else
    printf("[FAIL]  dlopen-rpath-from-dylib\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <test_dlopen@plt>
cmp    $0x0,%rax
je     115d <main+0x3d>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    1169 <main+0x49>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <test_dlopen@plt>
test   %rax,%rax
lea    0xee2(%rip),%rax
lea    0xefb(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"[BEGIN] dlopen-rpath-from-dylib\0A\00"
@.str.1 = [33 x i8] c"[PASS] dlopen-rpath-from-dylib\0A\00"
@.str.2 = [33 x i8] c"[FAIL] dlopen-rpath-from-dylib\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%3 = call i64 (...) @test_dlopen()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
ret i32 0
}

LLVM IR (-O2):
@str = [32 x i8] c"[BEGIN] dlopen-rpath-from-dylib\00"
@str.3 = [32 x i8] c"[FAIL] dlopen-rpath-from-dylib\00"
@str.4 = [32 x i8] c"[PASS] dlopen-rpath-from-dylib\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 (...) @test_dlopen()
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.4, i64 0, i64 0)
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
ret i32 0
}
int _ht_cmp_ptr(void *d1, void *d2) {
  int i1 = *(int *)d1;
  int i2 = *(int *)d2;
  int i = i1 - i2;
  int result = 0;
  if (i < 0) {
    result = -1;
  } else if (i > 0) {
    result = 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<_ht_cmp_ptr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1144 <_ht_cmp_ptr+0x44>
movl   $0xffffffff,-0x20(%rbp)
jmp    115a <_ht_cmp_ptr+0x5a>
cmpl   $0x0,-0x1c(%rbp)
jle    1155 <_ht_cmp_ptr+0x55>
movl   $0x1,-0x20(%rbp)
jmp    115a <_ht_cmp_ptr+0x5a>
mov    -0x20(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @_ht_cmp_ptr(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = bitcast i8* %1 to i32*
%6 = load i32, i32* %5
%7 = sub nsw i32 %4, %6
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i32
%10 = icmp sgt i32 %7, -1
%11 = select i1 %10, i32 %9, i32 -1
ret i32 %11
}
void zero(float buf[], int count) {
  int i;
  for (i = 0; i < count; i++) {
    buf[i] = 0;
  }
}


x86 assembly (clang, -O0):
<zero>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    113c <zero+0x3c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <zero+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<zero>:
test   %esi,%esi
jle    1126 <zero+0x16>
push   %rax
mov    %esi,%edx
shl    $0x2,%rdx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
ret

LLVM IR (-O0):
define void @zero(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
store float* %0, float** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %15, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = load float*, float** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds float, float* %11, i64 %13
store float 0.000000e+00, float* %14
br label %15
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %6
18: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @zero(float* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = bitcast float* %0 to i8*
%6 = zext i32 %1 to i64
%7 = shl nuw nsw i64 %6, 2
br label %8
8: ; preds = %4, %2
ret void
}
/* Variables and functions */
char *mem_begin(char *);
char *str_insert(char *, char *);
char *str_prepend(char *dst, char *src) {
  char *str = NULL;
  char *dst_begin = mem_begin(dst);
  str = str_insert(dst_begin, src);
  return (str);
}


x86 assembly (clang, -O0):
<str_prepend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <mem_begin@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <str_insert@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_prepend>:
push   %rbx
mov    %rsi,%rbx
call   1040 <mem_begin@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <str_insert@plt>

LLVM IR (-O0):
define i8* @str_prepend(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* null, i8** %5
%7 = load i8*, i8** %3
%8 = call i8* @mem_begin(i8* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %4
%11 = call i8* @str_insert(i8* %9, i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
ret i8* %12
}

LLVM IR (-O2):
define i8* @str_prepend(i8* %0, i8* %1) {
%3 = tail call i8* @mem_begin(i8* %0)
%4 = tail call i8* @str_insert(i8* %3, i8* %1)
ret i8* %4
}
/* Type definitions */
typedef int /*<<< orphan*/ pthread_rwlockattr_t;
typedef int /*<<< orphan*/ pthread_rwlock_t;

/* Variables and functions */
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ pthread_rwlock_init(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_rwlockattr_init(int /*<<< orphan*/ *);
pthread_rwlock_t *hybris_alloc_init_rwlock(void) {
  pthread_rwlock_t *realrwlock = malloc(sizeof(pthread_rwlock_t));
  pthread_rwlockattr_t attr;
  pthread_rwlockattr_init(&attr);
  pthread_rwlock_init(realrwlock, &attr);
  return realrwlock;
}


x86 assembly (clang, -O0):
<hybris_alloc_init_rwlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <pthread_rwlockattr_init@plt>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <pthread_rwlock_init@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hybris_alloc_init_rwlock>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1030 <pthread_rwlockattr_init@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <pthread_rwlock_init@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @hybris_alloc_init_rwlock() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @malloc(i32 4)
store i32* %3, i32** %1
%4 = call i32 @pthread_rwlockattr_init(i32* %2)
%5 = load i32*, i32** %1
%6 = call i32 @pthread_rwlock_init(i32* %5, i32* %2)
%7 = load i32*, i32** %1
ret i32* %7
}

LLVM IR (-O2):
define i32* @hybris_alloc_init_rwlock() {
%1 = alloca i32
%2 = tail call i32* @malloc(i32 4)
%3 = bitcast i32* %1 to i8*
%4 = call i32 @pthread_rwlockattr_init(i32* %1)
%5 = call i32 @pthread_rwlock_init(i32* %2, i32* %1)
ret i32* %2
}
int function(char param1, int param2, long param3) {
  return param1 + param2 + param3;
}


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
add    -0x8(%rbp),%eax
cltq
add    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
lea    (%rdi,%rsi,1),%eax
add    %edx,%eax
ret

LLVM IR (-O0):
define i32 @function(i8 signext %0, i32 %1, i64 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i64
store i8 %0, i8* %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = load i32, i32* %5
%10 = add nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = load i64, i64* %6
%13 = add nsw i64 %11, %12
%14 = trunc i64 %13 to i32
ret i32 %14
}

LLVM IR (-O2):
define i32 @function(i8 signext %0, i32 %1, i64 %2) {
%4 = sext i8 %0 to i32
%5 = add nsw i32 %4, %1
%6 = trunc i64 %2 to i32
%7 = add i32 %5, %6
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ write_port(int, int);
void kb_init(void) { write_port(0x21, 0xFD); }


x86 assembly (clang, -O0):
<kb_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x21,%edi
mov    $0xfd,%esi
call   1030 <write_port@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kb_init>:
mov    $0x21,%edi
mov    $0xfd,%esi
jmp    1030 <write_port@plt>

LLVM IR (-O0):
define void @kb_init() {
%1 = call i32 @write_port(i32 33, i32 253)
ret void
}

LLVM IR (-O2):
define void @kb_init() {
%1 = tail call i32 @write_port(i32 33, i32 253)
ret void
}