xunge/DecIR huggingface dataset:
/* Type definitions */
struct position {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_piece(struct position *, int, int);
int /*<<< orphan*/ remove_piece(struct position *, int, int);
void move_piece(struct position *pos, int piece, int from, int to) {
  remove_piece(pos, piece, from);
  add_piece(pos, piece, to);
}


x86 assembly (clang, -O0):
<move_piece>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <remove_piece@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <add_piece@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move_piece>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <remove_piece@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <add_piece@plt>

LLVM IR (-O0):
%struct.position = type { i32 }
define void @move_piece(%struct.position* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.position*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.position* %0, %struct.position** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load %struct.position*, %struct.position** %5
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = call i32 @remove_piece(%struct.position* %9, i32 %10, i32 %11)
%13 = load %struct.position*, %struct.position** %5
%14 = load i32, i32* %6
%15 = load i32, i32* %8
%16 = call i32 @add_piece(%struct.position* %13, i32 %14, i32 %15)
ret void
}

LLVM IR (-O2):
%struct.position = type { i32 }
define void @move_piece(%struct.position* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @remove_piece(%struct.position* %0, i32 %1, i32 %2)
%6 = tail call i32 @add_piece(%struct.position* %0, i32 %1, i32 %3)
ret void
}
int to_int(char c) {
  int x = (c - '0') % 39;
  if (c == '.') {
    x += 1;
  }
  if ((c >= 'A') && (c <= 'F')) {
    x -= 7;
  }
  return x;
}


x86 assembly (clang, -O0):
<to_int>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    $0x27,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x2e,%eax
jne    1132 <to_int+0x32>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x41,%eax
jl     1155 <to_int+0x55>
movsbl -0x1(%rbp),%eax
cmp    $0x46,%eax
jg     1155 <to_int+0x55>
mov    -0x8(%rbp),%eax
sub    $0x7,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_int>:
mov    %edi,%eax
add    $0xffffffd0,%eax
imul   $0x6907,%eax,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x14,%eax
add    %ecx,%eax
imul   $0x27,%eax,%eax
neg    %eax
add    %edi,%eax
add    $0xffffffd0,%eax
cwtl
xor    %ecx,%ecx
cmp    $0x2e,%dil
sete   %cl
lea    (%rax,%rcx,1),%edx
lea    -0x41(%rdi),%esi
cmp    $0x6,%sil
lea    -0x7(%rax,%rcx,1),%eax
cmovae %edx,%eax
ret

LLVM IR (-O0):
define i32 @to_int(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = sub nsw i32 %5, 48
%7 = srem i32 %6, 39
store i32 %7, i32* %3
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 46
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %14
14: ; preds = %11, %1
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp sge i32 %16, 65
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 70
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 7
store i32 %24, i32* %3
br label %25
25: ; preds = %22, %18, %14
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @to_int(i8 signext %0) {
%2 = sext i8 %0 to i16
%3 = add nsw i16 %2, -48
%4 = srem i16 %3, 39
%5 = sext i16 %4 to i32
%6 = icmp eq i8 %0, 46
%7 = zext i1 %6 to i32
%8 = add nsw i32 %5, %7
%9 = add i8 %0, -65
%10 = icmp ult i8 %9, 6
%11 = add nsw i32 %8, -7
%12 = select i1 %10, i32 %11, i32 %8
ret i32 %12
}
/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ printf(char *);
void sig_quit(int what) {
  printf("We have received SIGQUIT: Aborting.\n");
  abort();
}


x86 assembly (clang, -O0):
<sig_quit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<sig_quit>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"We have received SIGQUIT: Aborting.\0A\00"
define void @sig_quit(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@str = [36 x i8] c"We have received SIGQUIT: Aborting.\00"
define void @sig_quit(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (...) @abort()
unreachable
}
void fa12(void) {
p0A:
  goto p0A;
  goto a;
P0A:
  goto P0A;
  ({
    P01A:
      goto P01A;
      ({
        P012A:
          goto P012A;
          0;
      });
    P01B:
      goto P01B;
      ({
        P013A:
          goto P013A;
          0;
      });
    P01C:
      goto P01C;
      0;
  });
P0B:
  goto P0B;
  ({
    P02A:
      goto P02A;
      ({
        P024A:
          goto P024A;
          0;
      });
    P02B:
      goto P02B;
      ({
        P025A:
          goto P025A;
          0;
      });
    P02C:
      goto P02C;
      0;
  });
a:
  0;
P0D:
  goto P0D;
}


x86 assembly (clang, -O0):
<fa12>:
push   %rbp
mov    %rsp,%rbp
jmp    1104 <fa12+0x4>

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

LLVM IR (-O0):
define void @fa12() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
br label %7
7: ; preds = %7, %0
br label %7
8: ; preds = %8
br label %8
9: ; No predecessors!
br label %10
10: ; preds = %10, %9
br label %10
11: ; No predecessors!
br label %12
12: ; preds = %12, %11
br label %12
13: ; preds = %13
br label %13
14: ; No predecessors!
br label %15
15: ; preds = %15, %14
br label %15
16: ; preds = %16
br label %16
17: ; preds = %17
br label %17
18: ; No predecessors!
br label %19
19: ; preds = %19, %18
br label %19
20: ; No predecessors!
br label %21
21: ; preds = %21, %20
br label %21
22: ; preds = %22
br label %22
23: ; No predecessors!
br label %24
24: ; preds = %24, %23
br label %24
25: ; preds = %25
br label %25
26: ; No predecessors!
br label %27
27: ; preds = %27, %26
br label %27
}

LLVM IR (-O2):
define void @fa12() {
br label %1
1: ; preds = %1, %0
br label %1
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int tr_reformat_usage() {
  fprintf(stderr, "Usage:   treebest format [-1] <tree>\n");
  return 1;
}


x86 assembly (clang, -O0):
<tr_reformat_usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tr_reformat_usage>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    (%rax),%edi
lea    0xedf(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Usage: treebest format [-1] <tree>\0A\00"
define i32 @tr_reformat_usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Usage: treebest format [-1] <tree>\0A\00"
define i32 @tr_reformat_usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  if (argc > 1)
    printf("first arg: %s\n", argv[1]);
  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)
cmpl   $0x1,-0x8(%rbp)
jle    1144 <main+0x34>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jl     112a <main+0x1a>
push   %rax
mov    0x8(%rsi),%rsi
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
add    $0x8,%rsp
xor    %eax,%eax
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"first arg: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %4, %2
ret i32 0
}
void timing_enter_max_prio(void) {}


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

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

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

LLVM IR (-O2):
define void @timing_enter_max_prio() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ init_signals();
void init(void *data) { init_signals(); }


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

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

LLVM IR (-O0):
define void @init(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 (...) @init_signals()
ret void
}

LLVM IR (-O2):
define void @init(i8* nocapture readnone %0) {
%2 = tail call i32 (...) @init_signals()
ret void
}
int main() {
  char c = 1000;
  return c;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movb   $0xe8,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
store i8 -24, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
ret i32 %4
}

LLVM IR (-O2):
define i32 @main() {
ret i32 -24
}
unsigned int pack_rgb10a2(int r, int g, int b, int a) {
  return (((unsigned int)((a >> 6) & 0x003) << 30) |
          ((unsigned int)((r << 2) & 0x3ff) << 20) |
          ((unsigned int)((g << 2) & 0x3ff) << 10) |
          ((unsigned int)((b << 2) & 0x3ff)));
}


x86 assembly (clang, -O0):
<pack_rgb10a2>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x6,%eax
and    $0x3,%eax
shl    $0x1e,%eax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
and    $0x3ff,%ecx
shl    $0x14,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
and    $0x3ff,%ecx
shl    $0xa,%ecx
or     %ecx,%eax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
and    $0x3ff,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack_rgb10a2>:
and    $0xffffffc0,%ecx
shl    $0x18,%ecx
movzbl %dil,%eax
shl    $0x16,%eax
movzbl %sil,%esi
shl    $0xc,%esi
or     %eax,%esi
movzbl %dl,%eax
lea    (%rsi,%rax,4),%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @pack_rgb10a2(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* %8
%10 = ashr i32 %9, 6
%11 = and i32 %10, 3
%12 = shl i32 %11, 30
%13 = load i32, i32* %5
%14 = shl i32 %13, 2
%15 = and i32 %14, 1023
%16 = shl i32 %15, 20
%17 = or i32 %12, %16
%18 = load i32, i32* %6
%19 = shl i32 %18, 2
%20 = and i32 %19, 1023
%21 = shl i32 %20, 10
%22 = or i32 %17, %21
%23 = load i32, i32* %7
%24 = shl i32 %23, 2
%25 = and i32 %24, 1023
%26 = or i32 %22, %25
ret i32 %26
}

LLVM IR (-O2):
define i32 @pack_rgb10a2(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %3, 24
%6 = and i32 %5, -1073741824
%7 = shl i32 %0, 22
%8 = and i32 %7, 1069547520
%9 = shl i32 %1, 12
%10 = and i32 %9, 1044480
%11 = shl i32 %2, 2
%12 = and i32 %11, 1020
%13 = or i32 %10, %8
%14 = or i32 %13, %12
%15 = or i32 %14, %6
ret i32 %15
}
/* Type definitions */
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ put_asm(int /*<<< orphan*/, int *, int);
void put_lda(uint16_t org, int *pos, int sel) {
  put_asm(org, pos, 0xbd);
  put_asm(org, pos, sel);
  put_asm(org, pos, 0x3f);
}


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

x86 assembly (clang, -O2):
<put_lda>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xbd,%edx
call   1030 <put_asm@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <put_asm@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x3f,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <put_asm@plt>

LLVM IR (-O0):
define void @put_lda(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* %4
%8 = load i32*, i32** %5
%9 = call i32 @put_asm(i32 %7, i32* %8, i32 189)
%10 = load i32, i32* %4
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = call i32 @put_asm(i32 %10, i32* %11, i32 %12)
%14 = load i32, i32* %4
%15 = load i32*, i32** %5
%16 = call i32 @put_asm(i32 %14, i32* %15, i32 63)
ret void
}

LLVM IR (-O2):
define void @put_lda(i32 %0, i32* %1, i32 %2) {
%4 = tail call i32 @put_asm(i32 %0, i32* %1, i32 189)
%5 = tail call i32 @put_asm(i32 %0, i32* %1, i32 %2)
%6 = tail call i32 @put_asm(i32 %0, i32* %1, i32 63)
ret void
}
int utf8_charsize(unsigned char c) {
  if ((c & 0xE0) == 0xC0)
    return 2;
  else if ((c & 0xF0) == 0xE0)
    return 3;
  else if ((c & 0xF8) == 0xF0)
    return 4;
  return 1;
}


x86 assembly (clang, -O0):
<utf8_charsize>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
and    $0xe0,%eax
cmp    $0xc0,%eax
jne    112a <utf8_charsize+0x2a>
movl   $0x2,-0x4(%rbp)
jmp    117b <utf8_charsize+0x7b>
movzbl -0x5(%rbp),%eax
and    $0xf0,%eax
cmp    $0xe0,%eax
jne    114a <utf8_charsize+0x4a>
movl   $0x3,-0x4(%rbp)
jmp    117b <utf8_charsize+0x7b>
movzbl -0x5(%rbp),%eax
and    $0xf8,%eax
cmp    $0xf0,%eax
jne    116a <utf8_charsize+0x6a>
movl   $0x4,-0x4(%rbp)
jmp    117b <utf8_charsize+0x7b>
jmp    116f <utf8_charsize+0x6f>
jmp    1174 <utf8_charsize+0x74>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8_charsize>:
mov    %edi,%ecx
and    $0xffffffe0,%ecx
mov    $0x2,%eax
cmp    $0xc0,%ecx
je     1138 <utf8_charsize+0x38>
mov    %edi,%ecx
and    $0xfffffff0,%ecx
mov    $0x3,%eax
cmp    $0xe0,%ecx
je     1138 <utf8_charsize+0x38>
and    $0xfffffff8,%edi
xor    %eax,%eax
cmp    $0xf0,%edi
sete   %al
lea    (%rax,%rax,2),%eax
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @utf8_charsize(i8 zeroext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = and i32 %5, 224
%7 = icmp eq i32 %6, 192
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 2, i32* %2
br label %24
9: ; preds = %1
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = and i32 %11, 240
%13 = icmp eq i32 %12, 224
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 3, i32* %2
br label %24
15: ; preds = %9
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = and i32 %17, 248
%19 = icmp eq i32 %18, 240
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 4, i32* %2
br label %24
21: ; preds = %15
br label %22
22: ; preds = %21
br label %23
23: ; preds = %22
store i32 1, i32* %2
br label %24
24: ; preds = %23, %20, %14, %8
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @utf8_charsize(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = and i32 %2, 224
%4 = icmp eq i32 %3, 192
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = and i32 %2, 240
%7 = icmp eq i32 %6, 224
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = and i32 %2, 248
%10 = icmp eq i32 %9, 240
%11 = select i1 %10, i32 4, i32 1
br label %12
12: ; preds = %8, %5, %1
%13 = phi i32 [ 2, %1 ], [ 3, %5 ], [ %11, %8 ]
ret i32 %13
}
int f(int a) { return a; }


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

x86 assembly (clang, -O2):
<f>:
mov    %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @f(i32 returned %0) {
ret i32 %0
}
/* Variables and functions */
int stringmatchlen(char const *, int, char const *, int, int);
scalar_t__ strlen(char const *);
int stringmatch(const char *pattern, const char *string, int nocase) {
  return stringmatchlen(pattern, (int)strlen(pattern), string,
                        (int)strlen(string), nocase);
}


x86 assembly (clang, -O0):
<stringmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
call   1040 <stringmatchlen@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringmatch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <stringmatchlen@plt>

LLVM IR (-O0):
define i32 @stringmatch(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
%11 = load i8*, i8** %5
%12 = load i8*, i8** %5
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
%15 = load i32, i32* %6
%16 = call i32 @stringmatchlen(i8* %7, i32 %10, i8* %11, i32 %14, i32 %15)
ret i32 %16
}

LLVM IR (-O2):
define i32 @stringmatch(i8* %0, i8* %1, i32 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = trunc i64 %4 to i32
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = trunc i64 %6 to i32
%8 = tail call i32 @stringmatchlen(i8* %0, i32 %5, i8* %1, i32 %7, i32 %2)
ret i32 %8
}
extern void outportb(unsigned short _port, unsigned char _data) {
  __asm__ __volatile__("outb %1, %0" : : "dN"(_port), "a"(_data));
}


x86 assembly (clang, -O0):
<outportb>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    -0x2(%rbp),%dx
mov    -0x3(%rbp),%al
out    %al,(%dx)
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @outportb(i16 zeroext %0, i8 zeroext %1) {
tail call void asm sideeffect "outb $1, $0", "{dx}N,{ax},~{dirflag},~{fpsr},~{flags}"(i16 %0, i8 %1)
ret void
}
/* Variables and functions */
int execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int main(int argc, char **argv) {
  char **newargv;
  int i;
  if (argc <= 1) {
    exit(1);
  }
  newargv = argv + 1;
  exit(execvp(newargv[0], newargv));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     114a <main+0x2a>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <execvp@plt>
mov    %eax,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
jg     1130 <main+0x10>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    0x8(%rsi),%rdi
add    $0x8,%rsi
call   1030 <execvp@plt>
mov    %eax,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
store i8** %14, i8*** %6
%15 = load i8**, i8*** %6
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %6
%19 = call i32 @execvp(i8* %17, i8** %18)
%20 = call i32 @exit(i32 %19)
unreachable
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @execvp(i8* %8, i8** %7)
%10 = tail call i32 @exit(i32 %9)
unreachable
}
void foo(int len) {
  char array[1000];
  __builtin_memset(array, 0, len);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
movslq -0x4(%rbp),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x3f0,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @foo(i32 %0) {
%2 = alloca i32
%3 = alloca [1000 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
ret void
}

LLVM IR (-O2):
define void @foo(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ func2(int);
void func1(int x) { func2(x * 2); }


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

x86 assembly (clang, -O2):
<func1>:
add    %edi,%edi
jmp    1030 <func2@plt>

LLVM IR (-O0):
define void @func1(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = mul nsw i32 %3, 2
%5 = call i32 @func2(i32 %4)
ret void
}

LLVM IR (-O2):
define void @func1(i32 %0) {
%2 = shl nsw i32 %0, 1
%3 = tail call i32 @func2(i32 %2)
ret void
}
char transform_decimal(int digit) {
  if (digit > 9) {
    switch (digit) {
    case 10:
      return 'a';
    case 11:
      return 'b';
    case 12:
      return 'c';
    case 13:
      return 'd';
    case 14:
      return 'e';
    case 15:
      return 'f';
    }
  }
  return (char)(digit + '0');
}


x86 assembly (clang, -O0):
<transform_decimal>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jle    1175 <transform_decimal+0x75>
mov    -0x8(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1170 <transform_decimal+0x70>
mov    -0x10(%rbp),%rax
lea    0xecf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x61,-0x1(%rbp)
jmp    117e <transform_decimal+0x7e>
movb   $0x62,-0x1(%rbp)
jmp    117e <transform_decimal+0x7e>
movb   $0x63,-0x1(%rbp)
jmp    117e <transform_decimal+0x7e>
movb   $0x64,-0x1(%rbp)
jmp    117e <transform_decimal+0x7e>
movb   $0x65,-0x1(%rbp)
jmp    117e <transform_decimal+0x7e>
movb   $0x66,-0x1(%rbp)
jmp    117e <transform_decimal+0x7e>
jmp    1175 <transform_decimal+0x75>
mov    -0x8(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform_decimal>:
lea    -0xa(%rdi),%eax
lea    -0xa(%rdi),%ecx
cmp    $0x6,%eax
mov    $0x61,%eax
mov    $0x30,%edx
cmovb  %eax,%edx
movzbl %cl,%eax
cmovae %edi,%eax
add    %dl,%al
ret

LLVM IR (-O0):
define signext i8 @transform_decimal(i32 %0) {
%2 = alloca i8
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 9
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load i32, i32* %3
switch i32 %7, label %14 [
i32 10, label %8
i32 11, label %9
i32 12, label %10
i32 13, label %11
i32 14, label %12
i32 15, label %13
]
8: ; preds = %6
store i8 97, i8* %2
br label %19
9: ; preds = %6
store i8 98, i8* %2
br label %19
10: ; preds = %6
store i8 99, i8* %2
br label %19
11: ; preds = %6
store i8 100, i8* %2
br label %19
12: ; preds = %6
store i8 101, i8* %2
br label %19
13: ; preds = %6
store i8 102, i8* %2
br label %19
14: ; preds = %6
br label %15
15: ; preds = %14, %1
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 48
%18 = trunc i32 %17 to i8
store i8 %18, i8* %2
br label %19
19: ; preds = %15, %13, %12, %11, %10, %9, %8
%20 = load i8, i8* %2
ret i8 %20
}

LLVM IR (-O2):
define signext i8 @transform_decimal(i32 %0) {
%2 = add i32 %0, 246
%3 = add i32 %0, -10
%4 = icmp ult i32 %3, 6
%5 = select i1 %4, i32 %2, i32 %0
%6 = add i32 %0, -10
%7 = icmp ult i32 %6, 6
%8 = select i1 %7, i8 97, i8 48
%9 = trunc i32 %5 to i8
%10 = add i8 %8, %9
ret i8 %10
}
void fbcon_new_modelist(struct fb_info *info) {}


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

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

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

LLVM IR (-O2):
%struct.fb_info = type opaque
define void @fbcon_new_modelist(%struct.fb_info* nocapture %0) {
ret void
}
int get_button3() { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @get_button3() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ TelosbBaseStationC__Boot__booted();
void RealMainP__Boot__booted(void) { TelosbBaseStationC__Boot__booted(); }


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

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

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

LLVM IR (-O2):
define void @RealMainP__Boot__booted() {
%1 = tail call i32 (...) @TelosbBaseStationC__Boot__booted()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ fclose(void *);
void stdio_close(void *rctxt) { fclose(rctxt); }


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

x86 assembly (clang, -O2):
<stdio_close>:
jmp    1030 <fclose@plt>

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

LLVM IR (-O2):
define void @stdio_close(i8* nocapture %0) {
%2 = tail call i32 @fclose(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  int i, j;
  if (i == 1337) {
    printf("1\n");
    goto next;
  }
  while (i < 15) {
    printf("2\n");
  next:
    for (j = 0; j < 20; j++) {
      printf("3\n");
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x539,-0x8(%rbp)
jne    113d <main+0x2d>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
jmp    1158 <main+0x48>
jmp    1142 <main+0x32>
cmpl   $0xf,-0x8(%rbp)
jge    1191 <main+0x81>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    1183 <main+0x73>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <main+0x4f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <main+0x32>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [3 x i8] c"1\0A\00"
@.str.1 = [3 x i8] c"2\0A\00"
@.str.2 = [3 x i8] c"3\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 1337
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %14
8: ; preds = %0
br label %9
9: ; preds = %23, %8
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 15
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %6
store i32 0, i32* %3
br label %15
15: ; preds = %20, %14
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 20
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %15
23: ; preds = %15
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %9
26: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ src;

/* Variables and functions */
char *malloc(int);
int my_strlen(char *);
char *my_strdup(char *src) {
  int len;
  int lp;
  char *dest;
  len = my_strlen(src);
  lp = 0;
  dest = malloc(sizeof(src) * len);
  while (lp < len) {
    dest[lp] = src[lp];
    ++lp;
  }
  return (dest);
}


x86 assembly (clang, -O0):
<my_strdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1182 <my_strdup+0x62>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <my_strdup+0x32>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strdup>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <my_strlen@plt>
mov    %eax,%ebx
lea    0x0(,%rbx,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %ebx,%ebx
jle    115f <my_strdup+0x2f>
mov    %ebx,%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <memcpy@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define noalias i8* @my_strdup(i8* %0) {
%2 = tail call i32 @my_strlen(i8* %0)
%3 = shl i32 %2, 3
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %1
ret i8* %4
}
/* Variables and functions */
int /*<<< orphan*/ dec_to_hex();
int /*<<< orphan*/ hex_to_dec();
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char option;
  scanf(" %c", &option);
  switch (option) {
  case 'h':
    hex_to_dec();
    break;
  case 'd':
    dec_to_hex();
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x64,%eax
je     1181 <main+0x51>
jmp    1164 <main+0x34>
mov    -0xc(%rbp),%eax
sub    $0x68,%eax
jne    1188 <main+0x58>
jmp    1175 <main+0x45>
mov    $0x0,%al
call   1040 <hex_to_dec@plt>
jmp    1188 <main+0x58>
mov    $0x0,%al
call   1030 <dec_to_hex@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
cmp    $0x64,%eax
je     115a <main+0x2a>
cmp    $0x68,%eax
jne    1161 <main+0x31>
xor    %eax,%eax
call   1040 <hex_to_dec@plt>
jmp    1161 <main+0x31>
xor    %eax,%eax
call   1030 <dec_to_hex@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %10 [
i32 104, label %6
i32 100, label %8
]
6: ; preds = %0
%7 = call i32 (...) @hex_to_dec()
br label %10
8: ; preds = %0
%9 = call i32 (...) @dec_to_hex()
br label %10
10: ; preds = %0, %8, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i8
%2 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = load i8, i8* %1
%4 = sext i8 %3 to i32
switch i32 %4, label %9 [
i32 104, label %5
i32 100, label %7
]
5: ; preds = %0
%6 = call i32 (...) @hex_to_dec()
br label %9
7: ; preds = %0
%8 = call i32 (...) @dec_to_hex()
br label %9
9: ; preds = %0, %7, %5
ret i32 0
}
int test_imm_E1int8_mem(signed char *val) {
  return ((*val) & (-0xE1 << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_E1int8_mem>:
movsbl (%rdi),%eax
test   $0xffffff1f,%eax
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_E1int8_mem(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = and i32 %5, -225
%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_E1int8_mem(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = and i32 %3, -225
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i32 -40, i32 -20
ret i32 %6
}
/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ width;
};
typedef TYPE_1__ XGraphicsExposeEvent;

/* Variables and functions */
int get_XGraphicsExposeEvent_width(void *_p) {
  return (int)((XGraphicsExposeEvent *)_p)->width;
}


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

x86 assembly (clang, -O2):
<get_XGraphicsExposeEvent_width>:
mov    (%rdi),%eax
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i64 }
define i32 @get_XGraphicsExposeEvent_width(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = bitcast i8* %3 to %struct.TYPE_2__*
%5 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %4, i32 0, i32 0
%6 = load i64, i64* %5
%7 = trunc i64 %6 to i32
ret i32 %7
}

LLVM IR (-O2):
define i32 @get_XGraphicsExposeEvent_width(i8* nocapture %0) {
%2 = bitcast i8* %0 to i64*
%3 = load i64, i64* %2
%4 = trunc i64 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void UEOF(void) {
  fprintf(stderr, "Error: unexpected end of file\n");
  exit(1);
}


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

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

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Error: unexpected end of file\0A\00"
define void @UEOF() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Error: unexpected end of file\0A\00"
define void @UEOF() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ finite(double);
double floor(double);
double trunctest(double x) {
  if (!finite(x))
    return x;
  if (x < 0.0)
    return -floor(-x);
  else
    return floor(x);
}


x86 assembly (clang, -O0):
<trunctest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xecb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    114e <trunctest+0x3e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ad <trunctest+0x9d>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    119e <trunctest+0x8e>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <floor@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ad <trunctest+0x9d>
movsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trunctest>:
push   %rax
movapd 0xee7(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xefb(%rip),%xmm1
je     1146 <trunctest+0x36>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1148 <trunctest+0x38>
xorpd  0xed7(%rip),%xmm0
call   1030 <floor@plt>
xorpd  0xeca(%rip),%xmm0
pop    %rax
ret
pop    %rax
jmp    1030 <floor@plt>

LLVM IR (-O0):
define double @trunctest(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call double @llvm.fabs.f64(double %4)
%6 = fcmp one double %5, 0x7FF0000000000000
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = load double, double* %3
store double %8, double* %2
br label %20
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load double, double* %3
%14 = fneg double %13
%15 = call double @llvm.floor.f64(double %14)
%16 = fneg double %15
store double %16, double* %2
br label %20
17: ; preds = %9
%18 = load double, double* %3
%19 = call double @llvm.floor.f64(double %18)
store double %19, double* %2
br label %20
20: ; preds = %17, %12, %7
%21 = load double, double* %2
ret double %21
}

LLVM IR (-O2):
define double @trunctest(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ueq double %2, 0x7FF0000000000000
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = fcmp olt double %0, 0.000000e+00
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = fneg double %0
%8 = tail call double @llvm.floor.f64(double %7)
%9 = fneg double %8
br label %12
10: ; preds = %4
%11 = tail call double @llvm.floor.f64(double %0)
br label %12
12: ; preds = %1, %10, %6
%13 = phi double [ %9, %6 ], [ %11, %10 ], [ %0, %1 ]
ret double %13
}
/* Type definitions */
typedef int int32_t;

/* Variables and functions */
int aeron_number_of_leading_zeroes(int);
int32_t aeron_find_next_power_of_two(int32_t value) {
  return 1 << (32 - aeron_number_of_leading_zeroes(value - 1));
}


x86 assembly (clang, -O0):
<aeron_find_next_power_of_two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1030 <aeron_number_of_leading_zeroes@plt>
mov    $0x20,%ecx
sub    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aeron_find_next_power_of_two>:
push   %rax
add    $0xffffffff,%edi
call   1030 <aeron_number_of_leading_zeroes@plt>
neg    %al
mov    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%edx
mov    %edx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @aeron_find_next_power_of_two(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sub nsw i32 %3, 1
%5 = call i32 @aeron_number_of_leading_zeroes(i32 %4)
%6 = sub nsw i32 32, %5
%7 = shl i32 1, %6
ret i32 %7
}

LLVM IR (-O2):
define i32 @aeron_find_next_power_of_two(i32 %0) {
%2 = add nsw i32 %0, -1
%3 = tail call i32 @aeron_number_of_leading_zeroes(i32 %2)
%4 = sub nsw i32 32, %3
%5 = shl nuw i32 1, %4
ret i32 %5
}
/* Type definitions */
typedef int /*<<< orphan*/ __s32;

/* Variables and functions */
int /*<<< orphan*/ i2c_smbus_access(int, int /*<<< orphan*/, int, int,
                                    int /*<<< orphan*/ *);
extern __s32 i2c_smbus_write_byte(int fd, int value) {
  return i2c_smbus_access(fd, 0, value, 1, NULL);
}


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

x86 assembly (clang, -O2):
<i2c_smbus_write_byte>:
mov    %esi,%edx
xor    %esi,%esi
mov    $0x1,%ecx
xor    %r8d,%r8d
jmp    1030 <i2c_smbus_access@plt>

LLVM IR (-O0):
define i32 @i2c_smbus_write_byte(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 @i2c_smbus_access(i32 %5, i32 0, i32 %6, i32 1, i32* null)
ret i32 %7
}

LLVM IR (-O2):
define i32 @i2c_smbus_write_byte(i32 %0, i32 %1) {
%3 = tail call i32 @i2c_smbus_access(i32 %0, i32 0, i32 %1, i32 1, i32* null)
ret i32 %3
}
int __libc_enable_asynccancel(void) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @__libc_enable_asynccancel() {
ret i32 0
}
/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ trim_character(char *, char, char *);
double timlib_atof(char *s) {
  char buffer[1024];
  if (!s)
    return 0.0;
  trim_character(buffer, ',', s);
  return atof(buffer);
}


x86 assembly (clang, -O0):
<timlib_atof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <timlib_atof+0x27>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    116d <timlib_atof+0x4d>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2c,%esi
call   1040 <trim_character@plt>
lea    -0x410(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timlib_atof>:
test   %rdi,%rdi
je     1151 <timlib_atof+0x31>
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1040 <trim_character@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
add    $0x400,%rsp
pop    %rbx
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @timlib_atof(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca [1024 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store double 0.000000e+00, double* %2
br label %14
8: ; preds = %1
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = call i32 @trim_character(i8* %9, i8 signext 44, i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call double @atof(i8* %12)
store double %13, double* %2
br label %14
14: ; preds = %8, %7
%15 = load double, double* %2
ret double %15
}

LLVM IR (-O2):
define double @timlib_atof(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = call i32 @trim_character(i8* %3, i8 signext 44, i8* %0)
%7 = call double @atof(i8* %3)
br label %8
8: ; preds = %1, %5
%9 = phi double [ %7, %5 ], [ 0.000000e+00, %1 ]
ret double %9
}
int frag_hack(int x, int y, int foo) {
  x /= 4;
  y /= 4;
  return (x ^ y) + foo;
}


x86 assembly (clang, -O0):
<frag_hack>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
xor    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<frag_hack>:
lea    0x3(%rdi),%ecx
test   %edi,%edi
cmovns %edi,%ecx
lea    0x3(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
xor    %ecx,%eax
sar    $0x2,%eax
add    %edx,%eax
ret

LLVM IR (-O0):
define i32 @frag_hack(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* %4
%8 = sdiv i32 %7, 4
store i32 %8, i32* %4
%9 = load i32, i32* %5
%10 = sdiv i32 %9, 4
store i32 %10, i32* %5
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = xor i32 %11, %12
%14 = load i32, i32* %6
%15 = add nsw i32 %13, %14
ret i32 %15
}

LLVM IR (-O2):
define i32 @frag_hack(i32 %0, i32 %1, i32 %2) {
%4 = sdiv i32 %0, 4
%5 = sdiv i32 %1, 4
%6 = xor i32 %5, %4
%7 = add nsw i32 %6, %2
ret i32 %7
}