#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
int main() {
  char *some_memory;
  int megabyte = (1024 * 1024);
  int exit_code = EXIT_FAILURE;
  some_memory = (char *)malloc(megabyte);
  if (some_memory != NULL) {
    sprintf(some_memory, "Hello World\n");
    printf("%s", some_memory);
    exit_code = EXIT_SUCCESS;
  }
  exit(exit_code);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x100000,-0x14(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a5 <main+0x65>
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    (%rax),%ebx
mov    $0x100000,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     117c <main+0x4c>
movabs $0xa646c726f5720,%rcx
mov    %rcx,0x5(%rax)
movabs $0x6f57206f6c6c6548,%rcx
20 57 6f
mov    %rcx,(%rax)
lea    0xea2(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [13 x i8] c"Hello World\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = load i32, i32* @EXIT_FAILURE
%2 = tail call i64 @malloc(i32 1048576)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %8, label %5
5: ; preds = %0
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(13) %3, i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13, i1 false)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = load i32, i32* @EXIT_SUCCESS
br label %8
8: ; preds = %5, %0
%9 = phi i32 [ %7, %5 ], [ %1, %0 ]
%10 = tail call i32 @exit(i32 %9)
unreachable
}