#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 *, ...);
char **logalloc() {
  int i;
  char **tmp;
  tmp = (char **)malloc(10 * sizeof(char *));
  if (tmp == NULL) {
    printf("ERROR 104 while allocating memory!\n");
    exit(104);
  }
  for (i = 0; i < 10; i++) {
    tmp[i] = (char *)malloc(81 * sizeof(char));
    if (tmp[i] == NULL) {
      printf("ERROR 104.%d while allocating memory!\n", i + 1);
      exit(105);
    }
  }
  return tmp;
}


x86 assembly (clang, -O0):
<logalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x50,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1169 <logalloc+0x39>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x68,%edi
call   1050 <exit@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11d7 <logalloc+0xa7>
mov    $0x51,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11c4 <logalloc+0x94>
mov    -0x4(%rbp),%esi
add    $0x1,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x69,%edi
call   1050 <exit@plt>
jmp    11c9 <logalloc+0x99>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <logalloc+0x40>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logalloc>:
push   %rbx
mov    $0x50,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1231 <logalloc+0xf1>
mov    %rax,%rbx
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1247 <logalloc+0x107>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rbx)
test   %rax,%rax
je     124e <logalloc+0x10e>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rbx)
test   %rax,%rax
je     1255 <logalloc+0x115>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%rbx)
test   %rax,%rax
je     125c <logalloc+0x11c>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%rbx)
test   %rax,%rax
je     1263 <logalloc+0x123>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x28(%rbx)
test   %rax,%rax
je     126a <logalloc+0x12a>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x30(%rbx)
test   %rax,%rax
je     1271 <logalloc+0x131>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x38(%rbx)
test   %rax,%rax
je     1278 <logalloc+0x138>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x40(%rbx)
test   %rax,%rax
je     127f <logalloc+0x13f>
mov    $0x51,%edi
call   1050 <malloc@plt>
mov    %rax,0x48(%rbx)
test   %rax,%rax
je     1286 <logalloc+0x146>
mov    %rbx,%rax
pop    %rbx
ret
lea    0xdef(%rip),%rdi
call   1030 <puts@plt>
mov    $0x68,%edi
call   1060 <exit@plt>
mov    $0x1,%esi
jmp    128b <logalloc+0x14b>
mov    $0x2,%esi
jmp    128b <logalloc+0x14b>
mov    $0x3,%esi
jmp    128b <logalloc+0x14b>
mov    $0x4,%esi
jmp    128b <logalloc+0x14b>
mov    $0x5,%esi
jmp    128b <logalloc+0x14b>
mov    $0x6,%esi
jmp    128b <logalloc+0x14b>
mov    $0x7,%esi
jmp    128b <logalloc+0x14b>
mov    $0x8,%esi
jmp    128b <logalloc+0x14b>
mov    $0x9,%esi
jmp    128b <logalloc+0x14b>
mov    $0xa,%esi
lea    0xd6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x69,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str.1 = [39 x i8] c"ERROR 104.%d while allocating memory!\0A\00"
@str = [35 x i8] c"ERROR 104 while allocating memory!\00"
define i8** @logalloc() {
%1 = tail call i64 @malloc(i32 80)
%2 = inttoptr i64 %1 to i8**
%3 = icmp eq i64 %1, 0
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i64 @malloc(i32 81)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = icmp eq i64 %5, 0
br i1 %7, label %11, label %15
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 104)
unreachable
11: ; preds = %55, %50, %45, %40, %35, %30, %25, %20, %15, %4
%12 = phi i32 [ 1, %4 ], [ 2, %15 ], [ 3, %20 ], [ 4, %25 ], [ 5, %30 ], [ 6, %35 ], [ 7, %40 ], [ 8, %45 ], [ 9, %50 ], [ 10, %55 ]
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @exit(i32 105)
unreachable
15: ; preds = %4
%16 = tail call i64 @malloc(i32 81)
%17 = inttoptr i64 %16 to i8*
%18 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* %17, i8** %18
%19 = icmp eq i64 %16, 0
br i1 %19, label %11, label %20
20: ; preds = %15
%21 = tail call i64 @malloc(i32 81)
%22 = inttoptr i64 %21 to i8*
%23 = getelementptr inbounds i8*, i8** %2, i64 2
store i8* %22, i8** %23
%24 = icmp eq i64 %21, 0
br i1 %24, label %11, label %25
25: ; preds = %20
%26 = tail call i64 @malloc(i32 81)
%27 = inttoptr i64 %26 to i8*
%28 = getelementptr inbounds i8*, i8** %2, i64 3
store i8* %27, i8** %28
%29 = icmp eq i64 %26, 0
br i1 %29, label %11, label %30
30: ; preds = %25
%31 = tail call i64 @malloc(i32 81)
%32 = inttoptr i64 %31 to i8*
%33 = getelementptr inbounds i8*, i8** %2, i64 4
store i8* %32, i8** %33
%34 = icmp eq i64 %31, 0
br i1 %34, label %11, label %35
35: ; preds = %30
%36 = tail call i64 @malloc(i32 81)
%37 = inttoptr i64 %36 to i8*
%38 = getelementptr inbounds i8*, i8** %2, i64 5
store i8* %37, i8** %38
%39 = icmp eq i64 %36, 0
br i1 %39, label %11, label %40
40: ; preds = %35
%41 = tail call i64 @malloc(i32 81)
%42 = inttoptr i64 %41 to i8*
%43 = getelementptr inbounds i8*, i8** %2, i64 6
store i8* %42, i8** %43
%44 = icmp eq i64 %41, 0
br i1 %44, label %11, label %45
45: ; preds = %40
%46 = tail call i64 @malloc(i32 81)
%47 = inttoptr i64 %46 to i8*
%48 = getelementptr inbounds i8*, i8** %2, i64 7
store i8* %47, i8** %48
%49 = icmp eq i64 %46, 0
br i1 %49, label %11, label %50
50: ; preds = %45
%51 = tail call i64 @malloc(i32 81)
%52 = inttoptr i64 %51 to i8*
%53 = getelementptr inbounds i8*, i8** %2, i64 8
store i8* %52, i8** %53
%54 = icmp eq i64 %51, 0
br i1 %54, label %11, label %55
55: ; preds = %50
%56 = tail call i64 @malloc(i32 81)
%57 = inttoptr i64 %56 to i8*
%58 = getelementptr inbounds i8*, i8** %2, i64 9
store i8* %57, i8** %58
%59 = icmp eq i64 %56, 0
br i1 %59, label %11, label %60
60: ; preds = %55
ret i8** %2
}