#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 allocateMemory(int);
scalar_t__ isNotAboveMaximumAmount(int);
scalar_t__ isPositiveMemoryAmount(int);
int /*<<< orphan*/ printLine(char *, int, int);
int /*<<< orphan*/ printNewLineCharacter();
int /*<<< orphan*/ storeUserInteger(int *);
int main() {
  int application_status = 1;
  int memory_amount = 0;
  printLine("Enter the number of MegaBytes of memory to allocate (32BIT max is "
            "2GB): ",
            0, 0);
  storeUserInteger(&memory_amount);
  printNewLineCharacter();
  if (isPositiveMemoryAmount(memory_amount) &&
      isNotAboveMaximumAmount(memory_amount))
    application_status = allocateMemory(memory_amount);
  else
    printLine("Negative and extremely huge sizes of memory are not supported.",
              1, 0);
  printNewLineCharacter();
  printLine("Press enter to quit...", 0, 1);
  return application_status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7c(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <printLine@plt>
lea    -0xc(%rbp),%rdi
call   1050 <storeUserInteger@plt>
mov    $0x0,%al
call   1070 <printNewLineCharacter@plt>
mov    -0xc(%rbp),%edi
call   1040 <isPositiveMemoryAmount@plt>
cmp    $0x0,%rax
je     11d1 <main+0x71>
mov    -0xc(%rbp),%edi
call   1030 <isNotAboveMaximumAmount@plt>
cmp    $0x0,%rax
je     11d1 <main+0x71>
mov    -0xc(%rbp),%edi
call   1080 <allocateMemory@plt>
mov    %eax,-0x8(%rbp)
jmp    11e4 <main+0x84>
lea    0xe71(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1060 <printLine@plt>
mov    $0x0,%al
call   1070 <printNewLineCharacter@plt>
lea    0xe96(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <printLine@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe8c(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <printLine@plt>
lea    0xc(%rsp),%rdi
call   1050 <storeUserInteger@plt>
xor    %eax,%eax
call   1070 <printNewLineCharacter@plt>
mov    0xc(%rsp),%edi
call   1040 <isPositiveMemoryAmount@plt>
test   %rax,%rax
je     11b7 <main+0x57>
mov    0xc(%rsp),%edi
call   1030 <isNotAboveMaximumAmount@plt>
test   %rax,%rax
je     11b7 <main+0x57>
mov    0xc(%rsp),%edi
call   1080 <allocateMemory@plt>
mov    %eax,%ebx
jmp    11cf <main+0x6f>
lea    0xe8b(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %edx,%edx
call   1060 <printLine@plt>
xor    %eax,%eax
call   1070 <printNewLineCharacter@plt>
lea    0xeab(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <printLine@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Enter the number of MegaBytes of memory to allocate (32BIT max is 2GB): \00"
@.str.1 = [63 x i8] c"Negative and extremely huge sizes of memory are not supported.\00"
@.str.2 = [23 x i8] c"Press enter to quit...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
%4 = call i32 @printLine(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
%5 = call i32 @storeUserInteger(i32* %3)
%6 = call i32 (...) @printNewLineCharacter()
%7 = load i32, i32* %3
%8 = call i64 @isPositiveMemoryAmount(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %0
%11 = load i32, i32* %3
%12 = call i64 @isNotAboveMaximumAmount(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i32 @allocateMemory(i32 %15)
store i32 %16, i32* %2
br label %19
17: ; preds = %10, %0
%18 = call i32 @printLine(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 0)
br label %19
19: ; preds = %17, %14
%20 = call i32 (...) @printNewLineCharacter()
%21 = call i32 @printLine(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [73 x i8] c"Enter the number of MegaBytes of memory to allocate (32BIT max is 2GB): \00"
@.str.1 = [63 x i8] c"Negative and extremely huge sizes of memory are not supported.\00"
@.str.2 = [23 x i8] c"Press enter to quit...\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @printLine(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
%4 = call i32 @storeUserInteger(i32* %1)
%5 = call i32 (...) @printNewLineCharacter()
%6 = load i32, i32* %1
%7 = call i64 @isPositiveMemoryAmount(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %0
%10 = load i32, i32* %1
%11 = call i64 @isNotAboveMaximumAmount(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = load i32, i32* %1
%15 = call i32 @allocateMemory(i32 %14)
br label %18
16: ; preds = %9, %0
%17 = call i32 @printLine(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 0)
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ %15, %13 ], [ 1, %16 ]
%20 = call i32 (...) @printNewLineCharacter()
%21 = call i32 @printLine(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
ret i32 %19
}