#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ help();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char *whoami = (char *)malloc(0xdead);
  strcpy(whoami, "I'm an ELF :-)");
  printf("%s", whoami);
  puts("...\n");
  srand(time(NULL));
  if (rand() % 2) {
    printf("And I'm happy. I live free ! :-)\n");
    exit(EXIT_SUCCESS);
  } else
    help();
  fprintf(stdout, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xdead,%edi
call   1090 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     122f <main+0x8f>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   10a0 <help@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xdead,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xe4b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   10c0 <rand@plt>
test   $0x1,%al
jne    1213 <main+0x73>
xor    %eax,%eax
call   10a0 <help@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xdfd(%rip),%rdi
call   1040 <puts@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"I'm an ELF :-)\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"...\0A\00"
@.str.3 = [34 x i8] c"And I'm happy. I live free ! :-)\0A\00"
@EXIT_SUCCESS = global i32 0
@stdout = global i32 0
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i64 @malloc(i32 57005)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %0
%20 = call i32 (...) @help()
br label %21
21: ; preds = %19
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"I'm an ELF :-)\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"...\0A\00"
@EXIT_SUCCESS = global i32 0
@stdout = global i32 0
@.str.4 = [2 x i8] c"\0A\00"
@str = [33 x i8] c"And I'm happy. I live free ! :-)\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 57005)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srand(i32 %6)
%8 = tail call i32 (...) @rand()
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_SUCCESS
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = tail call i32 (...) @help()
%17 = load i32, i32* @stdout
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}