xunge/DecIR huggingface dataset:
long max(long a, long b) { return a > b ? a : b; }


x86 assembly (clang, -O0):
<max>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    1127 <max+0x27>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    112f <max+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<max>:
mov    %rsi,%rax
cmp    %rsi,%rdi
cmovg  %rdi,%rax
ret

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

LLVM IR (-O2):
define i64 @max(i64 %0, i64 %1) {
%3 = icmp sgt i64 %0, %1
%4 = select i1 %3, i64 %0, i64 %1
ret i64 %4
}
/* Variables and functions */
int /*<<< orphan*/ stackExample(char *);
int main() {
  stackExample("hi");
  stackExample("This is longer than 5 bytes.");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [3 x i8] c"hi\00"
@.str.1 = [29 x i8] c"This is longer than 5 bytes.\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @stackExample(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @stackExample(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"hi\00"
@.str.1 = [29 x i8] c"This is longer than 5 bytes.\00"
define i32 @main() {
%1 = tail call i32 @stackExample(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @stackExample(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}
int test_imm_15int32_mem(int *val) {
  return ((*val) & (0x15 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_15int32_mem(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = load i32, i32* %3
%5 = and i32 %4, 21
%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_15int32_mem(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = and i32 %2, 21
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int mycomp(const void *p1, const void *p2) {
  const double *a1 = (const double *)p1;
  const double *a2 = (const double *)p2;
  if (*a1 > *a2)
    return 1;
  else if (*a1 == *a2)
    return 0;
  else
    return -1;
}


x86 assembly (clang, -O0):
<mycomp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    113e <mycomp+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    116d <mycomp+0x6d>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
ucomisd (%rax),%xmm0
jne    1166 <mycomp+0x66>
jp     1166 <mycomp+0x66>
movl   $0x0,-0x4(%rbp)
jmp    116d <mycomp+0x6d>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mycomp>:
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm1
ucomisd %xmm1,%xmm0
cmpneqsd %xmm1,%xmm0
movq   %xmm0,%rcx
mov    $0x1,%eax
cmovbe %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @mycomp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to double*
%4 = bitcast i8* %1 to double*
%5 = load double, double* %3
%6 = load double, double* %4
%7 = fcmp ogt double %5, %6
%8 = fcmp une double %5, %6
%9 = sext i1 %8 to i32
%10 = select i1 %7, i32 1, i32 %9
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  printf("hello world from process ID %d\n", getpid());
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xec1(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"hello world from process ID %d\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @getpid()
%3 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [32 x i8] c"hello world from process ID %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @exit(i32 0)
unreachable
}
int do_043() { return 43; }


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

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

LLVM IR (-O0):
define i32 @do_043() {
ret i32 43
}

LLVM IR (-O2):
define i32 @do_043() {
ret i32 43
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void calc_error(const char *s) { fprintf(stderr, "%s\n", s); }


x86 assembly (clang, -O0):
<calc_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xed0(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_error>:
mov    %rdi,%rdx
mov    0x2ec6(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @calc_error(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
void ext4_xattr_inode_set_class(struct inode *ea_inode) {}


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

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

LLVM IR (-O0):
%struct.inode = type opaque
define void @ext4_xattr_inode_set_class(%struct.inode* %0) {
%2 = alloca %struct.inode*
store %struct.inode* %0, %struct.inode** %2
ret void
}

LLVM IR (-O2):
%struct.inode = type opaque
define void @ext4_xattr_inode_set_class(%struct.inode* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ error(char *, char const *);
int stub_operation(const char *func) {
  error("%s is not implemented\n", func);
  return -1;
}


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

x86 assembly (clang, -O2):
<stub_operation>:
push   %rax
mov    %rdi,%rsi
lea    0xee5(%rip),%rdi
call   1030 <error@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%s is not implemented\0A\00"
define i32 @stub_operation(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 -1
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s is not implemented\0A\00"
define i32 @stub_operation(i8* %0) {
%2 = tail call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
ret i32 -1
}
float lininterp(float x, float a, float b) { return a + x * (b - a); }


x86 assembly (clang, -O0):
<lininterp>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
subss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<lininterp>:
subss  %xmm1,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @lininterp(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%7 = load float, float* %5
%8 = load float, float* %4
%9 = load float, float* %6
%10 = load float, float* %5
%11 = fsub float %9, %10
%12 = call float @llvm.fmuladd.f32(float %8, float %11, float %7)
ret float %12
}

LLVM IR (-O2):
define float @lininterp(float %0, float %1, float %2) {
%4 = fsub float %2, %1
%5 = tail call float @llvm.fmuladd.f32(float %0, float %4, float %1)
ret float %5
}
int LZ4_sizeofStreamStateHC(void) { return 262192; }


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

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

LLVM IR (-O0):
define i32 @LZ4_sizeofStreamStateHC() {
ret i32 262192
}

LLVM IR (-O2):
define i32 @LZ4_sizeofStreamStateHC() {
ret i32 262192
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ swap(int *, int *, int *, int);
int main() {
  int a = 5;
  int b = 6;
  int tmp;
  swap(&a, &b, &tmp, sizeof(int));
  printf("a = %i\n", a);
  printf("b = %i\n", b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0x6,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x4,%ecx
call   1040 <swap@plt>
mov    -0x8(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x5,0x10(%rsp)
movl   $0x6,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
mov    $0x4,%ecx
call   1040 <swap@plt>
mov    0x10(%rsp),%esi
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"a = %i\0A\00"
@.str.1 = [8 x i8] c"b = %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 5, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 6, i32* %2
%6 = bitcast i32* %3 to i8*
%7 = call i32 @swap(i32* %1, i32* %2, i32* %3, i32 4)
%8 = load i32, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %10)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ write_port(unsigned short, int);
void configure_serial_buffer(unsigned short com) {
  write_port((com + 2), 0xC7);
}


x86 assembly (clang, -O0):
<configure_serial_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x2,%eax
mov    $0xc7,%esi
movzwl %ax,%edi
call   1030 <write_port@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configure_serial_buffer>:
add    $0x2,%edi
movzwl %di,%edi
mov    $0xc7,%esi
jmp    1030 <write_port@plt>

LLVM IR (-O0):
define void @configure_serial_buffer(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
%5 = add nsw i32 %4, 2
%6 = trunc i32 %5 to i16
%7 = call i32 @write_port(i16 zeroext %6, i32 199)
ret void
}

LLVM IR (-O2):
define void @configure_serial_buffer(i16 zeroext %0) {
%2 = add i16 %0, 2
%3 = tail call i32 @write_port(i16 zeroext %2, i32 199)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ strcpy(void *, char const *);
scalar_t__ strlen(char const *);
void *xmalloc(scalar_t__);
char *xstrdup(const char *s) {
  void *ptr = xmalloc(strlen(s) + 1);
  strcpy(ptr, s);
  return (char *)ptr;
}


x86 assembly (clang, -O0):
<xstrdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <xmalloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xstrdup>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @xstrdup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 1
%7 = call i8* @xmalloc(i64 %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = load i8*, i8** %2
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = load i8*, i8** %3
ret i8* %11
}

LLVM IR (-O2):
define i8* @xstrdup(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i8* @xmalloc(i64 %3)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
ret i8* %4
}
void f(int x) {
  _Bool test5;
  _Bool test6[x];
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @f(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i64
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %4
%9 = alloca i8, i64 %7
store i64 %7, i64* %5
%10 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
define void @f(i32 %0) {
ret void
}
int test_imm_BBuint8_mem(unsigned char *val) {
  return ((*val) & (-0xBB << 0)) ? -20 : -40;
}


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

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

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

LLVM IR (-O2):
define i32 @test_imm_BBuint8_mem(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = and i8 %2, 69
%4 = icmp eq i8 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
void FUNC_lang(void) {}


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

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

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

LLVM IR (-O2):
define void @FUNC_lang() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
main() { printf("Hello world!\n"); }


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

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

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

LLVM IR (-O2):
@str = [13 x i8] c"Hello world!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ alarm(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ sleep(int);
void ex(const char *s) {
  alarm(0);
  alarm(0);
  perror(s);
  sleep(1);
  exit(3);
}


x86 assembly (clang, -O0):
<ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1030 <alarm@plt>
xor    %edi,%edi
call   1030 <alarm@plt>
mov    -0x8(%rbp),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<ex>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
call   1030 <alarm@plt>
xor    %edi,%edi
call   1030 <alarm@plt>
mov    %rbx,%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define void @ex(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @alarm(i32 0)
%4 = call i32 @alarm(i32 0)
%5 = load i8*, i8** %2
%6 = call i32 @perror(i8* %5)
%7 = call i32 @sleep(i32 1)
%8 = call i32 @exit(i32 3)
unreachable
}

LLVM IR (-O2):
define void @ex(i8* nocapture %0) {
%2 = tail call i32 @alarm(i32 0)
%3 = tail call i32 @alarm(i32 0)
%4 = tail call i32 @perror(i8* %0)
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i32 @exit(i32 3)
unreachable
}
/* Variables and functions */
int mpow(int, int);
int squaredDist(int x1, int y1, int x2, int y2) {
  return (mpow((x1 - x2), 2) + mpow((y1 - y2), 2));
}


x86 assembly (clang, -O0):
<squaredDist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
sub    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1030 <mpow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
sub    -0x10(%rbp),%edi
mov    $0x2,%esi
call   1030 <mpow@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squaredDist>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %esi,%ebp
sub    %edx,%edi
mov    $0x2,%esi
call   1030 <mpow@plt>
mov    %eax,%ebx
sub    %r14d,%ebp
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <mpow@plt>
add    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @squaredDist(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = load i32, i32* %7
%11 = sub nsw i32 %9, %10
%12 = call i32 @mpow(i32 %11, i32 2)
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = sub nsw i32 %13, %14
%16 = call i32 @mpow(i32 %15, i32 2)
%17 = add nsw i32 %12, %16
ret i32 %17
}

LLVM IR (-O2):
define i32 @squaredDist(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %0, %2
%6 = tail call i32 @mpow(i32 %5, i32 2)
%7 = sub nsw i32 %1, %3
%8 = tail call i32 @mpow(i32 %7, i32 2)
%9 = add nsw i32 %8, %6
ret i32 %9
}
int calculate(int num) {
  int first = 0, second = 1, current = 1, sum = 0;
  while (current < num) {
    if (current % 2 == 0) {
      sum += current;
    }
    first = second;
    second = current;
    current = first + second;
  }
  return sum;
}


x86 assembly (clang, -O0):
<calculate>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1166 <calculate+0x66>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    114c <calculate+0x4c>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <calculate+0x23>
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate>:
xor    %eax,%eax
cmp    $0x2,%edi
jl     113a <calculate+0x3a>
mov    $0x1,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%esi
test   $0x1,%sil
mov    $0x0,%edx
cmove  %esi,%edx
add    %edx,%eax
add    %esi,%ecx
mov    %ecx,%edx
cmp    %edi,%ecx
mov    %esi,%ecx
jl     1120 <calculate+0x20>
ret

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

LLVM IR (-O2):
define i32 @calculate(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %3, label %13
3: ; preds = %1, %3
%4 = phi i32 [ %10, %3 ], [ 0, %1 ]
%5 = phi i32 [ %11, %3 ], [ 1, %1 ]
%6 = phi i32 [ %5, %3 ], [ 1, %1 ]
%7 = and i32 %5, 1
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 %5, i32 0
%10 = add nsw i32 %9, %4
%11 = add nsw i32 %5, %6
%12 = icmp slt i32 %11, %0
br i1 %12, label %3, label %13
13: ; preds = %3, %1
%14 = phi i32 [ 0, %1 ], [ %10, %3 ]
ret i32 %14
}
char contCode(ctype)
int ctype;
{
  if (ctype == 0)
    return ('r');
  else if (ctype == 1)
    return ('a');
  else
    return ('o');
}


x86 assembly (clang, -O0):
<contCode>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    111a <contCode+0x1a>
movb   $0x72,-0x1(%rbp)
jmp    1131 <contCode+0x31>
cmpl   $0x1,-0x8(%rbp)
jne    112d <contCode+0x2d>
movb   $0x61,-0x1(%rbp)
jmp    1131 <contCode+0x31>
movb   $0x6f,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<contCode>:
cmp    $0x1,%edi
mov    $0x61,%eax
mov    $0x6f,%ecx
cmove  %eax,%ecx
test   %edi,%edi
mov    $0x72,%eax
cmovne %ecx,%eax
ret

LLVM IR (-O0):
define signext i8 @contCode(i32 %0) {
%2 = alloca i8
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i8 114, i8* %2
br label %12
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %7
store i8 97, i8* %2
br label %12
11: ; preds = %7
store i8 111, i8* %2
br label %12
12: ; preds = %11, %10, %6
%13 = load i8, i8* %2
ret i8 %13
}

LLVM IR (-O2):
define signext i8 @contCode(i32 %0) {
%2 = icmp eq i32 %0, 1
%3 = select i1 %2, i8 97, i8 111
%4 = icmp eq i32 %0, 0
%5 = select i1 %4, i8 114, i8 %3
ret i8 %5
}
/* Variables and functions */
int get_char();
unsigned get_word(void) {
  unsigned w;
  w = get_char();
  w |= get_char() << 8;
  w |= get_char() << 16;
  w |= get_char() << 24;
  return w;
}


x86 assembly (clang, -O0):
<get_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <get_char@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <get_char@plt>
shl    $0x8,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <get_char@plt>
shl    $0x10,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <get_char@plt>
shl    $0x18,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_word>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <get_char@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <get_char@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <get_char@plt>
mov    %eax,%ebx
shl    $0x10,%ebx
xor    %eax,%eax
call   1030 <get_char@plt>
shl    $0x18,%eax
or     %ebx,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_word() {
%1 = alloca i32
%2 = call i32 (...) @get_char()
store i32 %2, i32* %1
%3 = call i32 (...) @get_char()
%4 = shl i32 %3, 8
%5 = load i32, i32* %1
%6 = or i32 %5, %4
store i32 %6, i32* %1
%7 = call i32 (...) @get_char()
%8 = shl i32 %7, 16
%9 = load i32, i32* %1
%10 = or i32 %9, %8
store i32 %10, i32* %1
%11 = call i32 (...) @get_char()
%12 = shl i32 %11, 24
%13 = load i32, i32* %1
%14 = or i32 %13, %12
store i32 %14, i32* %1
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
define i32 @get_word() {
%1 = tail call i32 (...) @get_char()
%2 = tail call i32 (...) @get_char()
%3 = shl i32 %2, 8
%4 = or i32 %3, %1
%5 = tail call i32 (...) @get_char()
%6 = shl i32 %5, 16
%7 = or i32 %4, %6
%8 = tail call i32 (...) @get_char()
%9 = shl i32 %8, 24
%10 = or i32 %7, %9
ret i32 %10
}
void outportl(unsigned short port, unsigned int data) {
  asm volatile("outl %%eax, %%dx" : : "dN"(port), "a"(data));
}


x86 assembly (clang, -O0):
<outportl>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x2(%rbp),%dx
mov    -0x8(%rbp),%eax
out    %eax,(%dx)
pop    %rbp
ret

x86 assembly (clang, -O2):
<outportl>:
mov    %esi,%eax
mov    %edi,%edx
out    %eax,(%dx)
ret

LLVM IR (-O0):
define void @outportl(i16 zeroext %0, i32 %1) {
%3 = alloca i16
%4 = alloca i32
store i16 %0, i16* %3
store i32 %1, i32* %4
%5 = load i16, i16* %3
%6 = load i32, i32* %4
ret void
}

LLVM IR (-O2):
define void @outportl(i16 zeroext %0, i32 %1) {
tail call void asm sideeffect "outl %eax, %dx", "{dx}N,{ax},~{dirflag},~{fpsr},~{flags}"(i16 %0, i32 %1)
ret void
}
/* Variables and functions */
bool is_prime(int a) {
  int cnt = 1;
  int i;
  for (i = 2; i <= a; ++i) {
    if (a % i == 0)
      cnt++;
    if (cnt > 2)
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<is_prime>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1163 <is_prime+0x63>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    113a <is_prime+0x3a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jle    1150 <is_prime+0x50>
movl   $0x0,-0x4(%rbp)
jmp    116a <is_prime+0x6a>
jmp    1155 <is_prime+0x55>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1115 <is_prime+0x15>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_prime>:
mov    $0x1,%eax
cmp    $0x2,%edi
jl     1147 <is_prime+0x47>
mov    %edi,%r8d
neg    %r8d
mov    $0x1,%esi
mov    $0x2,%ecx
nopw   0x0(%rax,%rax,1)
mov    %edi,%eax
cltd
idiv   %ecx
cmp    $0x1,%edx
adc    $0x0,%esi
cmp    $0x3,%esi
jae    1145 <is_prime+0x45>
lea    (%r8,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x1,%eax
jne    1120 <is_prime+0x20>
mov    $0x1,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @is_prime(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %14, label %6
3: ; preds = %6
%4 = add nuw i32 %7, 1
%5 = icmp eq i32 %7, %0
br i1 %5, label %14, label %6
6: ; preds = %1, %3
%7 = phi i32 [ %4, %3 ], [ 2, %1 ]
%8 = phi i32 [ %12, %3 ], [ 1, %1 ]
%9 = srem i32 %0, %7
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %8, %11
%13 = icmp ugt i32 %12, 2
br i1 %13, label %14, label %3
14: ; preds = %6, %3, %1
%15 = phi i32 [ 1, %1 ], [ 1, %3 ], [ 0, %6 ]
ret i32 %15
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
uint32_t op_div(uint32_t a, uint32_t b) { return a / b; }


x86 assembly (clang, -O0):
<op_div>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<op_div>:
mov    %edi,%eax
cltd
idiv   %esi
ret

LLVM IR (-O0):
define i32 @op_div(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 = sdiv i32 %5, %6
ret i32 %7
}

LLVM IR (-O2):
define i32 @op_div(i32 %0, i32 %1) {
%3 = sdiv i32 %0, %1
ret i32 %3
}
void write_cr4(unsigned long val) { asm volatile("movq %0,%%cr4" ::"r"(val)); }


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

x86 assembly (clang, -O2):
<write_cr4>:
mov    %rdi,%cr4
ret

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

LLVM IR (-O2):
define void @write_cr4(i64 %0) {
tail call void asm sideeffect "movq $0,%cr4", "r,~{dirflag},~{fpsr},~{flags}"(i64 %0)
ret void
}
void init_wdt(void) {}


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

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

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

LLVM IR (-O2):
define void @init_wdt() {
ret void
}
void foo(unsigned char *x, short y) {
  short i;
  i = 2;
  while (i < y) {
    x[i - 1] = x[i];
    i = i + 1;
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movw   $0x2,-0xc(%rbp)
movswl -0xc(%rbp),%eax
movswl -0xa(%rbp),%ecx
cmp    %ecx,%eax
jge    1152 <foo+0x52>
mov    -0x8(%rbp),%rax
movswq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movswl -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movswl -0xc(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0xc(%rbp)
jmp    1115 <foo+0x15>
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
cmp    $0x3,%si
jl     1134 <foo+0x24>
push   %rax
mov    %rdi,%rax
add    $0x1,%rdi
add    $0x2,%rax
add    $0xfffffffe,%esi
movzwl %si,%edx
mov    %rax,%rsi
call   1030 <memmove@plt>
add    $0x8,%rsp
ret

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

LLVM IR (-O2):
define void @foo(i8* nocapture %0, i16 signext %1) {
%3 = icmp sgt i16 %1, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr i8, i8* %0, i64 1
%6 = getelementptr i8, i8* %0, i64 2
%7 = add nsw i16 %1, -2
%8 = zext i16 %7 to i64
br label %9
9: ; preds = %4, %2
ret void
}
/* Variables and functions */
char *drop_reader(char *was, char *list_name) { return NULL; }


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

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

LLVM IR (-O0):
define i8* @drop_reader(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @drop_reader(i8* nocapture readnone %0, i8* nocapture readnone %1) {
ret i8* null
}
int milliseconds_to_blocks(int milliseconds) {
  return milliseconds * (44100 / 100) / 10;
}


x86 assembly (clang, -O0):
<milliseconds_to_blocks>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
imul   $0x1b9,-0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
pop    %rbp
ret

x86 assembly (clang, -O2):
<milliseconds_to_blocks>:
imul   $0x1b9,%edi,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @milliseconds_to_blocks(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = mul nsw i32 %3, 441
%5 = sdiv i32 %4, 10
ret i32 %5
}

LLVM IR (-O2):
define i32 @milliseconds_to_blocks(i32 %0) {
%2 = mul nsw i32 %0, 441
%3 = sdiv i32 %2, 10
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ notify(int /*<<< orphan*/, int /*<<< orphan*/, char *);
void obsolete(void) { notify(0, 0, "obsolete"); }


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

x86 assembly (clang, -O2):
<obsolete>:
lea    0xee9(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
jmp    1030 <notify@plt>

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

LLVM IR (-O2):
@.str = [9 x i8] c"obsolete\00"
define void @obsolete() {
%1 = tail call i32 @notify(i32 0, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret void
}
void nrf_802154_timer_init(void) {}


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

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

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

LLVM IR (-O2):
define void @nrf_802154_timer_init() {
ret void
}
void print_users() {}


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

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

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

LLVM IR (-O2):
define void @print_users() {
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ __udivmoddi4(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/ *);
uint64_t __umoddi3(uint64_t num, uint64_t den) {
  uint64_t v;
  (void)__udivmoddi4(num, den, &v);
  return v;
}


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

x86 assembly (clang, -O2):
<__umoddi3>:
push   %rax
lea    0x4(%rsp),%rdx
call   1030 <__udivmoddi4@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @__umoddi3(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = call i32 @__udivmoddi4(i32 %6, i32 %7, i32* %5)
%9 = load i32, i32* %5
ret i32 %9
}

LLVM IR (-O2):
define i32 @__umoddi3(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @__udivmoddi4(i32 %0, i32 %1, i32* %3)
%6 = load i32, i32* %3
ret i32 %6
}
/* Variables and functions */
scalar_t__ adc_read(unsigned int, char *, unsigned int const);
unsigned int atoi(char *);
int adc_get_value(unsigned int ain, unsigned int *value) {
  const unsigned int length = 5;
  char buffer[length];
  if (adc_read(ain, buffer, length) < 0)
    return -1;
  *value = atoi(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<adc_get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x5,%edx
call   1030 <adc_read@plt>
cmp    $0x0,%rax
jge    116b <adc_get_value+0x4b>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    118a <adc_get_value+0x6a>
lea    -0x30(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adc_get_value>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rsp,%rsi
mov    $0x5,%edx
call   1030 <adc_read@plt>
test   %rax,%rax
js     1148 <adc_get_value+0x28>
mov    %rsp,%rdi
call   1040 <atoi@plt>
mov    %eax,(%rbx)
xor    %eax,%eax
jmp    114d <adc_get_value+0x2d>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @adc_get_value(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 5, i32* %6
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %7
%10 = alloca i8, i64 5
%11 = load i32, i32* %4
%12 = call i64 @adc_read(i32 %11, i8* %10, i32 5)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
store i32 1, i32* %8
br label %18
15: ; preds = %2
%16 = call i32 @atoi(i8* %10)
%17 = load i32*, i32** %5
store i32 %16, i32* %17
store i32 0, i32* %3
store i32 1, i32* %8
br label %18
18: ; preds = %15, %14
%19 = load i8*, i8** %7
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
define i32 @adc_get_value(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = call i64 @adc_read(i32 %0, i8* %4, i32 5)
%6 = icmp slt i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @atoi(i8* %4)
store i32 %8, i32* %1
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ 0, %7 ], [ -1, %2 ]
ret i32 %10
}
/* Variables and functions */
double gettimeofday_resolution();
double ptimer_resolution(void) { return gettimeofday_resolution(); }


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

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

LLVM IR (-O0):
define double @ptimer_resolution() {
%1 = call double (...) @gettimeofday_resolution()
ret double %1
}

LLVM IR (-O2):
define double @ptimer_resolution() {
%1 = tail call double (...) @gettimeofday_resolution()
ret double %1
}
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int first_keycode;
};
typedef TYPE_1__ XMappingEvent;

/* Variables and functions */
void set_XMappingEvent_first_keycode(void *_p, int _v) {
  ((XMappingEvent *)_p)->first_keycode = (int)_v;
}


x86 assembly (clang, -O0):
<set_XMappingEvent_first_keycode>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_XMappingEvent_first_keycode>:
mov    %esi,(%rdi)
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i32 }
define void @set_XMappingEvent_first_keycode(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 %struct.TYPE_2__*
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
store i32 %5, i32* %8
ret void
}

LLVM IR (-O2):
define void @set_XMappingEvent_first_keycode(i8* nocapture writeonly %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
store i32 %1, i32* %3
ret void
}
int COLORS() { return 256; }


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

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

LLVM IR (-O0):
define i32 @COLORS() {
ret i32 256
}

LLVM IR (-O2):
define i32 @COLORS() {
ret i32 256
}
void __attribute__((always_)) shim_clflush(volatile void *ptr) {
  asm volatile("clflush %0" : "+m"(*(volatile char *)ptr));
}


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

x86 assembly (clang, -O2):
<shim_clflush>:
clflush (%rdi)
ret

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

LLVM IR (-O2):
define void @shim_clflush(i8* %0) {
tail call void asm sideeffect "clflush $0", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i8* elementtype(i8) %0, i8* elementtype(i8) %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _MLPrintLog(int, int /*<<< orphan*/, char *, char const *,
                               char const *, int, int);
void __print_result_location(int result, const char *file, const char *func,
                             int line) {
  _MLPrintLog((6), 0, "%s|%s|%d returning %d\n", file, func, line, result);
}


x86 assembly (clang, -O0):
<__print_result_location>:
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    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
mov    -0x4(%rbp),%eax
mov    $0x6,%edi
xor    %esi,%esi
lea    0xebd(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <_MLPrintLog@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__print_result_location>:
push   %rax
mov    %ecx,%r9d
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %edi,(%rsp)
lea    0xedc(%rip),%rdx
mov    $0x6,%edi
xor    %esi,%esi
call   1030 <_MLPrintLog@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%s|%s|%d returning %d\0A\00"
define void @__print_result_location(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %6
%10 = load i8*, i8** %7
%11 = load i32, i32* %8
%12 = load i32, i32* %5
%13 = call i32 @_MLPrintLog(i32 6, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i32 %11, i32 %12)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s|%s|%d returning %d\0A\00"
define void @__print_result_location(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @_MLPrintLog(i32 6, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i32 %3, i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int add(int a, int b) {
  printf("I am doing %d + %d\n", a, b);
  return a + b;
}


x86 assembly (clang, -O0):
<add>:
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
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xee2(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
add    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"I am doing %d + %d\0A\00"
define i32 @add(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 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = add nsw i32 %8, %9
ret i32 %10
}

LLVM IR (-O2):
@.str = [20 x i8] c"I am doing %d + %d\0A\00"
define i32 @add(i32 %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%4 = add nsw i32 %1, %0
ret i32 %4
}