xunge/DecIR huggingface dataset:
int clamp(int val, int minval, int maxval) {
  if (val < minval)
    return minval;
  if (val > maxval)
    return maxval;
  return val;
}


x86 assembly (clang, -O0):
<clamp>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1124 <clamp+0x24>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1141 <clamp+0x41>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    113b <clamp+0x3b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1141 <clamp+0x41>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<clamp>:
mov    %edx,%eax
cmp    %edx,%edi
cmovle %edi,%eax
cmp    %esi,%edi
cmovl  %esi,%eax
ret

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

LLVM IR (-O2):
define i32 @clamp(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %0, %1
%5 = icmp sgt i32 %0, %2
%6 = select i1 %5, i32 %2, i32 %0
%7 = select i1 %4, i32 %1, i32 %6
ret i32 %7
}
void WWDGEnable(unsigned long ulBase) {
  ;
  (*((volatile unsigned long *)(0x40002C00))) |= 0x00000080;
}


x86 assembly (clang, -O0):
<WWDGEnable>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    $0x40002c00,%eax
mov    (%rax),%rcx
or     $0x80,%rcx
mov    $0x40002c00,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<WWDGEnable>:
orq    $0x80,0x40002c00
ret

LLVM IR (-O0):
define void @WWDGEnable(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load volatile i64, i64* inttoptr (i64 1073753088 to i64*)
%4 = or i64 %3, 128
store volatile i64 %4, i64* inttoptr (i64 1073753088 to i64*)
ret void
}

LLVM IR (-O2):
define void @WWDGEnable(i64 %0) {
%2 = load volatile i64, i64* inttoptr (i64 1073753088 to i64*)
%3 = or i64 %2, 128
store volatile i64 %3, i64* inttoptr (i64 1073753088 to i64*)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ CreatePath(char *);
int LoadFile(char *, void **);
int /*<<< orphan*/ SaveFile(char *, void *, int);
int /*<<< orphan*/ free(void *);
void QCopyFile(char *from, char *to) {
  void *buffer;
  int length;
  length = LoadFile(from, &buffer);
  CreatePath(to);
  SaveFile(to, buffer, length);
  free(buffer);
}


x86 assembly (clang, -O0):
<QCopyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <LoadFile@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <CreatePath@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <SaveFile@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QCopyFile>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rsp,%rsi
call   1060 <LoadFile@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <CreatePath@plt>
mov    (%rsp),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <SaveFile@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @QCopyFile(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @LoadFile(i8* %7, i8** %5)
store i32 %8, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @CreatePath(i8* %9)
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = call i32 @SaveFile(i8* %11, i8* %12, i32 %13)
%15 = load i8*, i8** %5
%16 = call i32 @free(i8* %15)
ret void
}

LLVM IR (-O2):
define void @QCopyFile(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @LoadFile(i8* %0, i8** %3)
%6 = call i32 @CreatePath(i8* %1)
%7 = load i8*, i8** %3
%8 = call i32 @SaveFile(i8* %1, i8* %7, i32 %5)
%9 = load i8*, i8** %3
%10 = call i32 @free(i8* %9)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ writeDebugStreamLine(char *);
void writeEndingCodeOutput() { writeDebugStreamLine("}"); }


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

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

LLVM IR (-O0):
@.str = [2 x i8] c"}\00"
define void @writeEndingCodeOutput() {
%1 = call i32 @writeDebugStreamLine(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"}\00"
define void @writeEndingCodeOutput() {
%1 = tail call i32 @writeDebugStreamLine(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ little_endian_to_native(void *, char *);
void WavpackLittleEndianToNative(void *data, char *format) {
  little_endian_to_native(data, format);
}


x86 assembly (clang, -O0):
<WavpackLittleEndianToNative>:
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 <little_endian_to_native@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WavpackLittleEndianToNative>:
jmp    1030 <little_endian_to_native@plt>

LLVM IR (-O0):
define void @WavpackLittleEndianToNative(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = call i32 @little_endian_to_native(i8* %5, i8* %6)
ret void
}

LLVM IR (-O2):
define void @WavpackLittleEndianToNative(i8* %0, i8* %1) {
%3 = tail call i32 @little_endian_to_native(i8* %0, i8* %1)
ret void
}
void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}


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

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

LLVM IR (-O0):
%struct.pci_dev = type opaque
%struct.fb_info = type opaque
define void @vga_switcheroo_client_fb_set(%struct.pci_dev* %0, %struct.fb_info* %1) {
%3 = alloca %struct.pci_dev*
%4 = alloca %struct.fb_info*
store %struct.pci_dev* %0, %struct.pci_dev** %3
store %struct.fb_info* %1, %struct.fb_info** %4
ret void
}

LLVM IR (-O2):
%struct.pci_dev = type opaque
%struct.fb_info = type opaque
define void @vga_switcheroo_client_fb_set(%struct.pci_dev* nocapture %0, %struct.fb_info* nocapture %1) {
ret void
}
/* Variables and functions */
double M_PI_2;
double sin(double);
double LSKeyframeAnimationFunctionEaseOutSine(double t, double b, double c,
                                              double d) {
  return c * sin(t / d * (M_PI_2)) + b;
}


x86 assembly (clang, -O0):
<LSKeyframeAnimationFunctionEaseOutSine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    0x2ea1(%rip),%rax
mulsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LSKeyframeAnimationFunctionEaseOutSine>:
sub    $0x18,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
divsd  %xmm3,%xmm0
mov    0x2ebd(%rip),%rax
mulsd  (%rax),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@M_PI_2 = global double 0.000000e+00
define double @LSKeyframeAnimationFunctionEaseOutSine(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %7
%10 = load double, double* %5
%11 = load double, double* %8
%12 = fdiv double %10, %11
%13 = load double, double* @M_PI_2
%14 = fmul double %12, %13
%15 = call double @sin(double %14)
%16 = load double, double* %6
%17 = call double @llvm.fmuladd.f64(double %9, double %15, double %16)
ret double %17
}

LLVM IR (-O2):
@M_PI_2 = global double 0.000000e+00
define double @LSKeyframeAnimationFunctionEaseOutSine(double %0, double %1, double %2, double %3) {
%5 = fdiv double %0, %3
%6 = load double, double* @M_PI_2
%7 = fmul double %5, %6
%8 = tail call double @sin(double %7)
%9 = tail call double @llvm.fmuladd.f64(double %2, double %8, double %1)
ret double %9
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
void Close_Report(FILE *Report) {
  fclose(Report);
  exit(0);
}


x86 assembly (clang, -O0):
<Close_Report>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<Close_Report>:
push   %rax
call   1030 <fclose@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define void @Close_Report(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @fclose(i32* %3)
%5 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define void @Close_Report(i32* nocapture %0) {
%2 = tail call i32 @fclose(i32* %0)
%3 = tail call i32 @exit(i32 0)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ sll_close();
int /*<<< orphan*/ sll_init(char *, int);
int /*<<< orphan*/ sll_log(int, char *);
int main(int argc, char **argv) {
  sll_init("sll_example.log", 1);
  sll_log(0, "debug_lvl message");
  sll_log(1, "info_lvl message");
  sll_log(3, "error_lvl message");
  sll_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x1,%esi
call   1050 <sll_init@plt>
xor    %edi,%edi
lea    0xeb0(%rip),%rsi
call   1040 <sll_log@plt>
mov    $0x1,%edi
lea    0xeb1(%rip),%rsi
call   1040 <sll_log@plt>
mov    $0x3,%edi
lea    0xeb1(%rip),%rsi
call   1040 <sll_log@plt>
mov    $0x0,%al
call   1030 <sll_close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
mov    $0x1,%esi
call   1050 <sll_init@plt>
lea    0xec7(%rip),%rsi
xor    %edi,%edi
call   1040 <sll_log@plt>
lea    0xecb(%rip),%rsi
mov    $0x1,%edi
call   1040 <sll_log@plt>
lea    0xecb(%rip),%rsi
mov    $0x3,%edi
call   1040 <sll_log@plt>
xor    %eax,%eax
call   1030 <sll_close@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"sll_example.log\00"
@.str.1 = [18 x i8] c"debug_lvl message\00"
@.str.2 = [17 x i8] c"info_lvl message\00"
@.str.3 = [18 x i8] c"error_lvl message\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @sll_init(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = call i32 @sll_log(i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @sll_log(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @sll_log(i32 3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (...) @sll_close()
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"sll_example.log\00"
@.str.1 = [18 x i8] c"debug_lvl message\00"
@.str.2 = [17 x i8] c"info_lvl message\00"
@.str.3 = [18 x i8] c"error_lvl message\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @sll_init(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = tail call i32 @sll_log(i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @sll_log(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @sll_log(i32 3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 (...) @sll_close()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ test(int);
int /*<<< orphan*/ test2(int);
int main() {
  test(5);
  test(-5);
  test2(0);
  test2(1);
  test2(2);
  test2(3);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0x5,%edi
call   1040 <test@plt>
mov    $0xfffffffb,%edi
call   1040 <test@plt>
xor    %edi,%edi
call   1030 <test2@plt>
mov    $0x1,%edi
call   1030 <test2@plt>
mov    $0x2,%edi
call   1030 <test2@plt>
mov    $0x3,%edi
call   1030 <test2@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x5,%edi
call   1040 <test@plt>
mov    $0xfffffffb,%edi
call   1040 <test@plt>
xor    %edi,%edi
call   1030 <test2@plt>
mov    $0x1,%edi
call   1030 <test2@plt>
mov    $0x2,%edi
call   1030 <test2@plt>
mov    $0x3,%edi
call   1030 <test2@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = call i32 @test(i32 5)
%2 = call i32 @test(i32 -5)
%3 = call i32 @test2(i32 0)
%4 = call i32 @test2(i32 1)
%5 = call i32 @test2(i32 2)
%6 = call i32 @test2(i32 3)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @test(i32 5)
%2 = tail call i32 @test(i32 -5)
%3 = tail call i32 @test2(i32 0)
%4 = tail call i32 @test2(i32 1)
%5 = tail call i32 @test2(i32 2)
%6 = tail call i32 @test2(i32 3)
ret i32 0
}
double foo(double x, double y) {
  double t = -x * y;
  return -t;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
mulsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @foo(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %3
%7 = fneg double %6
%8 = load double, double* %4
%9 = fmul double %7, %8
store double %9, double* %5
%10 = load double, double* %5
%11 = fneg double %10
ret double %11
}

LLVM IR (-O2):
define double @foo(double %0, double %1) {
%3 = fmul double %0, %1
ret double %3
}
char *RCSid() {
  return RCSid("$Id: doc2tex.c,v 1.24 2011/10/13 17:45:43 sfeam Exp $");
}


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

x86 assembly (clang, -O2):
<RCSid>:
jmp    1100 <RCSid>

LLVM IR (-O0):
@.str = [54 x i8] c"$Id: doc2tex.c,v 1.24 2011/10/13 17:45:43 sfeam Exp $\00"
define i8* @RCSid() {
%1 = call i8* (i8*, ...) bitcast (i8* ()* @RCSid to i8* (i8*, ...)*)(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
ret i8* %1
}

LLVM IR (-O2):
define noalias i8* @RCSid() {
br label %1
1: ; preds = %1, %0
br label %1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int treeprt(void *data, int lvl) {
  printf("(%d; %d)\n", lvl, *(int *)data);
  return 0;
}


x86 assembly (clang, -O0):
<treeprt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<treeprt>:
push   %rax
mov    (%rdi),%edx
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"(%d; %d)\0A\00"
define i32 @treeprt(i8* nocapture %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %4)
ret i32 0
}
bfill(dst, len, fill) register char *dst;
register int len;
register int fill;
{
  while (--len >= 0)
    *dst++ = fill;
}


x86 assembly (clang, -O0):
<bfill>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     113b <bfill+0x3b>
mov    -0x18(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    110e <bfill+0xe>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfill>:
test   %esi,%esi
jle    1125 <bfill+0x15>
push   %rax
mov    %esi,%eax
mov    %edx,%esi
mov    %rax,%rdx
call   1030 <memset@plt>
add    $0x8,%rsp
ret

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

LLVM IR (-O2):
define i32 @bfill(i8* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = trunc i32 %2 to i8
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %5, %3
ret i32 undef
}
int mc_base64_declen(int len) { return (((len + 3) / 4) * 3) + 1; }


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

x86 assembly (clang, -O2):
<mc_base64_declen>:
lea    0x3(%rdi),%eax
add    $0x6,%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x2,%edi
lea    (%rdi,%rdi,2),%eax
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @mc_base64_declen(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add nsw i32 %3, 3
%5 = sdiv i32 %4, 4
%6 = mul nsw i32 %5, 3
%7 = add nsw i32 %6, 1
ret i32 %7
}

LLVM IR (-O2):
define i32 @mc_base64_declen(i32 %0) {
%2 = add nsw i32 %0, 3
%3 = sdiv i32 %2, 4
%4 = mul nsw i32 %3, 3
%5 = add nsw i32 %4, 1
ret i32 %5
}
OP(op, cf) { RST(0x08); }


x86 assembly (clang, -O0):
<OP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x8,%edi
mov    $0x0,%al
call   1030 <RST@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OP>:
mov    $0x8,%edi
xor    %eax,%eax
jmp    1030 <RST@plt>

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

LLVM IR (-O2):
define i32 @OP(i32 %0, i32 %1) {
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @RST to i32 (i32, ...)*)(i32 8)
ret i32 undef
}
int sub_mod_int(int a, int b, int m) {
  a -= b;
  if (a < 0)
    a += m;
  return a;
}


x86 assembly (clang, -O0):
<sub_mod_int>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    112b <sub_mod_int+0x2b>
mov    -0xc(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_mod_int>:
sub    %esi,%edi
mov    %edi,%eax
sar    $0x1f,%eax
and    %edx,%eax
add    %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @sub_mod_int(i32 %0, i32 %1, i32 %2) {
%4 = sub nsw i32 %0, %1
%5 = icmp slt i32 %4, 0
%6 = select i1 %5, i32 %2, i32 0
%7 = add nsw i32 %6, %4
ret i32 %7
}
/* Type definitions */
typedef int /*<<< orphan*/ z_stream;

/* Variables and functions */
int inflateInit2(int /*<<< orphan*/ *, int);
int streaming_commons_inflate_init2(z_stream *stream, int window_bits) {
  return inflateInit2(stream, window_bits);
}


x86 assembly (clang, -O0):
<streaming_commons_inflate_init2>:
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 <inflateInit2@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<streaming_commons_inflate_init2>:
jmp    1030 <inflateInit2@plt>

LLVM IR (-O0):
define i32 @streaming_commons_inflate_init2(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 @inflateInit2(i32* %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @streaming_commons_inflate_init2(i32* %0, i32 %1) {
%3 = tail call i32 @inflateInit2(i32* %0, i32 %1)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ _log(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ exit(int);
char const *strerror(int);
void die(const char *msg, int errno_) {
  _log(LOG_CRIT, "%s\n", msg);
  if (errno_ > 0)
    _log(LOG_CRIT, "%s\n", strerror(errno_));
  exit(1);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xead(%rip),%rsi
call   1030 <_log@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1188 <die+0x58>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe7d(%rip),%rsi
call   1030 <_log@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rdx
mov    0x2ea9(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xeb7(%rip),%rsi
call   1030 <_log@plt>
test   %ebx,%ebx
jle    116d <die+0x3d>
mov    0x0(%rbp),%ebp
mov    %ebx,%edi
call   1050 <strerror@plt>
lea    0xe9d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1030 <_log@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@LOG_CRIT = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @die(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* @LOG_CRIT
%6 = load i8*, i8** %3
%7 = call i32 @_log(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @LOG_CRIT
%12 = load i32, i32* %4
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @_log(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %2
%16 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@LOG_CRIT = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @die(i8* %0, i32 %1) {
%3 = load i32, i32* @LOG_CRIT
%4 = tail call i32 @_log(i32 %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @LOG_CRIT
%8 = tail call i8* @strerror(i32 %1)
%9 = tail call i32 @_log(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %6, %2
%11 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void printusage(int argc, char *argv[]) {
  printf("Usage: %s -n BLOCKCOUNT -f FILE\n", argv[0]);
}


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

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

LLVM IR (-O0):
@.str = [33 x i8] c"Usage: %s -n BLOCKCOUNT -f FILE\0A\00"
define void @printusage(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = load i8**, i8*** %4
%6 = getelementptr inbounds i8*, i8** %5, i64 0
%7 = load i8*, i8** %6
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %7)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Usage: %s -n BLOCKCOUNT -f FILE\0A\00"
define void @printusage(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}
void __attribute__((weak)) otg_fs_wkup_isr() { debug_handler(__FUNCTION__); }


x86 assembly (clang, -O0):
<otg_fs_wkup_isr>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <debug_handler@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<otg_fs_wkup_isr>:
lea    0xee9(%rip),%rdi
xor    %eax,%eax
jmp    1030 <debug_handler@plt>

LLVM IR (-O0):
@__FUNCTION__.otg_fs_wkup_isr = [16 x i8] c"otg_fs_wkup_isr\00"
define weak void @otg_fs_wkup_isr() {
%1 = call i32 (i8*, ...) bitcast (i32 (...)* @debug_handler to i32 (i8*, ...)*)(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.otg_fs_wkup_isr, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__FUNCTION__.otg_fs_wkup_isr = [16 x i8] c"otg_fs_wkup_isr\00"
define weak void @otg_fs_wkup_isr() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @debug_handler to i32 (i8*, ...)*)(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.otg_fs_wkup_isr, i64 0, i64 0))
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ curs_set(int);
int /*<<< orphan*/ echo();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ wgetnstr(int /*<<< orphan*/ *, char *, size_t);
void readstr(WINDOW *w, char *buf, size_t buflen) {
  echo();
  curs_set(1);
  wgetnstr(w, buf, buflen);
  curs_set(0);
  noecho();
}


x86 assembly (clang, -O0):
<readstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1030 <echo@plt>
mov    $0x1,%edi
call   1060 <curs_set@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <wgetnstr@plt>
xor    %edi,%edi
call   1060 <curs_set@plt>
mov    $0x0,%al
call   1040 <noecho@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readstr>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <echo@plt>
mov    $0x1,%edi
call   1060 <curs_set@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <wgetnstr@plt>
xor    %edi,%edi
call   1060 <curs_set@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <noecho@plt>

LLVM IR (-O0):
define void @readstr(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = call i32 (...) @echo()
%8 = call i32 @curs_set(i32 1)
%9 = load i32*, i32** %4
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = call i32 @wgetnstr(i32* %9, i8* %10, i64 %11)
%13 = call i32 @curs_set(i32 0)
%14 = call i32 (...) @noecho()
ret void
}

LLVM IR (-O2):
define void @readstr(i32* %0, i8* %1, i64 %2) {
%4 = tail call i32 (...) @echo()
%5 = tail call i32 @curs_set(i32 1)
%6 = tail call i32 @wgetnstr(i32* %0, i8* %1, i64 %2)
%7 = tail call i32 @curs_set(i32 0)
%8 = tail call i32 (...) @noecho()
ret void
}
void lan2_recv_handler(void *rs) { return; }


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

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

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

LLVM IR (-O2):
define void @lan2_recv_handler(i8* nocapture %0) {
ret void
}
/* Variables and functions */
float rcp(float);
float NewVisibility(float ldh, float alpha) {
  float k = alpha * 0.5;
  float k2 = k * k;
  float invK2 = 1.0f - k2;
  float vis = rcp(ldh * ldh * invK2 + k2);
  return vis;
}


x86 assembly (clang, -O0):
<NewVisibility>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xed5(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xea9(%rip),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <rcp@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NewVisibility>:
mulss  0xee8(%rip),%xmm1
mulss  %xmm1,%xmm1
movss  0xee0(%rip),%xmm2
subss  %xmm1,%xmm2
mulss  %xmm0,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
jmp    1030 <rcp@plt>

LLVM IR (-O0):
define float @NewVisibility(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %3
store float %1, float* %4
%9 = load float, float* %4
%10 = fpext float %9 to double
%11 = fmul double %10, 5.000000e-01
%12 = fptrunc double %11 to float
store float %12, float* %5
%13 = load float, float* %5
%14 = load float, float* %5
%15 = fmul float %13, %14
store float %15, float* %6
%16 = load float, float* %6
%17 = fsub float 1.000000e+00, %16
store float %17, float* %7
%18 = load float, float* %3
%19 = load float, float* %3
%20 = fmul float %18, %19
%21 = load float, float* %7
%22 = load float, float* %6
%23 = call float @llvm.fmuladd.f32(float %20, float %21, float %22)
%24 = call float @rcp(float %23)
store float %24, float* %8
%25 = load float, float* %8
ret float %25
}

LLVM IR (-O2):
define float @NewVisibility(float %0, float %1) {
%3 = fmul float %1, 5.000000e-01
%4 = fmul float %3, %3
%5 = fsub float 1.000000e+00, %4
%6 = fmul float %0, %0
%7 = tail call float @llvm.fmuladd.f32(float %6, float %5, float %4)
%8 = tail call float @rcp(float %7)
ret float %8
}
int test_imm_86int16_reg(short val) {
  return ((val) & (0x86 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_86int16_reg>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%edx
and    $0x86,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @test_imm_86int16_reg(i16 signext %0) {
%2 = and i16 %0, 134
%3 = icmp eq i16 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ swift_main();
int main() { swift_main(); }


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

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

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @swift_main()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ set_mode(int);
int f_v2(int mode, unsigned char **sec, float *data, unsigned int ndata,
         char *inv_out, void **local) {
  set_mode(2);
  return 0;
}


x86 assembly (clang, -O0):
<f_v2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x2,%edi
call   1030 <set_mode@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @f_v2(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%13 = call i32 @set_mode(i32 2)
ret i32 0
}

LLVM IR (-O2):
define i32 @f_v2(i32 %0, i8** nocapture readnone %1, float* nocapture readnone %2, i32 %3, i8* nocapture readnone %4, i8** nocapture readnone %5) {
%7 = tail call i32 @set_mode(i32 2)
ret i32 0
}
void _printTAB_bin(void) {}


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

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

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

LLVM IR (-O2):
define void @_printTAB_bin() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ BSP_UART_SendCongestionString(int /*<<< orphan*/, char *);
void HaltUndef(void) {
  BSP_UART_SendCongestionString(0, "Undefined instruction exception!!!\n\0");
  while (1)
    ;
}


x86 assembly (clang, -O0):
<HaltUndef>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
lea    0xee3(%rip),%rsi
call   1030 <BSP_UART_SendCongestionString@plt>
jmp    1122 <HaltUndef+0x12>

x86 assembly (clang, -O2):
<HaltUndef>:
push   %rax
lea    0xee8(%rip),%rsi
xor    %edi,%edi
call   1030 <BSP_UART_SendCongestionString@plt>
nop
jmp    1120 <HaltUndef+0x10>

LLVM IR (-O0):
@.str = [37 x i8] c"Undefined instruction exception!!!\0A\00\00"
define void @HaltUndef() {
%1 = call i32 @BSP_UART_SendCongestionString(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
br label %2
}

LLVM IR (-O2):
@.str = [37 x i8] c"Undefined instruction exception!!!\0A\00\00"
define void @HaltUndef() {
%1 = tail call i32 @BSP_UART_SendCongestionString(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
br label %2
}
int getLevel(char chr) {
  int level = -1;
  switch (chr) {
  case '+':
  case '-':
    level = 0;
    break;
  case '*':
  case '/':
    level = 1;
    break;
  case '(':
    level = -1;
    break;
  }
  return level;
}


x86 assembly (clang, -O0):
<getLevel>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffd8,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x7,%eax
ja     115a <getLevel+0x5a>
mov    -0x10(%rbp),%rax
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x8(%rbp)
jmp    115a <getLevel+0x5a>
movl   $0x1,-0x8(%rbp)
jmp    115a <getLevel+0x5a>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLevel>:
add    $0xffffffd6,%edi
mov    $0xffffffff,%eax
cmp    $0x5,%edi
ja     111a <getLevel+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @getLevel(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 -1, i32* %3
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %9 [
i32 43, label %6
i32 45, label %6
i32 42, label %7
i32 47, label %7
i32 40, label %8
]
6: ; preds = %1, %1
store i32 0, i32* %3
br label %9
7: ; preds = %1, %1
store i32 1, i32* %3
br label %9
8: ; preds = %1
store i32 -1, i32* %3
br label %9
9: ; preds = %1, %8, %7, %6
%10 = load i32, i32* %3
ret i32 %10
}

LLVM IR (-O2):
@switch.table.getLevel = [6 x i32] [i32 1, i32 0, i32 -1, i32 0, i32 -1, i32 1]
define i32 @getLevel(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -42
%4 = icmp ult i32 %3, 6
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.getLevel, i64 0, i64 %6
%8 = load i32, i32* %7
br label %9
9: ; preds = %5, %1
%10 = phi i32 [ -1, %1 ], [ %8, %5 ]
ret i32 %10
}
const struct exception_table_entry *
search_extable(const struct exception_table_entry *first,
               const struct exception_table_entry *last, unsigned long value) {
  return 0;
}


x86 assembly (clang, -O0):
<search_extable>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.exception_table_entry = type opaque
define %struct.exception_table_entry* @search_extable(%struct.exception_table_entry* %0, %struct.exception_table_entry* %1, i64 %2) {
%4 = alloca %struct.exception_table_entry*
%5 = alloca %struct.exception_table_entry*
%6 = alloca i64
store %struct.exception_table_entry* %0, %struct.exception_table_entry** %4
store %struct.exception_table_entry* %1, %struct.exception_table_entry** %5
store i64 %2, i64* %6
ret %struct.exception_table_entry* null
}

LLVM IR (-O2):
%struct.exception_table_entry = type opaque
define noalias %struct.exception_table_entry* @search_extable(%struct.exception_table_entry* nocapture readnone %0, %struct.exception_table_entry* nocapture readnone %1, i64 %2) {
ret %struct.exception_table_entry* null
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void ToConsole(char *sMessage) {
  FILE *hConsole;
  hConsole = fopen("/dev/console", "w");
  if (hConsole == NULL) {
    return;
  }
  fprintf(hConsole, "%s", sMessage);
  fclose(hConsole);
}


x86 assembly (clang, -O0):
<ToConsole>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <ToConsole+0x33>
jmp    1180 <ToConsole+0x50>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe9d(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ToConsole>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     116c <ToConsole+0x3c>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/console\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
define void @ToConsole(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
br label %14
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = load i8*, i8** %2
%11 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i32*, i32** %3
%13 = call i32 @fclose(i32* %12)
br label %14
14: ; preds = %8, %7
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/console\00"
@.str.1 = [2 x i8] c"w\00"
define void @ToConsole(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @fputs(i8* %0, i32* %2)
%6 = tail call i32 @fclose(i32* %2)
br label %7
7: ; preds = %1, %4
ret void
}
void DMTimerPreScalerClkDisable(unsigned int baseAdd) {
  (*((volatile unsigned int *)(baseAdd + (0x38)))) &= ~(0x00000020u);
}


x86 assembly (clang, -O0):
<DMTimerPreScalerClkDisable>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x38,%eax
mov    %eax,%eax
mov    (%rax),%ecx
and    $0xffffffdf,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<DMTimerPreScalerClkDisable>:
add    $0x38,%edi
andl   $0xffffffdf,(%rdi)
ret

LLVM IR (-O0):
define void @DMTimerPreScalerClkDisable(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add i32 %3, 56
%5 = zext i32 %4 to i64
%6 = inttoptr i64 %5 to i32*
%7 = load volatile i32, i32* %6
%8 = and i32 %7, -33
store volatile i32 %8, i32* %6
ret void
}

LLVM IR (-O2):
define void @DMTimerPreScalerClkDisable(i32 %0) {
%2 = add i32 %0, 56
%3 = zext i32 %2 to i64
%4 = inttoptr i64 %3 to i32*
%5 = load volatile i32, i32* %4
%6 = and i32 %5, -33
store volatile i32 %6, i32* %4
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int, int);
void main(int argc, char **argv) {
  char buffer[1000];
  FILE *badfile;
  memset(buffer, 0x90, sizeof(buffer));
  badfile = fopen("./badfile", "w");
  fwrite(buffer, 1000, 1, badfile);
  fclose(badfile);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x90,%esi
mov    $0x3e8,%edx
call   1040 <memset@plt>
lea    0xe91(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x408(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%rcx
mov    $0x3e8,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
mov    -0x408(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x90,%esi
mov    $0x3e8,%edx
call   1040 <memset@plt>
lea    0xe9a(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x3e8,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"./badfile\00"
@.str.1 = [2 x i8] c"w\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [1000 x i8]
%6 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 144, i32 1000)
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%11 = load i32*, i32** %6
%12 = call i32 @fwrite(i8* %10, i32 1000, i32 1, i32* %11)
%13 = load i32*, i32** %6
%14 = call i32 @fclose(i32* %13)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"./badfile\00"
@.str.1 = [2 x i8] c"w\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 144, i32 1000)
%6 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @fwrite(i8* %4, i32 1000, i32 1, i32* %6)
%8 = call i32 @fclose(i32* %6)
ret void
}
int do_msg(int severity) {
  extern int loglevel;
  return severity >= loglevel;
}


x86 assembly (clang, -O0):
<do_msg>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ecf(%rip),%rcx
cmp    (%rcx),%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_msg>:
mov    0x2ed9(%rip),%rcx
xor    %eax,%eax
cmp    %edi,(%rcx)
setle  %al
ret

LLVM IR (-O0):
@loglevel = external global i32
define i32 @do_msg(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @loglevel
%5 = icmp sge i32 %3, %4
%6 = zext i1 %5 to i32
ret i32 %6
}

LLVM IR (-O2):
@loglevel = external global i32
define i32 @do_msg(i32 %0) {
%2 = load i32, i32* @loglevel
%3 = icmp sle i32 %2, %0
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
void myprint(void) { puts("This is myprint!"); }


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

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

LLVM IR (-O0):
@.str = [17 x i8] c"This is myprint!\00"
define void @myprint() {
%1 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"This is myprint!\00"
define void @myprint() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int replaces(int, int, int);
int qreplace(int f, int n) { return (replaces(1, f, n)); }


x86 assembly (clang, -O0):
<qreplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0x1,%edi
call   1030 <replaces@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qreplace>:
mov    %esi,%edx
mov    %edi,%esi
mov    $0x1,%edi
jmp    1030 <replaces@plt>

LLVM IR (-O0):
define i32 @qreplace(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 @replaces(i32 1, i32 %5, i32 %6)
ret i32 %7
}

LLVM IR (-O2):
define i32 @qreplace(i32 %0, i32 %1) {
%3 = tail call i32 @replaces(i32 1, i32 %0, i32 %1)
ret i32 %3
}
/* Variables and functions */
int llvm_close(int);
__attribute__((visibility("hidden"))) int close(int fd) {
  return llvm_close(fd);
  return 0;
}


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

x86 assembly (clang, -O2):
<close>:
jmp    1030 <llvm_close@plt>

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

LLVM IR (-O2):
define hidden i32 @close(i32 %0) {
%2 = tail call i32 @llvm_close(i32 %0)
ret i32 %2
}