#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
void *malloc(int);
int /*<<< orphan*/ processLine(char *, long *);
long ***initGrid(FILE *file) {
  long **grid = malloc(20 * sizeof(long *));
  long ***gridHead = &grid;
  for (int i = 0; i < 20; i++) {
    grid[i] = malloc(20 * sizeof(long));
  }
  char *line = malloc(64 * sizeof(char));
  for (int i = 0; fgets(line, 64, file); i++) {
    processLine(line, grid[i]);
  }
  return gridHead;
}


x86 assembly (clang, -O0):
<initGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    118a <initGrid+0x5a>
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <initGrid+0x29>
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x40,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11de <initGrid+0xae>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <processLine@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119f <initGrid+0x6f>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initGrid>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x18(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x20(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x28(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x30(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x38(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x40(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x48(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x50(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x58(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x60(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x68(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x70(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x78(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x80(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x88(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x90(%rbx)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,0x98(%rbx)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x40,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     12c4 <initGrid+0x194>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rsi
mov    %r15,%rdi
call   1050 <processLine@plt>
mov    %r15,%rdi
mov    $0x40,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    12a0 <initGrid+0x170>
lea    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64*** @initGrid(i32* %0) {
%2 = alloca i32*
%3 = alloca i64**
%4 = alloca i64***
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %2
%8 = call i8* @malloc(i32 160)
%9 = bitcast i8* %8 to i64**
store i64** %9, i64*** %3
store i64*** %3, i64**** %4
store i32 0, i32* %5
br label %10
10: ; preds = %20, %1
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 20
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = call i8* @malloc(i32 160)
%15 = bitcast i8* %14 to i64*
%16 = load i64**, i64*** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i64*, i64** %16, i64 %18
store i64* %15, i64** %19
br label %20
20: ; preds = %13
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %10
23: ; preds = %10
%24 = call i8* @malloc(i32 64)
store i8* %24, i8** %6
store i32 0, i32* %7
br label %25
25: ; preds = %38, %23
%26 = load i8*, i8** %6
%27 = load i32*, i32** %2
%28 = call i64 @fgets(i8* %26, i32 64, i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %25
%31 = load i8*, i8** %6
%32 = load i64**, i64*** %3
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i64*, i64** %32, i64 %34
%36 = load i64*, i64** %35
%37 = call i32 @processLine(i8* %31, i64* %36)
br label %38
38: ; preds = %30
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %25
41: ; preds = %25
%42 = load i64***, i64**** %4
ret i64*** %42
}

LLVM IR (-O2):
define noalias i64*** @initGrid(i32* nocapture %0) {
%2 = alloca i64**
%3 = bitcast i64*** %2 to i8*
%4 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%5 = bitcast i64*** %2 to i8**
store i8* %4, i8** %5
%6 = bitcast i8* %4 to i64**
%7 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%8 = bitcast i8* %4 to i8**
store i8* %7, i8** %8
%9 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%10 = getelementptr inbounds i64*, i64** %6, i64 1
%11 = bitcast i64** %10 to i8**
store i8* %9, i8** %11
%12 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%13 = getelementptr inbounds i64*, i64** %6, i64 2
%14 = bitcast i64** %13 to i8**
store i8* %12, i8** %14
%15 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%16 = getelementptr inbounds i64*, i64** %6, i64 3
%17 = bitcast i64** %16 to i8**
store i8* %15, i8** %17
%18 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%19 = getelementptr inbounds i64*, i64** %6, i64 4
%20 = bitcast i64** %19 to i8**
store i8* %18, i8** %20
%21 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%22 = getelementptr inbounds i64*, i64** %6, i64 5
%23 = bitcast i64** %22 to i8**
store i8* %21, i8** %23
%24 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%25 = getelementptr inbounds i64*, i64** %6, i64 6
%26 = bitcast i64** %25 to i8**
store i8* %24, i8** %26
%27 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%28 = getelementptr inbounds i64*, i64** %6, i64 7
%29 = bitcast i64** %28 to i8**
store i8* %27, i8** %29
%30 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%31 = getelementptr inbounds i64*, i64** %6, i64 8
%32 = bitcast i64** %31 to i8**
store i8* %30, i8** %32
%33 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%34 = getelementptr inbounds i64*, i64** %6, i64 9
%35 = bitcast i64** %34 to i8**
store i8* %33, i8** %35
%36 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%37 = getelementptr inbounds i64*, i64** %6, i64 10
%38 = bitcast i64** %37 to i8**
store i8* %36, i8** %38
%39 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%40 = getelementptr inbounds i64*, i64** %6, i64 11
%41 = bitcast i64** %40 to i8**
store i8* %39, i8** %41
%42 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%43 = getelementptr inbounds i64*, i64** %6, i64 12
%44 = bitcast i64** %43 to i8**
store i8* %42, i8** %44
%45 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%46 = getelementptr inbounds i64*, i64** %6, i64 13
%47 = bitcast i64** %46 to i8**
store i8* %45, i8** %47
%48 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%49 = getelementptr inbounds i64*, i64** %6, i64 14
%50 = bitcast i64** %49 to i8**
store i8* %48, i8** %50
%51 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%52 = getelementptr inbounds i64*, i64** %6, i64 15
%53 = bitcast i64** %52 to i8**
store i8* %51, i8** %53
%54 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%55 = getelementptr inbounds i64*, i64** %6, i64 16
%56 = bitcast i64** %55 to i8**
store i8* %54, i8** %56
%57 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%58 = getelementptr inbounds i64*, i64** %6, i64 17
%59 = bitcast i64** %58 to i8**
store i8* %57, i8** %59
%60 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%61 = getelementptr inbounds i64*, i64** %6, i64 18
%62 = bitcast i64** %61 to i8**
store i8* %60, i8** %62
%63 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%64 = getelementptr inbounds i64*, i64** %6, i64 19
%65 = bitcast i64** %64 to i8**
store i8* %63, i8** %65
%66 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%67 = tail call i64 @fgets(i8* %66, i32 64, i32* %0)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %70, %1
ret i64*** %2
70: ; preds = %1, %70
%71 = phi i64 [ %75, %70 ], [ 0, %1 ]
%72 = getelementptr inbounds i64*, i64** %6, i64 %71
%73 = load i64*, i64** %72
%74 = tail call i32 @processLine(i8* %66, i64* %73)
%75 = add nuw i64 %71, 1
%76 = tail call i64 @fgets(i8* %66, i32 64, i32* %0)
%77 = icmp eq i64 %76, 0
br i1 %77, label %69, label %70
}