xunge/DecIR huggingface dataset:
/* Variables and functions */
char *_(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int,
                           char const *);
int /*<<< orphan*/ stderr;
int error_dup(int opt, const char *already, const char *additionnal) {
  fprintf(stderr,
          _("Duplicate parameter \"%s\" for option -%c\n"
            "would override previous value \"%s\".\n"),
          additionnal, opt, already);
  return 2;
}


x86 assembly (clang, -O0):
<error_dup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <_@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%r8
call   1030 <fprintf@plt>
mov    $0x2,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_dup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2eaa(%rip),%rax
mov    (%rax),%ebx
lea    0xec1(%rip),%rdi
call   1040 <_@plt>
mov    %ebx,%edi
mov    %rax,%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    %r14,%r8
call   1030 <fprintf@plt>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [77 x i8] c"Duplicate parameter \22%s\22 for option -%c\0Awould override previous value \22%s\22.\0A\00"
define i32 @error_dup(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* @stderr
%8 = call i8* @_(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %6
%10 = load i32, i32* %4
%11 = load i8*, i8** %5
%12 = call i32 @fprintf(i32 %7, i8* %8, i8* %9, i32 %10, i8* %11)
ret i32 2
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [77 x i8] c"Duplicate parameter \22%s\22 for option -%c\0Awould override previous value \22%s\22.\0A\00"
define i32 @error_dup(i32 %0, i8* %1, i8* %2) {
%4 = load i32, i32* @stderr
%5 = tail call i8* @_(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @fprintf(i32 %4, i8* %5, i8* %2, i32 %0, i8* %1)
ret i32 2
}
/* Variables and functions */
int mmc_datatrans(int /*<<< orphan*/, void *, unsigned long, int);
int mmc_readsector(void *data, unsigned long sector) {
  return mmc_datatrans(0, data, sector, 1);
}


x86 assembly (clang, -O0):
<mmc_readsector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %edi,%edi
mov    $0x1,%ecx
call   1030 <mmc_datatrans@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mmc_readsector>:
mov    %rsi,%rdx
mov    %rdi,%rsi
xor    %edi,%edi
mov    $0x1,%ecx
jmp    1030 <mmc_datatrans@plt>

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

LLVM IR (-O2):
define i32 @mmc_readsector(i8* %0, i64 %1) {
%3 = tail call i32 @mmc_datatrans(i32 0, i8* %0, i64 %1, i32 1)
ret i32 %3
}
void f6(char a0, short a1, int a2, long long a3, void *a4) {}


x86 assembly (clang, -O0):
<f6>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %ax,-0x4(%rbp)
mov    %edx,-0x8(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @f6(i8 signext %0, i16 signext %1, i32 %2, i64 %3, i8* %4) {
%6 = alloca i8
%7 = alloca i16
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
store i8 %0, i8* %6
store i16 %1, i16* %7
store i32 %2, i32* %8
store i64 %3, i64* %9
store i8* %4, i8** %10
ret void
}

LLVM IR (-O2):
define void @f6(i8 signext %0, i16 signext %1, i32 %2, i64 %3, i8* nocapture %4) {
ret void
}
int test_imm_96uint32_mem(unsigned int *val) {
  return ((*val) & (0x96 << 0)) ? -20 : -40;
}


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

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

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

LLVM IR (-O2):
define i32 @test_imm_96uint32_mem(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = and i32 %2, 150
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Type definitions */
typedef int u_int8_t;
typedef scalar_t__ sig_t;

/* Variables and functions */
int /*<<< orphan*/ SIGTTOU;
scalar_t__ SIG_ERR;
int /*<<< orphan*/ SIG_IGN;
scalar_t__ signal(int /*<<< orphan*/, int /*<<< orphan*/);
u_int8_t __ignore_background_tty_writes() {
  sig_t prev_val;
  prev_val = signal(SIGTTOU, SIG_IGN);
  return (prev_val == SIG_ERR);
}


x86 assembly (clang, -O0):
<__ignore_background_tty_writes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ignore_background_tty_writes>:
push   %rax
mov    0x2ed0(%rip),%rax
mov    (%rax),%edi
mov    0x2ebf(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2ea1(%rip),%rdx
xor    %ecx,%ecx
cmp    (%rdx),%rax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@SIGTTOU = global i32 0
@SIG_IGN = global i32 0
@SIG_ERR = global i64 0
define i32 @__ignore_background_tty_writes() {
%1 = alloca i64
%2 = load i32, i32* @SIGTTOU
%3 = load i32, i32* @SIG_IGN
%4 = call i64 @signal(i32 %2, i32 %3)
store i64 %4, i64* %1
%5 = load i64, i64* %1
%6 = load i64, i64* @SIG_ERR
%7 = icmp eq i64 %5, %6
%8 = zext i1 %7 to i32
ret i32 %8
}

LLVM IR (-O2):
@SIGTTOU = global i32 0
@SIG_IGN = global i32 0
@SIG_ERR = global i64 0
define i32 @__ignore_background_tty_writes() {
%1 = load i32, i32* @SIGTTOU
%2 = load i32, i32* @SIG_IGN
%3 = tail call i64 @signal(i32 %1, i32 %2)
%4 = load i64, i64* @SIG_ERR
%5 = icmp eq i64 %3, %4
%6 = zext i1 %5 to i32
ret i32 %6
}
/* Type definitions */
struct winsize {
  int ws_row;
};

/* Variables and functions */
int /*<<< orphan*/ TIOCGWINSZ;
scalar_t__ ioctl(int /*<<< orphan*/, int /*<<< orphan*/, struct winsize *);
int t_getheight() {
  struct winsize ts;
  if (ioctl(0, TIOCGWINSZ, &ts)) {
    return -1;
  }
  return ts.ws_row;
}


x86 assembly (clang, -O0):
<t_getheight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x8(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
je     1142 <t_getheight+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    1148 <t_getheight+0x38>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_getheight>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1030 <ioctl@plt>
neg    %rax
sbb    %eax,%eax
or     (%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.winsize = type { i32 }
@TIOCGWINSZ = global i32 0
define i32 @t_getheight() {
%1 = alloca i32
%2 = alloca %struct.winsize
%3 = load i32, i32* @TIOCGWINSZ
%4 = call i64 @ioctl(i32 0, i32 %3, %struct.winsize* %2)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 -1, i32* %1
br label %10
7: ; preds = %0
%8 = getelementptr inbounds %struct.winsize, %struct.winsize* %2, i32 0, i32 0
%9 = load i32, i32* %8
store i32 %9, i32* %1
br label %10
10: ; preds = %7, %6
%11 = load i32, i32* %1
ret i32 %11
}

LLVM IR (-O2):
%struct.winsize = type { i32 }
@TIOCGWINSZ = global i32 0
define i32 @t_getheight() {
%1 = alloca %struct.winsize
%2 = bitcast %struct.winsize* %1 to i8*
%3 = load i32, i32* @TIOCGWINSZ
%4 = call i64 @ioctl(i32 0, i32 %3, %struct.winsize* %1)
%5 = icmp eq i64 %4, 0
%6 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = select i1 %5, i32 %7, i32 -1
ret i32 %8
}
/* Type definitions */
struct splay_tree_s {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ splay_tree_insert(struct splay_tree_s *, char *, void *);
void splay_insert(struct splay_tree_s *splay, const void *data,
                  const char *key) {
  splay_tree_insert(splay, (char *)key, (void *)data);
}


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

x86 assembly (clang, -O2):
<splay_insert>:
mov    %rsi,%rax
mov    %rdx,%rsi
mov    %rax,%rdx
jmp    1030 <splay_tree_insert@plt>

LLVM IR (-O0):
%struct.splay_tree_s = type { i32 }
define void @splay_insert(%struct.splay_tree_s* %0, i8* %1, i8* %2) {
%4 = alloca %struct.splay_tree_s*
%5 = alloca i8*
%6 = alloca i8*
store %struct.splay_tree_s* %0, %struct.splay_tree_s** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load %struct.splay_tree_s*, %struct.splay_tree_s** %4
%8 = load i8*, i8** %6
%9 = load i8*, i8** %5
%10 = call i32 @splay_tree_insert(%struct.splay_tree_s* %7, i8* %8, i8* %9)
ret void
}

LLVM IR (-O2):
%struct.splay_tree_s = type { i32 }
define void @splay_insert(%struct.splay_tree_s* %0, i8* %1, i8* %2) {
%4 = tail call i32 @splay_tree_insert(%struct.splay_tree_s* %0, i8* %2, i8* %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char buffer[5];
  strcpy(buffer, argv[1]);
  return 0;
}


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)
lea    -0x15(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rsi
lea    0x3(%rsp),%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strcpy(i8* %7, i8* %10)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i32 @strcpy(i8* %4, i8* %6)
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ getpid();
int kill(int /*<<< orphan*/, int);
int raise(int sig) {
  int ret;
  pid_t pid;
  pid = getpid();
  ret = kill(pid, sig);
  return ret;
}


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

x86 assembly (clang, -O2):
<raise>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%edi
mov    %ebx,%esi
pop    %rbx
jmp    1040 <kill@plt>

LLVM IR (-O0):
define i32 @raise(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @getpid()
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = call i32 @kill(i32 %6, i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
ret i32 %9
}

LLVM IR (-O2):
define i32 @raise(i32 %0) {
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 @kill(i32 %2, i32 %0)
ret i32 %3
}
void security_socket_post_create(struct socket *sock, int family, int type,
                                 int protocol) {}


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

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

LLVM IR (-O0):
%struct.socket = type opaque
define void @security_socket_post_create(%struct.socket* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.socket*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.socket* %0, %struct.socket** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
ret void
}

LLVM IR (-O2):
%struct.socket = type opaque
define void @security_socket_post_create(%struct.socket* nocapture %0, i32 %1, i32 %2, i32 %3) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void usage() {
  printf("usage:\n"
         "   ldrdf [options] object modules ... [-llibrary ...]\n"
         "   ldrdf -r\n"
         "options:\n"
         "   -v[=n]          increase verbosity by 1, or set it to n\n"
         "   -a nn           set segment alignment value (default 16)\n"
         "   -s              strip public symbols\n"
         "   -dy             Unix-style dynamic linking\n"
         "   -o name         write output in file 'name'\n"
         "   -j path         specify objects search path\n"
         "   -L path         specify libraries search path\n"
         "   -g file         embed 'file' as a first header record with type "
         "'generic'\n");
  exit(0);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

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

LLVM IR (-O0):
@.str = [508 x i8] c"usage:\0A ldrdf [options] object modules ... [-llibrary ...]\0A ldrdf -r\0Aoptions:\0A -v[=n] increase verbosity by 1, or set it to n\0A -a nn set segment alignment value (default 16)\0A -s strip public symbols\0A -dy Unix-style dynamic linking\0A -o name write output in file 'name'\0A -j path specify objects search path\0A -L path specify libraries search path\0A -g file embed 'file' as a first header record with type 'generic'\0A\00"
define void @usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([508 x i8], [508 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [507 x i8] c"usage:\0A ldrdf [options] object modules ... [-llibrary ...]\0A ldrdf -r\0Aoptions:\0A -v[=n] increase verbosity by 1, or set it to n\0A -a nn set segment alignment value (default 16)\0A -s strip public symbols\0A -dy Unix-style dynamic linking\0A -o name write output in file 'name'\0A -j path specify objects search path\0A -L path specify libraries search path\0A -g file embed 'file' as a first header record with type 'generic'\00"
define void @usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([507 x i8], [507 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @exit(i32 0)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main() {
  printf("Hello World2!\n");
  return 0;
}


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

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

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

LLVM IR (-O2):
@str = [14 x i8] c"Hello World2!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}
int mask(int pos, int bits) {
  int i;
  unsigned int m;
  i = 8 * sizeof(int);
  m = ~(0);
  m = m << (i - bits);
  m = m >> (i - 1 - pos);
  return m;
}


x86 assembly (clang, -O0):
<mask>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x20,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x4(%rbp),%ecx
shr    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mask>:
mov    %esi,%ecx
neg    %cl
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    $0x1f,%cl
sub    %dil,%cl
shr    %cl,%eax
ret

LLVM IR (-O0):
define i32 @mask(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 32, i32* %5
store i32 -1, i32* %6
%7 = load i32, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %8, %9
%11 = shl i32 %7, %10
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %3
%16 = sub nsw i32 %14, %15
%17 = lshr i32 %12, %16
store i32 %17, i32* %6
%18 = load i32, i32* %6
ret i32 %18
}

LLVM IR (-O2):
define i32 @mask(i32 %0, i32 %1) {
%3 = sub nsw i32 32, %1
%4 = shl nsw i32 -1, %3
%5 = sub nsw i32 31, %0
%6 = lshr i32 %4, %5
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ my_printf(char *, ...);
int main(void) {
  my_printf("hi\n");
  my_printf("hi %d\n", 42);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <my_printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <my_printf@plt>
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [4 x i8] c"hi\0A\00"
@.str.1 = [7 x i8] c"hi %d\0A\00"
define i32 @main() {
%1 = call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 42)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"hi\0A\00"
@.str.1 = [7 x i8] c"hi %d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 42)
ret i32 0
}
void barrier_compiler(void) { __asm__ volatile("" : : : "memory"); }


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

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

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

LLVM IR (-O2):
define void @barrier_compiler() {
tail call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ remove(char *);
void RemoveMyPid() { remove("pid"); }


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

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

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

LLVM IR (-O2):
@.str = [4 x i8] c"pid\00"
define void @RemoveMyPid() {
%1 = tail call i32 @remove(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int is_unique(char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char *s = "abca";
  int isUnique = is_unique(s);
  if (isUnique) {
    printf("%s has all unique characters!\n", s);
    return 0;
  } else {
    printf("%s does not have all unique characters!\n", s);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <is_unique@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116c <main+0x4c>
mov    -0x10(%rbp),%rsi
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1183 <main+0x63>
mov    -0x10(%rbp),%rsi
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <is_unique@plt>
test   %eax,%eax
lea    0xeeb(%rip),%rax
lea    0xec5(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"abca\00"
@.str.1 = [31 x i8] c"%s has all unique characters!\0A\00"
@.str.2 = [41 x i8] c"%s does not have all unique characters!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @is_unique(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %9)
store i32 0, i32* %1
br label %14
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %12)
store i32 0, i32* %1
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [5 x i8] c"abca\00"
@.str.1 = [31 x i8] c"%s has all unique characters!\0A\00"
@.str.2 = [41 x i8] c"%s does not have all unique characters!\0A\00"
define i32 @main() {
%1 = tail call i32 @is_unique(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
%3 = select i1 %2, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0)
%4 = tail call i32 @printf(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void fe(char *mess, char *arg) {
  if (arg)
    fprintf(stderr, mess, arg);
  else
    fprintf(stderr, mess);
  fprintf(stderr, "\n");
  exit(1);
}


x86 assembly (clang, -O0):
<fe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1158 <fe+0x38>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    116c <fe+0x4c>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<fe>:
push   %rbx
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    0x2eb2(%rip),%rbx
mov    (%rbx),%edi
xor    %eax,%eax
test   %rdx,%rdx
jne    113e <fe+0x1e>
call   1030 <fprintf@plt>
jmp    1143 <fe+0x23>
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeb4(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @fe(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
%4 = load i32, i32* @stderr
br i1 %3, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* %0, i8* %1)
br label %9
7: ; preds = %2
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* %0)
br label %9
9: ; preds = %7, %5
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ test_compare_exchanges();
int /*<<< orphan*/ test_exchanges();
int /*<<< orphan*/ test_fetch_op();
int /*<<< orphan*/ test_is_lock_free();
int /*<<< orphan*/ test_loads();
int /*<<< orphan*/ test_stores();
int main() {
  test_loads();
  test_stores();
  test_exchanges();
  test_compare_exchanges();
  test_fetch_op();
  test_is_lock_free();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <test_loads@plt>
mov    $0x0,%al
call   1050 <test_stores@plt>
mov    $0x0,%al
call   1030 <test_exchanges@plt>
mov    $0x0,%al
call   1080 <test_compare_exchanges@plt>
mov    $0x0,%al
call   1070 <test_fetch_op@plt>
mov    $0x0,%al
call   1060 <test_is_lock_free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <test_loads@plt>
xor    %eax,%eax
call   1050 <test_stores@plt>
xor    %eax,%eax
call   1030 <test_exchanges@plt>
xor    %eax,%eax
call   1080 <test_compare_exchanges@plt>
xor    %eax,%eax
call   1070 <test_fetch_op@plt>
xor    %eax,%eax
call   1060 <test_is_lock_free@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @test_loads()
%3 = call i32 (...) @test_stores()
%4 = call i32 (...) @test_exchanges()
%5 = call i32 (...) @test_compare_exchanges()
%6 = call i32 (...) @test_fetch_op()
%7 = call i32 (...) @test_is_lock_free()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @test_loads()
%2 = tail call i32 (...) @test_stores()
%3 = tail call i32 (...) @test_exchanges()
%4 = tail call i32 (...) @test_compare_exchanges()
%5 = tail call i32 (...) @test_fetch_op()
%6 = tail call i32 (...) @test_is_lock_free()
ret i32 0
}
/* Type definitions */
struct ncpaddr {
  int dummy;
};

/* Variables and functions */
char const *ncpaddr_ntowa(struct ncpaddr const *);
const char *ncpaddr_ntoa(const struct ncpaddr *addr) {
  return ncpaddr_ntowa(addr);
}


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

x86 assembly (clang, -O2):
<ncpaddr_ntoa>:
jmp    1030 <ncpaddr_ntowa@plt>

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

LLVM IR (-O2):
%struct.ncpaddr = type { i32 }
define i8* @ncpaddr_ntoa(%struct.ncpaddr* %0) {
%2 = tail call i8* @ncpaddr_ntowa(%struct.ncpaddr* %0)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ usb_cleanup();
void CUSBCleanup(void) { usb_cleanup(); }


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

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

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

LLVM IR (-O2):
define void @CUSBCleanup() {
%1 = tail call i32 (...) @usb_cleanup()
ret void
}
float Max(float a, float b) { return (a < b) ? b : a; }


x86 assembly (clang, -O0):
<Max>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1130 <Max+0x30>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    113a <Max+0x3a>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<Max>:
maxss  %xmm0,%xmm1
movaps %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define float @Max(float %0, float %1) {
%3 = fcmp olt float %0, %1
%4 = select i1 %3, float %1, float %0
ret float %4
}
/* Type definitions */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
void *mellow_allocString(void *, int /*<<< orphan*/);
void *charsToString(void *chs) {
  return mellow_allocString(chs + ((8) + (8)), ((uint64_t *)(chs))[1]);
}


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

x86 assembly (clang, -O2):
<charsToString>:
mov    0x4(%rdi),%esi
add    $0x10,%rdi
jmp    1030 <mellow_allocString@plt>

LLVM IR (-O0):
define i8* @charsToString(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr i8, i8* %3, i64 16
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
%7 = getelementptr inbounds i32, i32* %6, i64 1
%8 = load i32, i32* %7
%9 = call i8* @mellow_allocString(i8* %4, i32 %8)
ret i8* %9
}

LLVM IR (-O2):
define i8* @charsToString(i8* %0) {
%2 = getelementptr i8, i8* %0, i64 16
%3 = getelementptr inbounds i8, i8* %0, i64 4
%4 = bitcast i8* %3 to i32*
%5 = load i32, i32* %4
%6 = tail call i8* @mellow_allocString(i8* %2, i32 %5)
ret i8* %6
}
/* Variables and functions */
int /*<<< orphan*/ LBA_REG_WRITE(void *, int, int);
int apollo_util_reset(void *phys_addr) {
  LBA_REG_WRITE(phys_addr, 0x0500, 0xf);
  return 0;
}


x86 assembly (clang, -O0):
<apollo_util_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x500,%esi
mov    $0xf,%edx
call   1030 <LBA_REG_WRITE@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apollo_util_reset>:
push   %rax
mov    $0x500,%esi
mov    $0xf,%edx
call   1030 <LBA_REG_WRITE@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @apollo_util_reset(i8* %0) {
%2 = tail call i32 @LBA_REG_WRITE(i8* %0, i32 1280, i32 15)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ abc(char *);
int main() {
  abc("123");
  return 0;
}


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

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

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

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
define i32 @main() {
%1 = tail call i32 @abc(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
int cpuid_cmp(const void *a, const void *b) {
  int *id1 = (int *)a;
  int *id2 = (int *)b;
  if (*id1 > *id2) {
    return (1);
  }
  if (*id1 < *id2) {
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<cpuid_cmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jle    113a <cpuid_cmp+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    115f <cpuid_cmp+0x5f>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    1158 <cpuid_cmp+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    115f <cpuid_cmp+0x5f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuid_cmp>:
mov    (%rdi),%eax
mov    (%rsi),%ecx
xor    %edx,%edx
cmp    %ecx,%eax
setl   %dl
neg    %edx
cmp    %ecx,%eax
mov    $0x1,%eax
cmovle %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @cpuid_cmp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i32*
%4 = bitcast i8* %1 to i32*
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = icmp sgt i32 %5, %6
%8 = icmp slt i32 %5, %6
%9 = sext i1 %8 to i32
%10 = select i1 %7, i32 1, i32 %9
ret i32 %10
}
/* Variables and functions */
int EOF;
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  printf("EOF is %d\n", EOF);
  return 0;
}


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

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

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

LLVM IR (-O2):
@.str = [11 x i8] c"EOF is %d\0A\00"
@EOF = global i32 0
define i32 @main() {
%1 = load i32, i32* @EOF
%2 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %1)
ret i32 0
}
/* Variables and functions */
double atof(char const *);
char *opt_get_string(char const *, char const *, int /*<<< orphan*/ *);
double opt_get_double(const char *section, const char *key, double defvalue) {
  const char *value;
  value = opt_get_string(section, key, NULL);
  if (value != NULL)
    return atof(value);
  else
    return defvalue;
}


x86 assembly (clang, -O0):
<opt_get_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <opt_get_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1168 <opt_get_double+0x48>
mov    -0x28(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1172 <opt_get_double+0x52>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_get_double>:
push   %rax
movsd  %xmm0,(%rsp)
xor    %edx,%edx
call   1040 <opt_get_string@plt>
test   %rax,%rax
je     113b <opt_get_double+0x1b>
mov    %rax,%rdi
pop    %rax
jmp    1030 <atof@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @opt_get_double(i8* %0, i8* %1, double %2) {
%4 = alloca double
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca double
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store double %2, double* %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i8* @opt_get_string(i8* %9, i8* %10, i32* null)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %8
%16 = call double @atof(i8* %15)
store double %16, double* %4
br label %19
17: ; preds = %3
%18 = load double, double* %7
store double %18, double* %4
br label %19
19: ; preds = %17, %14
%20 = load double, double* %4
ret double %20
}

LLVM IR (-O2):
define double @opt_get_double(i8* %0, i8* %1, double %2) {
%4 = tail call i8* @opt_get_string(i8* %0, i8* %1, i32* null)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call double @atof(i8* %4)
br label %8
8: ; preds = %3, %6
%9 = phi double [ %7, %6 ], [ %2, %3 ]
ret double %9
}
/* Variables and functions */
int /*<<< orphan*/ setllent();
extern void p_setllent(void) { setllent(); }


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

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

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

LLVM IR (-O2):
define void @p_setllent() {
%1 = tail call i32 (...) @setllent()
ret void
}
/* Variables and functions */
unsigned short strlen(const char *s) {
  int result = 0;
  while (*s != '\0') {
    result++;
    s++;
  }
  return result;
}


x86 assembly (clang, -O0):
<strlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1139 <strlen+0x39>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <strlen+0xf>
mov    -0xc(%rbp),%eax
movzwl %ax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlen>:
cmpb   $0x0,(%rdi)
je     111c <strlen+0x1c>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,0x1(%rdi,%rax,1)
lea    0x1(%rax),%rax
jne    1110 <strlen+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define zeroext i16 @strlen(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %7, %4 ], [ 0, %1 ]
%6 = phi i8* [ %8, %4 ], [ %0, %1 ]
%7 = add nuw nsw i32 %5, 1
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = trunc i32 %7 to i16
br label %13
13: ; preds = %11, %1
%14 = phi i16 [ 0, %1 ], [ %12, %11 ]
ret i16 %14
}
void memzero(void *data, unsigned nbytes) {
  unsigned *wordp = (unsigned *)data;
  unsigned nwords = nbytes / sizeof(int);
  while (nwords-- > 0)
    *wordp++ = 0;
}


x86 assembly (clang, -O0):
<memzero>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
shr    $0x2,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
jbe    114b <memzero+0x4b>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
movl   $0x0,(%rax)
jmp    111d <memzero+0x1d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<memzero>:
cmp    $0x4,%esi
jb     112f <memzero+0x1f>
push   %rax
shr    $0x2,%esi
add    $0xffffffff,%esi
lea    0x4(,%rsi,4),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
ret

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

LLVM IR (-O2):
define void @memzero(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp ult i32 %1, 4
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = lshr i32 %1, 2
%6 = add nsw i32 %5, -1
%7 = zext i32 %6 to i64
%8 = shl nuw nsw i64 %7, 2
%9 = add nuw nsw i64 %8, 4
br label %10
10: ; preds = %4, %2
ret void
}
double sgn(double nu) {
  double result;
  if (nu < 0)
    result = -1;
  else
    result = 1;
  return result;
}


x86 assembly (clang, -O0):
<sgn>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1129 <sgn+0x29>
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1136 <sgn+0x36>
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sgn>:
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
lea    0xeec(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
ret

LLVM IR (-O0):
define double @sgn(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %1
store double -1.000000e+00, double* %3
br label %8
7: ; preds = %1
store double 1.000000e+00, double* %3
br label %8
8: ; preds = %7, %6
%9 = load double, double* %3
ret double %9
}

LLVM IR (-O2):
define double @sgn(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = select i1 %2, double -1.000000e+00, double 1.000000e+00
ret double %3
}
/* Variables and functions */
int /*<<< orphan*/ ASAN_POISON_MEMORY_REGION(char *, int);
int /*<<< orphan*/ ASAN_UNPOISON_MEMORY_REGION(char *, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
long long strtoll(char *, int /*<<< orphan*/ *, int);
void test3(char *array, char *endptr) {
  memset(array, 0, 8);
  ASAN_POISON_MEMORY_REGION(array, 8);
  long long r = strtoll(array + 1, NULL, -1);
  assert(r == 0);
  ASAN_UNPOISON_MEMORY_REGION(array, 8);
}


x86 assembly (clang, -O0):
<test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1070 <ASAN_POISON_MEMORY_REGION@plt>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xffffffff,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1030 <ASAN_UNPOISON_MEMORY_REGION@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test3>:
push   %rbx
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1070 <ASAN_POISON_MEMORY_REGION@plt>
lea    0x1(%rbx),%rdi
xor    %esi,%esi
mov    $0xffffffff,%edx
call   1050 <strtoll@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
pop    %rbx
jmp    1030 <ASAN_UNPOISON_MEMORY_REGION@plt>

LLVM IR (-O0):
define void @test3(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @memset(i8* %6, i32 0, i32 8)
%8 = load i8*, i8** %3
%9 = call i32 @ASAN_POISON_MEMORY_REGION(i8* %8, i32 8)
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i64 @strtoll(i8* %11, i32* null, i32 -1)
store i64 %12, i64* %5
%13 = load i64, i64* %5
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %3
%18 = call i32 @ASAN_UNPOISON_MEMORY_REGION(i8* %17, i32 8)
ret void
}

LLVM IR (-O2):
define void @test3(i8* %0, i8* nocapture readnone %1) {
%3 = tail call i32 @memset(i8* %0, i32 0, i32 8)
%4 = tail call i32 @ASAN_POISON_MEMORY_REGION(i8* %0, i32 8)
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = tail call i64 @strtoll(i8* nocapture %5, i32* null, i32 -1)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @ASAN_UNPOISON_MEMORY_REGION(i8* %0, i32 8)
ret void
}
/* Type definitions */
struct module {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ examples_init(char const *);
int /*<<< orphan*/ module_prepare_mocks(struct module **);
void examples_init_NCC(const char *name, struct module **mod) {
  examples_init(name);
  module_prepare_mocks(mod);
}


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

x86 assembly (clang, -O2):
<examples_init_NCC>:
push   %rbx
mov    %rsi,%rbx
call   1040 <examples_init@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <module_prepare_mocks@plt>

LLVM IR (-O0):
%struct.module = type { i32 }
define void @examples_init_NCC(i8* %0, %struct.module** %1) {
%3 = alloca i8*
%4 = alloca %struct.module**
store i8* %0, i8** %3
store %struct.module** %1, %struct.module*** %4
%5 = load i8*, i8** %3
%6 = call i32 @examples_init(i8* %5)
%7 = load %struct.module**, %struct.module*** %4
%8 = call i32 @module_prepare_mocks(%struct.module** %7)
ret void
}

LLVM IR (-O2):
%struct.module = type { i32 }
define void @examples_init_NCC(i8* %0, %struct.module** %1) {
%3 = tail call i32 @examples_init(i8* %0)
%4 = tail call i32 @module_prepare_mocks(%struct.module** %1)
ret void
}