xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ write(char *, char *, int /*<<< orphan*/ *);
void init_asig_section() { write("msproject.xml", "<Assignments>\n", NULL); }


x86 assembly (clang, -O0):
<init_asig_section>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xeec(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <write@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_asig_section>:
lea    0xee9(%rip),%rdi
lea    0xef0(%rip),%rsi
xor    %edx,%edx
jmp    1030 <write@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"msproject.xml\00"
@.str.1 = [15 x i8] c"<Assignments>\0A\00"
define void @init_asig_section() {
%1 = call i32 @write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* null)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"msproject.xml\00"
@.str.1 = [15 x i8] c"<Assignments>\0A\00"
define void @init_asig_section() {
%1 = tail call i32 @write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* null)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ assert(int);
char *malloc(int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *str_copy(char *str) {
  char *cpy = malloc(sizeof(char) * (strlen(str) + 1));
  strcpy(cpy, str);
  assert(!strcmp(str, cpy));
  return cpy;
}


x86 assembly (clang, -O0):
<str_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_copy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @str_copy(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = mul i64 1, %7
%9 = trunc i64 %8 to i32
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = call i32 @strcmp(i8* %14, i8* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
define i8* @str_copy(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %4)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
ret i8* %4
}
void funptr_apply_p1(void (*funptr)(void), void *p1) {
  void (*lock)(void *) = (void (*)(void *))funptr;
  (*lock)(p1);
}


x86 assembly (clang, -O0):
<funptr_apply_p1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rdi
call   *%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<funptr_apply_p1>:
mov    %rdi,%rax
mov    %rsi,%rdi
jmp    *%rax

LLVM IR (-O0):
define void @funptr_apply_p1(void ()* %0, i8* %1) {
%3 = alloca void ()*
%4 = alloca i8*
%5 = alloca void (i8*)*
store void ()* %0, void ()** %3
store i8* %1, i8** %4
%6 = load void ()*, void ()** %3
%7 = bitcast void ()* %6 to void (i8*)*
store void (i8*)* %7, void (i8*)** %5
%8 = load void (i8*)*, void (i8*)** %5
%9 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
define void @funptr_apply_p1(void ()* nocapture %0, i8* %1) {
%3 = bitcast void ()* %0 to void (i8*)*
tail call void %3(i8* %1)
ret void
}
int interpHistoryInc(int x) { return (x + 1) % 32; }


x86 assembly (clang, -O0):
<interpHistoryInc>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpHistoryInc>:
lea    0x1(%rdi),%eax
lea    0x20(%rdi),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffe0,%ecx
neg    %ecx
lea    (%rdi,%rcx,1),%eax
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @interpHistoryInc(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add nsw i32 %3, 1
%5 = srem i32 %4, 32
ret i32 %5
}

LLVM IR (-O2):
define i32 @interpHistoryInc(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = srem i32 %2, 32
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ _irqack();
void irq3() { _irqack(); }


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

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

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

LLVM IR (-O2):
define void @irq3() {
%1 = tail call i32 (...) @_irqack()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ WSramAddr(int);
int /*<<< orphan*/ Wd(int, int);
int /*<<< orphan*/ Ws(char *);
int Winst9A(int i, int code) {
  Ws("sbi   ");
  WSramAddr((code >> 3) & 0x1F);
  Ws(", ");
  Wd(code & 7, 1);
  return 0;
}


x86 assembly (clang, -O0):
<Winst9A>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xebb(%rip),%rdi
call   1030 <Ws@plt>
mov    -0x8(%rbp),%edi
sar    $0x3,%edi
and    $0x1f,%edi
call   1040 <WSramAddr@plt>
lea    0xea8(%rip),%rdi
call   1030 <Ws@plt>
mov    -0x8(%rbp),%edi
and    $0x7,%edi
mov    $0x1,%esi
call   1050 <Wd@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Winst9A>:
push   %rbx
mov    %esi,%ebx
lea    0xec6(%rip),%rdi
call   1030 <Ws@plt>
mov    %ebx,%edi
shr    $0x3,%edi
and    $0x1f,%edi
call   1040 <WSramAddr@plt>
lea    0xeb4(%rip),%rdi
call   1030 <Ws@plt>
and    $0x7,%ebx
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <Wd@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"sbi \00"
@.str.1 = [3 x i8] c", \00"
define i32 @Winst9A(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = call i32 @Ws(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %4
%7 = ashr i32 %6, 3
%8 = and i32 %7, 31
%9 = call i32 @WSramAddr(i32 %8)
%10 = call i32 @Ws(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %4
%12 = and i32 %11, 7
%13 = call i32 @Wd(i32 %12, i32 1)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"sbi \00"
@.str.1 = [3 x i8] c", \00"
define i32 @Winst9A(i32 %0, i32 %1) {
%3 = tail call i32 @Ws(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = lshr i32 %1, 3
%5 = and i32 %4, 31
%6 = tail call i32 @WSramAddr(i32 %5)
%7 = tail call i32 @Ws(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = and i32 %1, 7
%9 = tail call i32 @Wd(i32 %8, i32 1)
ret i32 0
}
char **perl_free(ptr)
char **ptr;
{ free(ptr[0]); }


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

x86 assembly (clang, -O2):
<perl_free>:
mov    (%rdi),%rdi
jmp    1030 <free@plt>

LLVM IR (-O0):
define i8** @perl_free(i8** %0) {
%2 = alloca i8**
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = getelementptr inbounds i8*, i8** %4, i64 0
%6 = load i8*, i8** %5
%7 = load i8**, i8*** %2
ret i8** %7
}

LLVM IR (-O2):
define noalias i8** @perl_free(i8** nocapture %0) {
%2 = load i8*, i8** %0
tail call void @free(i8* %2)
ret i8** undef
}
int test_imm_4Auint64_midword_reg(unsigned long long val) {
  return ((val >> 16) & (0x4A << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_4Auint64_midword_reg>:
test   $0x4a0000,%edi
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_4Auint64_midword_reg(i64 %0) {
%2 = and i64 %0, 4849664
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
/* Variables and functions */
scalar_t__ signbit(float);
float fabsf(float x) { return signbit(x) ? -x : x; }


x86 assembly (clang, -O0):
<fabsf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <signbit@plt>
cmp    $0x0,%rax
je     114d <fabsf+0x3d>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1157 <fabsf+0x47>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fabsf>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1030 <signbit@plt>
test   %rax,%rax
je     1132 <fabsf+0x22>
movaps (%rsp),%xmm0
xorps  0xed3(%rip),%xmm0
add    $0x18,%rsp
ret
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @fabsf(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = call i64 @signbit(float %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load float, float* %2
%8 = fneg float %7
br label %11
9: ; preds = %1
%10 = load float, float* %2
br label %11
11: ; preds = %9, %6
%12 = phi float [ %8, %6 ], [ %10, %9 ]
ret float %12
}

LLVM IR (-O2):
define float @fabsf(float %0) {
%2 = tail call i64 @signbit(float %0)
%3 = icmp eq i64 %2, 0
%4 = fneg float %0
%5 = select i1 %3, float %0, float %4
ret float %5
}
/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(int);
void randomize() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  srand(tv.tv_sec * 1000 + tv.tv_usec / 1000);
}


x86 assembly (clang, -O0):
<randomize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,-0x8(%rbp),%edi
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    %eax,%edi
call   1040 <srand@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize>:
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,(%rsp),%eax
movslq 0x4(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rdi
mov    %rdi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rdi
add    %ecx,%edi
add    %eax,%edi
pop    %rax
jmp    1040 <srand@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @randomize() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%4 = load i32, i32* %3
%5 = mul nsw i32 %4, 1000
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%7 = load i32, i32* %6
%8 = sdiv i32 %7, 1000
%9 = add nsw i32 %5, %8
%10 = call i32 @srand(i32 %9)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @randomize() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, 1000
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = sdiv i32 %8, 1000
%10 = add nsw i32 %9, %6
%11 = tail call i32 @srand(i32 %10)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void usage() {
  fprintf(stderr, "Usage: hex2dsk --template template.dsk cpm_loader.hex "
                  "cpm22.hex alice3_cbios.hex out.dsk\n");
  exit(-1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [90 x i8] c"Usage: hex2dsk --template template.dsk cpm_loader.hex cpm22.hex alice3_cbios.hex out.dsk\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [90 x i8] c"Usage: hex2dsk --template template.dsk cpm_loader.hex cpm22.hex alice3_cbios.hex out.dsk\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @exit(i32 -1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ LPUART2_DriverIRQHandler();
__attribute__((weak)) void LPUART2_IRQHandler(void) {
  LPUART2_DriverIRQHandler();
}


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

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

LLVM IR (-O0):
define weak void @LPUART2_IRQHandler() {
%1 = call i32 (...) @LPUART2_DriverIRQHandler()
ret void
}

LLVM IR (-O2):
define weak void @LPUART2_IRQHandler() {
%1 = tail call i32 (...) @LPUART2_DriverIRQHandler()
ret void
}
/* Variables and functions */
void *c_malloc(unsigned int);
void *malloc(unsigned int size) { return c_malloc(size); }


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

x86 assembly (clang, -O2):
<malloc>:
jmp    1030 <c_malloc@plt>

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

LLVM IR (-O2):
define i8* @malloc(i32 %0) {
%2 = tail call i8* @c_malloc(i32 %0)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
void *realloc(void *, size_t);
void *realloc_or_die(void *mem, size_t sz) {
  mem = realloc(mem, sz);
  if (mem == NULL)
    exit(1);
  return mem;
}


x86 assembly (clang, -O0):
<realloc_or_die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1156 <realloc_or_die+0x36>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realloc_or_die>:
push   %rax
call   1030 <realloc@plt>
test   %rax,%rax
je     112d <realloc_or_die+0xd>
pop    %rcx
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define i8* @realloc_or_die(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i8*, i8** %3
%6 = load i64, i64* %4
%7 = call i8* @realloc(i8* %5, i64 %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i8*, i8** %3
ret i8* %13
}

LLVM IR (-O2):
define noalias i8* @realloc_or_die(i8* nocapture %0, i64 %1) {
%3 = tail call i8* @realloc(i8* %0, i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
ret i8* %3
}
int test_imm_4Fuint64_midword_reg(unsigned long long val) {
  return ((val >> 16) & (0x4F << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_4Fuint64_midword_reg>:
test   $0x4f0000,%edi
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_4Fuint64_midword_reg(i64 %0) {
%2 = and i64 %0, 5177344
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
__attribute__((always_)) unsigned int _xbegin(void) {
  unsigned int ret = (~0u);
  __asm__ volatile(".byte 0xc7, 0xf8; .long 0" : "+a"(ret)::"memory");
  return ret;
}


x86 assembly (clang, -O0):
<_xbegin>:
push   %rbp
mov    %rsp,%rbp
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
xbegin 1114 <_xbegin+0x14>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_xbegin>:
mov    $0xffffffff,%eax
xbegin 110b <_xbegin+0xb>
ret

LLVM IR (-O0):
define i32 @_xbegin() {
%1 = alloca i32
store i32 -1, i32* %1
%2 = load i32, i32* %1
%3 = call i32 asm sideeffect ".byte 0xc7, 0xf8; .long 0", "={ax},0,~{memory},~{dirflag},~{fpsr},~{flags}"(i32 %2)
store i32 %3, i32* %1
%4 = load i32, i32* %1
ret i32 %4
}

LLVM IR (-O2):
define i32 @_xbegin() {
%1 = tail call i32 asm sideeffect ".byte 0xc7, 0xf8; .long 0", "={ax},0,~{memory},~{dirflag},~{fpsr},~{flags}"(i32 -1)
ret i32 %1
}
double f(double x, double a) { return x * (1 - x) * (x - a); }


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xee5(%rip),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
movsd  0xef8(%rip),%xmm2
subsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @f(double %0, double %1) {
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double %1, double* %4
%5 = load double, double* %3
%6 = load double, double* %3
%7 = fsub double 1.000000e+00, %6
%8 = fmul double %5, %7
%9 = load double, double* %3
%10 = load double, double* %4
%11 = fsub double %9, %10
%12 = fmul double %8, %11
ret double %12
}

LLVM IR (-O2):
define double @f(double %0, double %1) {
%3 = fsub double 1.000000e+00, %0
%4 = fmul double %3, %0
%5 = fsub double %0, %1
%6 = fmul double %4, %5
ret double %6
}
int Bematech_FI_Descontos(Var, Retorno) {
  return Formata("\x1b|35|05|\x1b", Var, Retorno);
}


x86 assembly (clang, -O0):
<Bematech_FI_Descontos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <Formata@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Bematech_FI_Descontos>:
mov    %esi,%edx
mov    %edi,%esi
lea    0xee5(%rip),%rdi
xor    %eax,%eax
jmp    1030 <Formata@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"\1B|35|05|\1B\00"
define i32 @Bematech_FI_Descontos(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @Formata to i32 (i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
@.str = [10 x i8] c"\1B|35|05|\1B\00"
define i32 @Bematech_FI_Descontos(i32 %0, i32 %1) {
%3 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @Formata to i32 (i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
ret i32 %3
}
int main(void) {
  int k = 5;
  for (k = 10; k < 100; k++) {
    if (k == 0) {
      break;
    }
    if (k == 1) {
      break;
    } else if (k == 2) {
      break;
    } else if (k == 3) {
      break;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0xa,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    117c <main+0x7c>
cmpl   $0x0,-0x8(%rbp)
jne    1132 <main+0x32>
jmp    117c <main+0x7c>
cmpl   $0x1,-0x8(%rbp)
jne    1141 <main+0x41>
jmp    117c <main+0x7c>
cmpl   $0x2,-0x8(%rbp)
jne    1150 <main+0x50>
jmp    117c <main+0x7c>
cmpl   $0x3,-0x8(%rbp)
jne    115f <main+0x5f>
jmp    117c <main+0x7c>
jmp    1164 <main+0x64>
jmp    1169 <main+0x69>
jmp    116e <main+0x6e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1119 <main+0x19>
xor    %eax,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Type definitions */
struct _Locale_name_hint {
  int dummy;
};

/* Variables and functions */
char const *_Locale_extract_name(char const *, int *);
char const *_Locale_extract_collate_name(const char *name,
                                         char *buf __attribute__((__unused__)),
                                         struct _Locale_name_hint *hint
                                         __attribute__((__unused__)),
                                         int *__err_code) {
  return _Locale_extract_name(name, __err_code);
}


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

x86 assembly (clang, -O2):
<_Locale_extract_collate_name>:
mov    %rcx,%rsi
jmp    1030 <_Locale_extract_name@plt>

LLVM IR (-O0):
%struct._Locale_name_hint = type { i32 }
define i8* @_Locale_extract_collate_name(i8* %0, i8* %1, %struct._Locale_name_hint* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct._Locale_name_hint*
%8 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store %struct._Locale_name_hint* %2, %struct._Locale_name_hint** %7
store i32* %3, i32** %8
%9 = load i8*, i8** %5
%10 = load i32*, i32** %8
%11 = call i8* @_Locale_extract_name(i8* %9, i32* %10)
ret i8* %11
}

LLVM IR (-O2):
%struct._Locale_name_hint = type { i32 }
define i8* @_Locale_extract_collate_name(i8* %0, i8* nocapture readnone %1, %struct._Locale_name_hint* nocapture readnone %2, i32* %3) {
%5 = tail call i8* @_Locale_extract_name(i8* %0, i32* %3)
ret i8* %5
}
/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *julian_to_yyyy_mm_dd(double);
char *timlib_yyyymmdd_to_oracle_format(char *);
char *julian_display_oracle_format(double current) {
  char *yyyy_mm_dd;
  char *oracle_format;
  yyyy_mm_dd = julian_to_yyyy_mm_dd(current);
  oracle_format = timlib_yyyymmdd_to_oracle_format(yyyy_mm_dd);
  free(yyyy_mm_dd);
  return oracle_format;
}


x86 assembly (clang, -O0):
<julian_display_oracle_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <julian_to_yyyy_mm_dd@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <timlib_yyyymmdd_to_oracle_format@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<julian_display_oracle_format>:
push   %r14
push   %rbx
push   %rax
call   1040 <julian_to_yyyy_mm_dd@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <timlib_yyyymmdd_to_oracle_format@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @julian_display_oracle_format(double %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i8*
store double %0, double* %2
%5 = load double, double* %2
%6 = call i8* @julian_to_yyyy_mm_dd(double %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @timlib_yyyymmdd_to_oracle_format(i8* %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @free(i8* %9)
%11 = load i8*, i8** %4
ret i8* %11
}

LLVM IR (-O2):
define i8* @julian_display_oracle_format(double %0) {
%2 = tail call i8* @julian_to_yyyy_mm_dd(double %0)
%3 = tail call i8* @timlib_yyyymmdd_to_oracle_format(i8* %2)
%4 = tail call i32 @free(i8* %2)
ret i8* %3
}
unsigned xrop3_184_0_1(unsigned char s, unsigned char t) {
  unsigned D = 0x00ff;
  unsigned S = ((unsigned)s << 8) | s;
  unsigned T = ((unsigned)t << 8) | t;
  unsigned stk1;
  unsigned stk2;
  unsigned stk3;
  stk3 = D ^ T;
  stk2 = S & stk3;
  stk1 = T ^ stk2;
  return (stk1 & S) | (stk1 & (~T)) | (T & (~S) & D);
}


x86 assembly (clang, -O0):
<xrop3_184_0_1>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movl   $0xff,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x8,%eax
movzbl -0x1(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
movzbl -0x2(%rbp),%eax
shl    $0x8,%eax
movzbl -0x2(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
xor    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%edx
xor    $0xffffffff,%edx
and    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%edx
xor    $0xffffffff,%edx
and    %edx,%ecx
and    -0x8(%rbp),%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrop3_184_0_1>:
mov    %edi,%eax
shl    $0x8,%eax
or     %edi,%eax
mov    %esi,%ecx
shl    $0x8,%ecx
or     %esi,%ecx
mov    %ecx,%edx
xor    $0xff,%edx
and    %eax,%edx
mov    %edx,%edi
xor    %ecx,%edi
and    %eax,%edi
not    %ecx
and    %edx,%ecx
not    %eax
and    %esi,%eax
or     %ecx,%eax
or     %edi,%eax
ret

LLVM IR (-O0):
define i32 @xrop3_184_0_1(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
store i32 255, i32* %5
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = shl i32 %12, 8
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = or i32 %13, %15
store i32 %16, i32* %6
%17 = load i8, i8* %4
%18 = zext i8 %17 to i32
%19 = shl i32 %18, 8
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = or i32 %19, %21
store i32 %22, i32* %7
%23 = load i32, i32* %5
%24 = load i32, i32* %7
%25 = xor i32 %23, %24
store i32 %25, i32* %10
%26 = load i32, i32* %6
%27 = load i32, i32* %10
%28 = and i32 %26, %27
store i32 %28, i32* %9
%29 = load i32, i32* %7
%30 = load i32, i32* %9
%31 = xor i32 %29, %30
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = load i32, i32* %6
%34 = and i32 %32, %33
%35 = load i32, i32* %8
%36 = load i32, i32* %7
%37 = xor i32 %36, -1
%38 = and i32 %35, %37
%39 = or i32 %34, %38
%40 = load i32, i32* %7
%41 = load i32, i32* %6
%42 = xor i32 %41, -1
%43 = and i32 %40, %42
%44 = load i32, i32* %5
%45 = and i32 %43, %44
%46 = or i32 %39, %45
ret i32 %46
}

LLVM IR (-O2):
define i32 @xrop3_184_0_1(i8 zeroext %0, i8 zeroext %1) {
%3 = zext i8 %0 to i32
%4 = mul nuw nsw i32 %3, 257
%5 = zext i8 %1 to i32
%6 = mul nuw nsw i32 %5, 257
%7 = xor i32 %6, 255
%8 = and i32 %7, %4
%9 = xor i32 %8, %6
%10 = and i32 %9, %4
%11 = xor i32 %6, -1
%12 = and i32 %8, %11
%13 = xor i32 %4, -1
%14 = and i32 %13, %5
%15 = or i32 %12, %14
%16 = or i32 %15, %10
ret i32 %16
}
/* Variables and functions */
int /*<<< orphan*/ hello(int);
int main(void) {
  hello(3);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
call   1030 <hello@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @hello(i32 3)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ f(int);
int /*<<< orphan*/ printf(char *);
main() {
  int x;
  x = 3;
  f(x);
  printf("MAIN");
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
call   1030 <f@plt>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"MAIN\00"
define i32 @main() {
%1 = tail call i32 @f(i32 3)
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
void _rpmalloc_spin(void) { __asm__ volatile("pause" ::: "memory"); }


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

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

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

LLVM IR (-O2):
define void @_rpmalloc_spin() {
tail call void asm sideeffect "pause", "~{memory},~{dirflag},~{fpsr},~{flags}"()
ret void
}
char lowerToUppercase(char c) {
  if ('a' <= c && c <= 'z') {
    return c + 'A' - 'a';
  }
  return c;
}


x86 assembly (clang, -O0):
<lowerToUppercase>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%ecx
mov    $0x61,%eax
cmp    %ecx,%eax
jg     113a <lowerToUppercase+0x3a>
movsbl -0x2(%rbp),%eax
cmp    $0x7a,%eax
jg     113a <lowerToUppercase+0x3a>
movsbl -0x2(%rbp),%eax
add    $0x41,%eax
sub    $0x61,%eax
mov    %al,-0x1(%rbp)
jmp    1140 <lowerToUppercase+0x40>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<lowerToUppercase>:
lea    -0x61(%rdi),%eax
lea    -0x20(%rdi),%ecx
cmp    $0x1a,%al
movzbl %cl,%eax
cmovae %edi,%eax
ret

LLVM IR (-O0):
define signext i8 @lowerToUppercase(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp sle i32 97, %5
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 122
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = add nsw i32 %13, 65
%15 = sub nsw i32 %14, 97
%16 = trunc i32 %15 to i8
store i8 %16, i8* %2
br label %19
17: ; preds = %7, %1
%18 = load i8, i8* %3
store i8 %18, i8* %2
br label %19
19: ; preds = %17, %11
%20 = load i8, i8* %2
ret i8 %20
}

LLVM IR (-O2):
define signext i8 @lowerToUppercase(i8 signext %0) {
%2 = add i8 %0, -97
%3 = icmp ult i8 %2, 26
%4 = add i8 %0, -32
%5 = select i1 %3, i8 %4, i8 %0
ret i8 %5
}
/* Variables and functions */
int /*<<< orphan*/ proc_mutex_fcntl_setup();
int /*<<< orphan*/ proc_mutex_sysv_setup();
void apr_proc_mutex_unix_setup_lock(void) {
  proc_mutex_sysv_setup();
  proc_mutex_fcntl_setup();
}


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

x86 assembly (clang, -O2):
<apr_proc_mutex_unix_setup_lock>:
push   %rax
xor    %eax,%eax
call   1030 <proc_mutex_sysv_setup@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <proc_mutex_fcntl_setup@plt>

LLVM IR (-O0):
define void @apr_proc_mutex_unix_setup_lock() {
%1 = call i32 (...) @proc_mutex_sysv_setup()
%2 = call i32 (...) @proc_mutex_fcntl_setup()
ret void
}

LLVM IR (-O2):
define void @apr_proc_mutex_unix_setup_lock() {
%1 = tail call i32 (...) @proc_mutex_sysv_setup()
%2 = tail call i32 (...) @proc_mutex_fcntl_setup()
ret void
}
/* Type definitions */
typedef unsigned long long uint64_t;

/* Variables and functions */
uint64_t random_number(uint64_t prv_number) {
  return prv_number * 4294967311ULL + 17;
}


x86 assembly (clang, -O0):
<random_number>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movabs $0x10000000f,%rax
imul   -0x8(%rbp),%rax
add    $0x11,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_number>:
movabs $0x10000000f,%rax
imul   %rdi,%rax
add    $0x11,%rax
ret

LLVM IR (-O0):
define i64 @random_number(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = mul i64 %3, 4294967311
%5 = add i64 %4, 17
ret i64 %5
}

LLVM IR (-O2):
define i64 @random_number(i64 %0) {
%2 = mul i64 %0, 4294967311
%3 = add i64 %2, 17
ret i64 %3
}
int test_imm_99uint64_midword_reg(unsigned long long val) {
  return ((val >> 16) & (0x99 << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_99uint64_midword_reg>:
test   $0x990000,%edi
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_99uint64_midword_reg(i64 %0) {
%2 = and i64 %0, 10027008
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
int vde_chain_nm2_init(int *n_in, int *n_out, int *n_int, int *n_real) {
  if (n_in)
    *n_in = 4;
  if (n_out)
    *n_out = 3;
  if (n_int)
    *n_int = 0;
  if (n_real)
    *n_real = 0;
  return 0;
}


x86 assembly (clang, -O0):
<vde_chain_nm2_init>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1129 <vde_chain_nm2_init+0x29>
mov    -0x8(%rbp),%rax
movl   $0x4,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     113e <vde_chain_nm2_init+0x3e>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1153 <vde_chain_nm2_init+0x53>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     1168 <vde_chain_nm2_init+0x68>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<vde_chain_nm2_init>:
test   %rdi,%rdi
je     110b <vde_chain_nm2_init+0xb>
movl   $0x4,(%rdi)
test   %rsi,%rsi
je     1116 <vde_chain_nm2_init+0x16>
movl   $0x3,(%rsi)
test   %rdx,%rdx
je     1121 <vde_chain_nm2_init+0x21>
movl   $0x0,(%rdx)
test   %rcx,%rcx
je     112c <vde_chain_nm2_init+0x2c>
movl   $0x0,(%rcx)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @vde_chain_nm2_init(i32* writeonly %0, i32* writeonly %1, i32* writeonly %2, i32* writeonly %3) {
%5 = icmp eq i32* %0, null
br i1 %5, label %7, label %6
6: ; preds = %4
store i32 4, i32* %0
br label %7
7: ; preds = %6, %4
%8 = icmp eq i32* %1, null
br i1 %8, label %10, label %9
9: ; preds = %7
store i32 3, i32* %1
br label %10
10: ; preds = %9, %7
%11 = icmp eq i32* %2, null
br i1 %11, label %13, label %12
12: ; preds = %10
store i32 0, i32* %2
br label %13
13: ; preds = %12, %10
%14 = icmp eq i32* %3, null
br i1 %14, label %16, label %15
15: ; preds = %13
store i32 0, i32* %3
br label %16
16: ; preds = %15, %13
ret i32 0
}
/* Variables and functions */
double RAND_MAX;
scalar_t__ rand();
int random_int(int d, int f) {
  double r;
  r = (double)rand();
  return (int)d + ((r / RAND_MAX) * (f - d - 1)) + 1;
}


x86 assembly (clang, -O0):
<random_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
mov    0x2ea8(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe9f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_int>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cvtsi2sd %rax,%xmm0
cvtsi2sd %ebp,%xmm1
mov    0x2eba(%rip),%rax
divsd  (%rax),%xmm0
not    %ebp
add    %ebx,%ebp
cvtsi2sd %ebp,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
addsd  0xeb6(%rip),%xmm2
cvttsd2si %xmm2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @random_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i64 (...) @rand()
%7 = sitofp i64 %6 to double
store double %7, double* %5
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to double
%10 = load double, double* %5
%11 = load double, double* @RAND_MAX
%12 = fdiv double %10, %11
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = sub nsw i32 %13, %14
%16 = sub nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double %12, double %17, double %9)
%19 = fadd double %18, 1.000000e+00
%20 = fptosi double %19 to i32
ret i32 %20
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @random_int(i32 %0, i32 %1) {
%3 = tail call i64 (...) @rand()
%4 = sitofp i64 %3 to double
%5 = sitofp i32 %0 to double
%6 = load double, double* @RAND_MAX
%7 = fdiv double %4, %6
%8 = xor i32 %0, -1
%9 = add i32 %8, %1
%10 = sitofp i32 %9 to double
%11 = tail call double @llvm.fmuladd.f64(double %7, double %10, double %5)
%12 = fadd double %11, 1.000000e+00
%13 = fptosi double %12 to i32
ret i32 %13
}
/* Variables and functions */
int /*<<< orphan*/ default_handler();
__attribute__((weak)) void SPI6_IRQHandler() { default_handler(); }


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

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

LLVM IR (-O0):
define weak void @SPI6_IRQHandler() {
%1 = call i32 (...) @default_handler()
ret void
}

LLVM IR (-O2):
define weak void @SPI6_IRQHandler() {
%1 = tail call i32 (...) @default_handler()
ret void
}
float test1f(float a) { return -a; }


x86 assembly (clang, -O0):
<test1f>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1f>:
xorps  0xef9(%rip),%xmm0
ret

LLVM IR (-O0):
define float @test1f(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fneg float %3
ret float %4
}

LLVM IR (-O2):
define float @test1f(float %0) {
%2 = fneg float %0
ret float %2
}
int fix_bad_code(char *pstring) {
  if (*pstring || !pstring)
    return 0;
  while (*pstring = '\0')
    ;
  pstring = 'Z';
  return 1;
}


x86 assembly (clang, -O0):
<fix_bad_code>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1123 <fix_bad_code+0x23>
cmpq   $0x0,-0x10(%rbp)
jne    112f <fix_bad_code+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    115f <fix_bad_code+0x5f>
jmp    1134 <fix_bad_code+0x34>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
test   $0x1,%al
jne    114a <fix_bad_code+0x4a>
jmp    114f <fix_bad_code+0x4f>
jmp    1134 <fix_bad_code+0x34>
mov    $0x5a,%eax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_bad_code>:
xor    %eax,%eax
cmpb   $0x0,(%rdi)
je     1108 <fix_bad_code+0x8>
ret
movb   $0x0,(%rdi)
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @fix_bad_code(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %1
store i8 0, i8* %0
br label %5
5: ; preds = %1, %4
%6 = phi i32 [ 1, %4 ], [ 0, %1 ]
ret i32 %6
}
/* Variables and functions */
int foo(int);
int main(void) { return foo(((1024 * 512) + 1)); }


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

x86 assembly (clang, -O2):
<main>:
mov    $0x80001,%edi
jmp    1030 <foo@plt>

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @foo(i32 524289)
ret i32 %1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
int main() {
  char a[] = {'x', 'y', 'z', '\0'};
  char *b = "xyz";
  printf("%s %s\n", a, b + 1);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x7a7978,0x4(%rsp)
lea    0xee4(%rip),%rdi
lea    0xeda(%rip),%rdx
lea    0x4(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"xyz\00"
@.str.1 = [7 x i8] c"%s %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 8026488, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 1))
ret i32 0
}