#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(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
void memoryalloc(char ***arguments, char **line, char ***fname) {
  *arguments = (char **)malloc(81 * sizeof(char *));
  if (*arguments == NULL) {
    printf("ERROR 101 while allocating memory!\n");
    exit(101);
  }
  *line = (char *)malloc(81 * sizeof(char));
  if (*line == NULL) {
    printf("ERROR 102 while allocating memory!\n");
    exit(102);
  }
  *fname = (char **)malloc(3 * sizeof(char *));
  if (*fname == NULL) {
    printf("ERROR 103 while allocating memory!\n");
    exit(103);
  }
  return;
}


x86 assembly (clang, -O0):
<memoryalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x288,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    117c <memoryalloc+0x4c>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    $0x65,%edi
call   1050 <exit@plt>
mov    $0x51,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11b4 <memoryalloc+0x84>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x66,%edi
call   1050 <exit@plt>
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11ec <memoryalloc+0xbc>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x67,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memoryalloc>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x288,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     117a <memoryalloc+0x4a>
mov    $0x51,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1190 <memoryalloc+0x60>
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11a6 <memoryalloc+0x76>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x65,%edi
call   1050 <exit@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x66,%edi
call   1050 <exit@plt>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
mov    $0x67,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"ERROR 101 while allocating memory!\0A\00"
@.str.1 = [36 x i8] c"ERROR 102 while allocating memory!\0A\00"
@.str.2 = [36 x i8] c"ERROR 103 while allocating memory!\0A\00"
define void @memoryalloc(i8*** %0, i8** %1, i8*** %2) {
%4 = alloca i8***
%5 = alloca i8**
%6 = alloca i8***
store i8*** %0, i8**** %4
store i8** %1, i8*** %5
store i8*** %2, i8**** %6
%7 = call i64 @malloc(i32 648)
%8 = inttoptr i64 %7 to i8**
%9 = load i8***, i8**** %4
store i8** %8, i8*** %9
%10 = load i8***, i8**** %4
%11 = load i8**, i8*** %10
%12 = icmp eq i8** %11, null
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 101)
unreachable
16: ; preds = %3
%17 = call i64 @malloc(i32 81)
%18 = inttoptr i64 %17 to i8*
%19 = load i8**, i8*** %5
store i8* %18, i8** %19
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 102)
unreachable
26: ; preds = %16
%27 = call i64 @malloc(i32 24)
%28 = inttoptr i64 %27 to i8**
%29 = load i8***, i8**** %6
store i8** %28, i8*** %29
%30 = load i8***, i8**** %6
%31 = load i8**, i8*** %30
%32 = icmp eq i8** %31, null
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 103)
unreachable
36: ; preds = %26
ret void
}

LLVM IR (-O2):
@str = [35 x i8] c"ERROR 103 while allocating memory!\00"
@str.3 = [35 x i8] c"ERROR 102 while allocating memory!\00"
@str.4 = [35 x i8] c"ERROR 101 while allocating memory!\00"
define void @memoryalloc(i8*** nocapture writeonly %0, i8** nocapture writeonly %1, i8*** nocapture writeonly %2) {
%4 = tail call i64 @malloc(i32 648)
%5 = inttoptr i64 %4 to i8**
store i8** %5, i8*** %0
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.4, i64 0, i64 0))
%9 = tail call i32 @exit(i32 101)
unreachable
10: ; preds = %3
%11 = tail call i64 @malloc(i32 81)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %1
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.3, i64 0, i64 0))
%16 = tail call i32 @exit(i32 102)
unreachable
17: ; preds = %10
%18 = tail call i64 @malloc(i32 24)
%19 = inttoptr i64 %18 to i8**
store i8** %19, i8*** %2
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 103)
unreachable
24: ; preds = %17
ret void
}