xunge/DecIR huggingface dataset:
int ctoi(char c) {
  if (c >= 'a' && c <= 'z')
    return c - 'a';
  else if (c >= 'A' && c <= 'Z')
    return c - 'A';
  else if (c == '-')
    return 'z' - 'a' + 1;
  else
    return 'z' - 'a' + 2;
}


x86 assembly (clang, -O0):
<ctoi>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     1133 <ctoi+0x33>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     1133 <ctoi+0x33>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <ctoi+0x7c>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     115c <ctoi+0x5c>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     115c <ctoi+0x5c>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <ctoi+0x7c>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
jne    1175 <ctoi+0x75>
movl   $0x1a,-0x4(%rbp)
jmp    117c <ctoi+0x7c>
movl   $0x1b,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctoi>:
mov    %edi,%eax
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     110e <ctoi+0xe>
add    $0xffffff9f,%eax
ret
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     111a <ctoi+0x1a>
add    $0xffffffbf,%eax
ret
xor    %ecx,%ecx
cmp    $0x2d,%al
sete   %cl
xor    $0x1b,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @ctoi(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 97
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 122
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 97
store i32 %14, i32* %2
br label %33
15: ; preds = %7, %1
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 65
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 90
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = sub nsw i32 %25, 65
store i32 %26, i32* %2
br label %33
27: ; preds = %19, %15
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 26, i32* %2
br label %33
32: ; preds = %27
store i32 27, i32* %2
br label %33
33: ; preds = %32, %31, %23, %11
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @ctoi(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add i8 %0, -97
%4 = icmp ult i8 %3, 26
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i32 %2, -97
br label %15
7: ; preds = %1
%8 = add i8 %0, -65
%9 = icmp ult i8 %8, 26
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %2, -65
br label %15
12: ; preds = %7
%13 = icmp eq i8 %0, 45
%14 = select i1 %13, i32 26, i32 27
br label %15
15: ; preds = %12, %10, %5
%16 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %14, %12 ]
ret i32 %16
}
/* Type definitions */
struct cpufreq_available_frequencies {
  int dummy;
};

/* Variables and functions */
struct cpufreq_available_frequencies *
sysfs_get_available_frequencies(unsigned int);
struct cpufreq_available_frequencies *
cpufreq_get_available_frequencies(unsigned int cpu) {
  return sysfs_get_available_frequencies(cpu);
}


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

x86 assembly (clang, -O2):
<cpufreq_get_available_frequencies>:
jmp    1030 <sysfs_get_available_frequencies@plt>

LLVM IR (-O0):
%struct.cpufreq_available_frequencies = type { i32 }
define %struct.cpufreq_available_frequencies* @cpufreq_get_available_frequencies(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call %struct.cpufreq_available_frequencies* @sysfs_get_available_frequencies(i32 %3)
ret %struct.cpufreq_available_frequencies* %4
}

LLVM IR (-O2):
%struct.cpufreq_available_frequencies = type { i32 }
define %struct.cpufreq_available_frequencies* @cpufreq_get_available_frequencies(i32 %0) {
%2 = tail call %struct.cpufreq_available_frequencies* @sysfs_get_available_frequencies(i32 %0)
ret %struct.cpufreq_available_frequencies* %2
}
void analogWrite(pin, value) { printf("analogWrite %i-%i\n", pin, value); }


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

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

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

LLVM IR (-O2):
@.str = [19 x i8] c"analogWrite %i-%i\0A\00"
define void @analogWrite(i32 %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
ret void
}
/* Variables and functions */
char *strtok_r(char *, char const *, char **);
char *strtok(char *restrict string, const char *restrict delimiters) {
  static char *state = NULL;
  if (string == NULL)
    state = NULL;
  return strtok_r(string, delimiters, &state);
}


x86 assembly (clang, -O0):
<strtok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1136 <strtok+0x26>
movq   $0x0,0x2efa(%rip)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0x2eeb(%rip),%rdx
call   1030 <strtok_r@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtok>:
test   %rdi,%rdi
je     1121 <strtok+0x11>
lea    0x2f14(%rip),%rdx
jmp    1030 <strtok_r@plt>
movq   $0x0,0x2f04(%rip)
lea    0x2efd(%rip),%rdx
jmp    1030 <strtok_r@plt>

LLVM IR (-O0):
@strtok.state = internal global i8* null
define i8* @strtok(i8* noalias %0, i8* noalias %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %2
store i8* null, i8** @strtok.state
br label %8
8: ; preds = %7, %2
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i8* @strtok_r(i8* %9, i8* %10, i8** @strtok.state)
ret i8* %11
}

LLVM IR (-O2):
@strtok.state = internal global i8* null
define i8* @strtok(i8* noalias %0, i8* noalias nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %5
4: ; preds = %2
store i8* null, i8** @strtok.state
br label %5
5: ; preds = %4, %2
%6 = tail call i8* @strtok_r(i8* %0, i8* %1, i8** @strtok.state)
ret i8* %6
}
void write_port_word(unsigned short port, unsigned short data) {
  __asm__("out dx, ax" : "=d"(port) : "a"(data));
}


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

LLVM IR (-O0):
LLVM IR (-O2):
define void @write_port_word(i16 zeroext %0, i16 zeroext %1) {
%3 = tail call i16 asm "out dx, ax", "={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i16 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Fmt_print(char *, int, char *, double);
void test_fmt() {
  int d = 7;
  Fmt_print("%.5d %s %f\n", d, "hello", 3.14);
}


x86 assembly (clang, -O0):
<test_fmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x7,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xedf(%rip),%rdi
lea    0xee4(%rip),%rdx
movsd  0xec8(%rip),%xmm0
call   1030 <Fmt_print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fmt>:
lea    0xef1(%rip),%rdi
lea    0xef6(%rip),%rdx
movsd  0xeda(%rip),%xmm0
mov    $0x7,%esi
jmp    1030 <Fmt_print@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%.5d %s %f\0A\00"
@.str.1 = [6 x i8] c"hello\00"
define void @test_fmt() {
%1 = alloca i32
store i32 7, i32* %1
%2 = load i32, i32* %1
%3 = call i32 @Fmt_print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 3.140000e+00)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%.5d %s %f\0A\00"
@.str.1 = [6 x i8] c"hello\00"
define void @test_fmt() {
%1 = tail call i32 @Fmt_print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 3.140000e+00)
ret void
}
void glGetActiveUniform(void) { return; }


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

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

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

LLVM IR (-O2):
define void @glGetActiveUniform() {
ret void
}
/* Type definitions */
struct timeval {
  int tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ sqlite3_vfs;
typedef int sqlite3_int64;

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow) {
  static const sqlite3_int64 unixEpoch = 24405875 * (sqlite3_int64)8640000;
  struct timeval sNow;
  gettimeofday(&sNow, 0);
  *piNow = unixEpoch + 1000 * (sqlite3_int64)sNow.tv_sec + sNow.tv_usec / 1000;
  (void)(NotUsed);
  return 0;
}


x86 assembly (clang, -O0):
<unixCurrentTimeInt64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%rax
imul   $0x3e8,%eax,%ecx
add    $0x3e532200,%ecx
mov    -0x20(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unixCurrentTimeInt64>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,0x8(%rsp),%eax
movslq (%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %ecx,%eax
add    $0x3e532200,%eax
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@unixCurrentTimeInt64.unixEpoch = internal constant i32 1045635584
define i32 @unixCurrentTimeInt64(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.timeval
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = mul nsw i32 1000, %9
%11 = add nsw i32 1045635584, %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%13 = load i32, i32* %12
%14 = sdiv i32 %13, 1000
%15 = add nsw i32 %11, %14
%16 = load i32*, i32** %4
store i32 %15, i32* %16
%17 = load i32*, i32** %3
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define i32 @unixCurrentTimeInt64(i32* nocapture readnone %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%7 = load i64, i64* %6
%8 = trunc i64 %7 to i32
%9 = mul nsw i32 %8, 1000
%10 = add nsw i32 %9, 1045635584
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = load i32, i32* %11
%13 = sdiv i32 %12, 1000
%14 = add nsw i32 %10, %13
store i32 %14, i32* %1
ret i32 0
}
unsigned short jb_strlen(const char *restrict s) {
  unsigned short i = 0;
  while (s[++i])
    ;
  return i;
}


x86 assembly (clang, -O0):
<jb_strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xa(%rbp),%cx
add    $0x1,%cx
mov    %cx,-0xa(%rbp)
movzwl %cx,%ecx
cmpb   $0x0,(%rax,%rcx,1)
je     1130 <jb_strlen+0x30>
jmp    110e <jb_strlen+0xe>
movzwl -0xa(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<jb_strlen>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%eax
movzwl %ax,%ecx
cmpb   $0x0,(%rdi,%rcx,1)
jne    1110 <jb_strlen+0x10>
ret

LLVM IR (-O0):
define zeroext i16 @jb_strlen(i8* noalias %0) {
%2 = alloca i8*
%3 = alloca i16
store i8* %0, i8** %2
store i16 0, i16* %3
br label %4
4: ; preds = %12, %1
%5 = load i8*, i8** %2
%6 = load i16, i16* %3
%7 = add i16 %6, 1
store i16 %7, i16* %3
%8 = zext i16 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %4
br label %4
13: ; preds = %4
%14 = load i16, i16* %3
ret i16 %14
}

LLVM IR (-O2):
define zeroext i16 @jb_strlen(i8* noalias nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i16 [ 0, %1 ], [ %4, %2 ]
%4 = add i16 %3, 1
%5 = zext i16 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %2
9: ; preds = %2
ret i16 %4
}
/* Variables and functions */
char getch();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char c;
  printf("enter a char !\n");
  do {
    c = getch();
    printf("\nyou enter char %c = %d =%x", c, c, c);
  } while (c != (char)13);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
movsbl -0x5(%rbp),%edx
movsbl -0x5(%rbp),%ecx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xd,%eax
jne    113d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getch@plt>
movsbl %al,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xd,%bpl
jne    1150 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"enter a char !\0A\00"
@.str.1 = [28 x i8] c"\0Ayou enter char %c = %d =%x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %13, %0
%5 = call signext i8 (...) @getch()
store i8 %5, i8* %2
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %9, i32 %11)
br label %13
13: ; preds = %4
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 13
br i1 %16, label %4, label %17
17: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"\0Ayou enter char %c = %d =%x\00"
@str = [15 x i8] c"enter a char !\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %2, %0
%3 = tail call signext i8 (...) @getch()
%4 = sext i8 %3 to i32
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 %4)
%6 = icmp eq i8 %3, 13
br i1 %6, label %7, label %2
7: ; preds = %2
ret i32 0
}
int setup(struct opt *opt) { return 0; }


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

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

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

LLVM IR (-O2):
%struct.opt = type opaque
define i32 @setup(%struct.opt* nocapture readnone %0) {
ret i32 0
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
uint8_t bitops_getb(uint8_t *a, uint8_t sh, uint8_t l) {
  return (*a >> sh) & ((1 << (l)) - 1);
}


x86 assembly (clang, -O0):
<bitops_getb>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
sub    $0x1,%ecx
and    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitops_getb>:
mov    %esi,%ecx
mov    (%rdi),%esi
sar    %cl,%esi
mov    $0xffffffff,%eax
mov    %edx,%ecx
shl    %cl,%eax
not    %eax
and    %esi,%eax
ret

LLVM IR (-O0):
define i32 @bitops_getb(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* %7
%9 = load i32, i32* %5
%10 = ashr i32 %8, %9
%11 = load i32, i32* %6
%12 = shl i32 1, %11
%13 = sub nsw i32 %12, 1
%14 = and i32 %10, %13
ret i32 %14
}

LLVM IR (-O2):
define i32 @bitops_getb(i32* nocapture %0, i32 %1, i32 %2) {
%4 = load i32, i32* %0
%5 = ashr i32 %4, %1
%6 = shl nsw i32 -1, %2
%7 = xor i32 %6, -1
%8 = and i32 %5, %7
ret i32 %8
}
/* Variables and functions */
int /*<<< orphan*/ free(void *);
void expr_free(void *maddr) {
  if (maddr != NULL) {
    free(maddr);
  }
}


x86 assembly (clang, -O0):
<expr_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1130 <expr_free+0x20>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expr_free>:
test   %rdi,%rdi
je     111a <expr_free+0xa>
jmp    1030 <free@plt>
ret

LLVM IR (-O0):
define void @expr_free(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = call i32 @free(i8* %6)
br label %8
8: ; preds = %5, %1
ret void
}

LLVM IR (-O2):
define void @expr_free(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @free(i8* %0)
br label %5
5: ; preds = %3, %1
ret void
}
/* Variables and functions */
scalar_t__ isspace(unsigned char);
const char *skip_whitespace_const(const char *s) {
  while (*s && isspace((unsigned char)*s)) {
    ++s;
  }
  return s;
}


x86 assembly (clang, -O0):
<skip_whitespace_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
je     1147 <skip_whitespace_const+0x37>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1157 <skip_whitespace_const+0x47>
jmp    1168 <skip_whitespace_const+0x58>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <skip_whitespace_const+0xc>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_whitespace_const>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1139 <skip_whitespace_const+0x29>
nopw   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     1139 <skip_whitespace_const+0x29>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1120 <skip_whitespace_const+0x10>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @skip_whitespace_const(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %15, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = call i64 @isspace(i8 zeroext %10)
%12 = icmp ne i64 %11, 0
br label %13
13: ; preds = %8, %3
%14 = phi i1 [ false, %3 ], [ %12, %8 ]
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
br label %3
18: ; preds = %13
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
define i8* @skip_whitespace_const(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %9
%5 = phi i8 [ %11, %9 ], [ %2, %1 ]
%6 = phi i8* [ %10, %9 ], [ %0, %1 ]
%7 = tail call i64 @isspace(i8 zeroext %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %9, %1
%14 = phi i8* [ %0, %1 ], [ %10, %9 ], [ %6, %4 ]
ret i8* %14
}
/* Variables and functions */
int *malloc(int);
void *overflow(int payload) {
  if (--payload) {
    int *stack = malloc(payload * sizeof(int));
    overflow(payload);
  }
}


x86 assembly (clang, -O0):
<overflow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1158 <overflow+0x38>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <overflow@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overflow>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
add    $0xffffffff,%ebp
je     113f <overflow+0x2f>
lea    -0x4(,%rdi,4),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <malloc@plt>
add    $0xfffffffc,%ebx
add    $0xffffffff,%ebp
jne    1130 <overflow+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define noalias i8* @overflow(i32 %0) {
%2 = add nsw i32 %0, -1
%3 = icmp eq i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %8, %4 ], [ %2, %1 ]
%6 = shl i32 %5, 2
%7 = tail call i32* @malloc(i32 %6)
%8 = add nsw i32 %5, -1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %4
10: ; preds = %4, %1
ret i8* undef
}
/* Variables and functions */
int rand();
void generateRandomString(char str[], unsigned arr_size) {
  unsigned i = 0;
  for (i; i < arr_size; ++i) {
    str[i] = (rand() % 26) + 65;
  }
}


x86 assembly (clang, -O0):
<generateRandomString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    115c <generateRandomString+0x4c>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <generateRandomString+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateRandomString>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
je     1166 <generateRandomString+0x56>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <generateRandomString+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @generateRandomString(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %5
br label %7
7: ; preds = %20, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 26
%14 = add nsw i32 %13, 65
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add i32 %21, 1
store i32 %22, i32* %5
br label %7
23: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @generateRandomString(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %13, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 26
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 65
%12 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 %11, i8* %12
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %15, label %6
15: ; preds = %6, %2
ret void
}
/* Variables and functions */
scalar_t__ malloc(int);
char *strCreate() {
  char *ns;
  ns = (char *)malloc(1);
  ns[0] = 0;
  return ns;
}


x86 assembly (clang, -O0):
<strCreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1030 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strCreate>:
push   %rax
mov    $0x1,%edi
call   1030 <malloc@plt>
movb   $0x0,(%rax)
pop    %rcx
ret

LLVM IR (-O0):
define i8* @strCreate() {
%1 = alloca i8*
%2 = call i64 @malloc(i32 1)
%3 = inttoptr i64 %2 to i8*
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8, i8* %4, i64 0
store i8 0, i8* %5
%6 = load i8*, i8** %1
ret i8* %6
}

LLVM IR (-O2):
define i8* @strCreate() {
%1 = tail call i64 @malloc(i32 1)
%2 = inttoptr i64 %1 to i8*
store i8 0, i8* %2
ret i8* %2
}
/* Type definitions */
typedef int /*<<< orphan*/ int8_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                          int);
int __int8_t_clone_array(const int8_t *p, int8_t *q, int elements) {
  memcpy(q, p, elements * sizeof(int8_t));
  return 0;
}


x86 assembly (clang, -O0):
<__int8_t_clone_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__int8_t_clone_array>:
push   %rax
mov    %rdi,%rax
shl    $0x2,%edx
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <memcpy@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @__int8_t_clone_array(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32*, i32** %5
%8 = load i32*, i32** %4
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i32 @memcpy(i32* %7, i32* %8, i32 %12)
ret i32 0
}

LLVM IR (-O2):
define i32 @__int8_t_clone_array(i32* %0, i32* %1, i32 %2) {
%4 = shl i32 %2, 2
%5 = tail call i32 @memcpy(i32* %1, i32* %0, i32 %4)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ assert(char *);
char tolower(char);
void str_lowcase(char *str) {
  assert(str);
  for (; *str; str++)
    *str = tolower(*str);
}


x86 assembly (clang, -O0):
<str_lowcase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1167 <str_lowcase+0x47>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1135 <str_lowcase+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_lowcase>:
push   %rbx
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    (%rbx),%al
test   %al,%al
je     1156 <str_lowcase+0x36>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <str_lowcase+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @str_lowcase(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @assert(i8* %3)
br label %5
5: ; preds = %14, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call signext i8 @tolower(i8 signext %11)
%13 = load i8*, i8** %2
store i8 %12, i8* %13
br label %14
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
br label %5
17: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @str_lowcase(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %10, %5 ], [ %3, %1 ]
%7 = phi i8* [ %9, %5 ], [ %0, %1 ]
%8 = tail call signext i8 @tolower(i8 signext %6)
store i8 %8, i8* %7
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %1
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int main() { socklen_t dummy; }


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

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
int intFindMaxHex(unsigned short i) {
  int b;
  for (b = 16; i > 1; i--)
    b *= b;
  return b;
}


x86 assembly (clang, -O0):
<intFindMaxHex>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movl   $0x10,-0x8(%rbp)
movzwl -0x2(%rbp),%eax
cmp    $0x1,%eax
jle    113a <intFindMaxHex+0x3a>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x2(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x2(%rbp)
jmp    1112 <intFindMaxHex+0x12>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<intFindMaxHex>:
mov    $0x10,%eax
cmp    $0x2,%di
jb     1169 <intFindMaxHex+0x69>
lea    -0x1(%rdi),%edx
add    $0xfffffffe,%edi
mov    %edx,%ecx
and    $0x7,%ecx
cmp    $0x7,%di
jae    1123 <intFindMaxHex+0x23>
mov    $0x10,%eax
jmp    114e <intFindMaxHex+0x4e>
and    $0xfff8,%edx
mov    $0x10,%eax
xchg   %ax,%ax
imul   %eax,%eax
imul   %eax,%eax
imul   %eax,%eax
imul   %eax,%eax
imul   %eax,%eax
imul   %eax,%eax
imul   %eax,%eax
imul   %eax,%eax
add    $0xfff8,%dx
jne    1130 <intFindMaxHex+0x30>
test   %cx,%cx
je     1169 <intFindMaxHex+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
imul   %eax,%eax
add    $0xffff,%cx
jne    1160 <intFindMaxHex+0x60>
ret

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

LLVM IR (-O2):
define i32 @intFindMaxHex(i16 zeroext %0) {
%2 = icmp ugt i16 %0, 1
br i1 %2, label %3, label %33
3: ; preds = %1
%4 = add i16 %0, -1
%5 = add i16 %0, -2
%6 = and i16 %4, 7
%7 = icmp ult i16 %5, 7
br i1 %7, label %23, label %8
8: ; preds = %3
%9 = and i16 %4, -8
br label %10
10: ; preds = %10, %8
%11 = phi i32 [ 16, %8 ], [ %20, %10 ]
%12 = phi i16 [ 0, %8 ], [ %21, %10 ]
%13 = mul nsw i32 %11, %11
%14 = mul nsw i32 %13, %13
%15 = mul nsw i32 %14, %14
%16 = mul nsw i32 %15, %15
%17 = mul nsw i32 %16, %16
%18 = mul nsw i32 %17, %17
%19 = mul nsw i32 %18, %18
%20 = mul nsw i32 %19, %19
%21 = add i16 %12, 8
%22 = icmp eq i16 %21, %9
br i1 %22, label %23, label %10
23: ; preds = %10, %3
%24 = phi i32 [ undef, %3 ], [ %20, %10 ]
%25 = phi i32 [ 16, %3 ], [ %20, %10 ]
%26 = icmp eq i16 %6, 0
br i1 %26, label %33, label %27
27: ; preds = %23, %27
%28 = phi i32 [ %30, %27 ], [ %25, %23 ]
%29 = phi i16 [ %31, %27 ], [ 0, %23 ]
%30 = mul nsw i32 %28, %28
%31 = add i16 %29, 1
%32 = icmp eq i16 %31, %6
br i1 %32, label %33, label %27
33: ; preds = %23, %27, %1
%34 = phi i32 [ 16, %1 ], [ %24, %23 ], [ %30, %27 ]
ret i32 %34
}
int dquot_resume(struct super_block *sb, int type) { return 0; }


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

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

LLVM IR (-O0):
%struct.super_block = type opaque
define i32 @dquot_resume(%struct.super_block* %0, i32 %1) {
%3 = alloca %struct.super_block*
%4 = alloca i32
store %struct.super_block* %0, %struct.super_block** %3
store i32 %1, i32* %4
ret i32 0
}

LLVM IR (-O2):
%struct.super_block = type opaque
define i32 @dquot_resume(%struct.super_block* nocapture readnone %0, i32 %1) {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_help(const char *prg) {
  printf("Usage: %s [OPTIONS] -i <input> -o <output>\n", prg);
  printf("\tOptions are:\n");
  printf("\t\t-sp N - salt and pepper noise N%%\n");
}


x86 assembly (clang, -O0):
<print_help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_help>:
push   %rax
mov    %rdi,%rsi
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"Usage: %s [OPTIONS] -i <input> -o <output>\0A\00"
@.str.1 = [15 x i8] c"\09Options are:\0A\00"
@.str.2 = [37 x i8] c"\09\09-sp N - salt and pepper noise N%%\0A\00"
define void @print_help(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"Usage: %s [OPTIONS] -i <input> -o <output>\0A\00"
@.str.2 = [37 x i8] c"\09\09-sp N - salt and pepper noise N%%\0A\00"
@str = [14 x i8] c"\09Options are:\00"
define void @print_help(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
int isqrt(int);
void t_sqrt_140() {
  Assert_real((isqrt(140) == 11),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/stdlib/isqrt.c",
              705, ("Integer square root of 140 should be 11"));
}


x86 assembly (clang, -O0):
<t_sqrt_140>:
push   %rbp
mov    %rsp,%rbp
mov    $0x8c,%edi
call   1030 <isqrt@plt>
cmp    $0xb,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xec0(%rip),%rsi
mov    $0x2c1,%edx
lea    0xf56(%rip),%rcx
call   1040 <Assert_real@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_sqrt_140>:
push   %rax
mov    $0x8c,%edi
call   1030 <isqrt@plt>
xor    %edi,%edi
cmp    $0xb,%eax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf60(%rip),%rcx
mov    $0x2c1,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [162 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/stdlib/isqrt.c\00"
@.str.1 = [40 x i8] c"Integer square root of 140 should be 11\00"
define void @t_sqrt_140() {
%1 = call i32 @isqrt(i32 140)
%2 = icmp eq i32 %1, 11
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str, i64 0, i64 0), i32 705, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [162 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/stdlib/isqrt.c\00"
@.str.1 = [40 x i8] c"Integer square root of 140 should be 11\00"
define void @t_sqrt_140() {
%1 = tail call i32 @isqrt(i32 140)
%2 = icmp eq i32 %1, 11
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str, i64 0, i64 0), i32 705, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
ret void
}
int fn6(int i) { return i == 1 >> -1; }


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

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

LLVM IR (-O0):
define i32 @fn6(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, poison
%5 = zext i1 %4 to i32
ret i32 %5
}

LLVM IR (-O2):
define i32 @fn6(i32 %0) {
ret i32 poison
}
/* Variables and functions */
unsigned long syscall(int, unsigned long);
void *sbrk(intptr_t inc) {
  unsigned long cur = syscall(45, 0);
  if (inc && syscall(45, cur + inc) != cur + inc)
    return (void *)-1;
  return (void *)cur;
}


x86 assembly (clang, -O0):
<sbrk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x2d,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <syscall@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116c <sbrk+0x5c>
mov    -0x18(%rbp),%rsi
add    -0x10(%rbp),%rsi
mov    $0x2d,%edi
call   1030 <syscall@plt>
mov    -0x18(%rbp),%rcx
add    -0x10(%rbp),%rcx
cmp    %rcx,%rax
je     116c <sbrk+0x5c>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
jmp    1174 <sbrk+0x64>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sbrk>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2d,%edi
xor    %esi,%esi
call   1030 <syscall@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     114a <sbrk+0x3a>
add    %r14,%rbx
mov    $0x2d,%edi
mov    %rbx,%rsi
call   1030 <syscall@plt>
mov    %rax,%rcx
mov    $0xffffffffffffffff,%rax
cmp    %rbx,%rcx
jne    114d <sbrk+0x3d>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @sbrk(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
%5 = call i64 @syscall(i32 45, i64 0)
store i64 %5, i64* %4
%6 = load i64, i64* %3
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load i64, i64* %4
%10 = load i64, i64* %3
%11 = add i64 %9, %10
%12 = call i64 @syscall(i32 45, i64 %11)
%13 = load i64, i64* %4
%14 = load i64, i64* %3
%15 = add i64 %13, %14
%16 = icmp ne i64 %12, %15
br i1 %16, label %17, label %18
17: ; preds = %8
store i8* inttoptr (i64 -1 to i8*), i8** %2
br label %21
18: ; preds = %8, %1
%19 = load i64, i64* %4
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %2
br label %21
21: ; preds = %18, %17
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
define i8* @sbrk(i64 %0) {
%2 = tail call i64 @syscall(i32 45, i64 0)
%3 = icmp eq i64 %0, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = add i64 %2, %0
%6 = tail call i64 @syscall(i32 45, i64 %5)
%7 = icmp eq i64 %6, %5
br i1 %7, label %8, label %10
8: ; preds = %4, %1
%9 = inttoptr i64 %2 to i8*
br label %10
10: ; preds = %4, %8
%11 = phi i8* [ %9, %8 ], [ inttoptr (i64 -1 to i8*), %4 ]
ret i8* %11
}
int utf8Len(unsigned char c, int N) {
  int len = 1;
  if (c > 0x7f) {
    if ((c & 0xe0) == 0xc0) {
      len = 2;
    } else if ((c & 0xf0) == 0xe0) {
      len = 3;
    } else {
      len = 4;
    }
  }
  if (len > N)
    len = N;
  return len;
}


x86 assembly (clang, -O0):
<utf8Len>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jle    1172 <utf8Len+0x72>
movzbl -0x1(%rbp),%eax
and    $0xe0,%eax
cmp    $0xc0,%eax
jne    1141 <utf8Len+0x41>
movl   $0x2,-0xc(%rbp)
jmp    116d <utf8Len+0x6d>
movzbl -0x1(%rbp),%eax
and    $0xf0,%eax
cmp    $0xe0,%eax
jne    1161 <utf8Len+0x61>
movl   $0x3,-0xc(%rbp)
jmp    1168 <utf8Len+0x68>
movl   $0x4,-0xc(%rbp)
jmp    116d <utf8Len+0x6d>
jmp    1172 <utf8Len+0x72>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1184 <utf8Len+0x84>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8Len>:
mov    $0x1,%eax
test   %dil,%dil
jns    1131 <utf8Len+0x31>
mov    %edi,%ecx
and    $0xffffffe0,%ecx
mov    $0x2,%eax
cmp    $0xc0,%ecx
je     1131 <utf8Len+0x31>
and    $0xfffffff0,%edi
xor    %ecx,%ecx
cmp    $0xe0,%edi
sete   %cl
mov    $0x4,%eax
sub    %ecx,%eax
cmp    %esi,%eax
cmovg  %esi,%eax
ret

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

LLVM IR (-O2):
define i32 @utf8Len(i8 zeroext %0, i32 %1) {
%3 = zext i8 %0 to i32
%4 = icmp slt i8 %0, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = and i32 %3, 224
%7 = icmp eq i32 %6, 192
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = and i32 %3, 240
%10 = icmp eq i32 %9, 224
%11 = select i1 %10, i32 3, i32 4
br label %12
12: ; preds = %8, %5, %2
%13 = phi i32 [ 1, %2 ], [ 2, %5 ], [ %11, %8 ]
%14 = icmp sgt i32 %13, %1
%15 = select i1 %14, i32 %1, i32 %13
ret i32 %15
}
void mtrace() {}


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

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

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

LLVM IR (-O2):
define void @mtrace() {
ret void
}
/* Variables and functions */
size_t strlen(char *);
int get_recurse(char *optarg) {
  size_t len;
  int recurse = 1;
  if (optarg && (len = strlen(optarg)) && optarg[len - 1] == ':') {
    recurse = 0;
    optarg[len - 1] = '\0';
  }
  return recurse;
}


x86 assembly (clang, -O0):
<get_recurse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1175 <get_recurse+0x65>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1175 <get_recurse+0x65>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1175 <get_recurse+0x65>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_recurse>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
test   %rdi,%rdi
je     1138 <get_recurse+0x28>
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %rax,%rax
je     1138 <get_recurse+0x28>
cmpb   $0x3a,-0x1(%rax,%rbx,1)
jne    1138 <get_recurse+0x28>
movb   $0x0,-0x1(%rbx,%rax,1)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_recurse(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %4
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %24
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %3
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i64, i64* %3
%14 = sub i64 %13, 1
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 58
br i1 %18, label %19, label %24
19: ; preds = %11
store i32 0, i32* %4
%20 = load i8*, i8** %2
%21 = load i64, i64* %3
%22 = sub i64 %21, 1
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %19, %11, %7, %1
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
define i32 @get_recurse(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = add i64 %4, -1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 58
br i1 %10, label %11, label %12
11: ; preds = %6
store i8 0, i8* %8
br label %12
12: ; preds = %11, %6, %3, %1
%13 = phi i32 [ 0, %11 ], [ 1, %6 ], [ 1, %3 ], [ 1, %1 ]
ret i32 %13
}
/* Variables and functions */
double NAN;
double log10(double);
double piemathLog(double a) {
  if (a <= 0) {
    return NAN;
  }
  return log10(a);
}


x86 assembly (clang, -O0):
<piemathLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1140 <piemathLog+0x30>
mov    0x2ec6(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    114f <piemathLog+0x3f>
movsd  -0x10(%rbp),%xmm0
call   1030 <log10@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piemathLog>:
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    111f <piemathLog+0xf>
jmp    1030 <log10@plt>
mov    0x2ed2(%rip),%rax
movsd  (%rax),%xmm0
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define double @piemathLog(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, 0.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load double, double* @NAN
store double %7, double* %2
br label %11
8: ; preds = %1
%9 = load double, double* %3
%10 = call double @log10(double %9)
store double %10, double* %2
br label %11
11: ; preds = %8, %6
%12 = load double, double* %2
ret double %12
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
define double @piemathLog(double %0) {
%2 = fcmp ugt double %0, 0.000000e+00
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = load double, double* @NAN
br label %7
5: ; preds = %1
%6 = tail call double @log10(double %0)
br label %7
7: ; preds = %5, %3
%8 = phi double [ %4, %3 ], [ %6, %5 ]
ret double %8
}