#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*/ fprintf(int /*<<< orphan*/, char *, long);
void *malloc(long);
long parse_human_number(char *);
int /*<<< orphan*/ stdout;
int syntax();
int main(int argc, char **argv) {
  void *buf;
  long mem;
  if (argc != 2)
    return syntax();
  mem = parse_human_number(argv[1]);
  if ((buf = malloc(mem))) {
    fprintf(stdout, "malloc %lu bytes succeeded.\n", mem);
    return 0;
  } else {
    fprintf(stdout, "malloc %lu bytes failed.\n", mem);
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116f <main+0x2f>
mov    $0x0,%al
call   1050 <syntax@plt>
mov    %eax,-0x4(%rbp)
jmp    11dc <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <parse_human_number@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11bc <main+0x7c>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe55(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dc <main+0x9c>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe4d(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jne    115b <main+0x2b>
push   %rax
mov    0x8(%rsi),%rdi
call   1050 <parse_human_number@plt>
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%edi
lea    0xeb1(%rip),%rsi
mov    %rax,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
jmp    1040 <syntax@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [29 x i8] c"malloc %lu bytes succeeded.\0A\00"
@.str.1 = [26 x i8] c"malloc %lu bytes failed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @syntax()
store i32 %11, i32* %3
br label %28
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @parse_human_number(i8* %15)
store i64 %16, i64* %7
%17 = load i64, i64* %7
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %12
%21 = load i32, i32* @stdout
%22 = load i64, i64* %7
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %22)
store i32 0, i32* %3
br label %28
24: ; preds = %12
%25 = load i32, i32* @stdout
%26 = load i64, i64* %7
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %26)
store i32 1, i32* %3
br label %28
28: ; preds = %24, %20, %10
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [29 x i8] c"malloc %lu bytes succeeded.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @syntax()
br label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @parse_human_number(i8* %8)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %9)
br label %12
12: ; preds = %6, %4
%13 = phi i32 [ %5, %4 ], [ 0, %6 ]
ret i32 %13
}