#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 */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *, int *, int *,
           int *);
int /*<<< orphan*/ zeroTryte(int *);
void load(int **mem, char *filename) {
  int i;
  FILE *f;
  f = fopen(filename, "r");
  assert(f != NULL);
  for (i = 0; i < 729; i++) {
    if (6 != fscanf(f, "%d%d%d%d%d%d\n", &mem[i][0], &mem[i][1], &mem[i][2],
                    &mem[i][3], &mem[i][4], &mem[i][5])) {
      zeroTryte(mem[i]);
    }
  }
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2d9,-0x14(%rbp)
jge    1232 <load+0xf2>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
add    $0x4,%rcx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rsi
mov    (%rax,%rsi,8),%r8
add    $0x8,%r8
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rsi
mov    (%rax,%rsi,8),%r9
add    $0xc,%r9
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rsi
mov    (%rax,%rsi,8),%r10
add    $0x10,%r10
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rsi
mov    (%rax,%rsi,8),%rax
add    $0x14,%rax
lea    0xe11(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <fscanf@plt>
mov    %eax,%ecx
mov    $0x6,%eax
cmp    %ecx,%eax
je     121f <load+0xdf>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <zeroTryte@plt>
jmp    1224 <load+0xe4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <load+0x3d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r12
lea    0xeab(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
xor    %ebx,%ebx
lea    0xe8b(%rip),%r15
jmp    118d <load+0x4d>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x2d9,%rbx
je     11c7 <load+0x87>
mov    (%r12,%rbx,8),%rdx
lea    0x4(%rdx),%rcx
lea    0x8(%rdx),%r8
lea    0xc(%rdx),%r9
lea    0x10(%rdx),%r10
lea    0x14(%rdx),%rax
mov    %r14,%rdi
mov    %r15,%rsi
push   %rax
push   %r10
call   1040 <fscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
je     1180 <load+0x40>
mov    (%r12,%rbx,8),%rdi
call   1030 <zeroTryte@plt>
jmp    1180 <load+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"%d%d%d%d%d%d\0A\00"
define void @load(i32** %0, i8* %1) {
%3 = alloca i32**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
store i32** %0, i32*** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i32 0, i32* %5
br label %13
13: ; preds = %64, %2
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 729
br i1 %15, label %16, label %67
16: ; preds = %13
%17 = load i32*, i32** %6
%18 = load i32**, i32*** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32*, i32** %18, i64 %20
%22 = load i32*, i32** %21
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32**, i32*** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32*, i32** %24, i64 %26
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32**, i32*** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32*, i32** %30, i64 %32
%34 = load i32*, i32** %33
%35 = getelementptr inbounds i32, i32* %34, i64 2
%36 = load i32**, i32*** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 3
%42 = load i32**, i32*** %3
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32*, i32** %42, i64 %44
%46 = load i32*, i32** %45
%47 = getelementptr inbounds i32, i32* %46, i64 4
%48 = load i32**, i32*** %3
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32*, i32** %48, i64 %50
%52 = load i32*, i32** %51
%53 = getelementptr inbounds i32, i32* %52, i64 5
%54 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %23, i32* %29, i32* %35, i32* %41, i32* %47, i32* %53)
%55 = icmp ne i32 6, %54
br i1 %55, label %56, label %63
56: ; preds = %16
%57 = load i32**, i32*** %3
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32*, i32** %57, i64 %59
%61 = load i32*, i32** %60
%62 = call i32 @zeroTryte(i32* %61)
br label %63
63: ; preds = %56, %16
br label %64
64: ; preds = %63
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %13
67: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"%d%d%d%d%d%d\0A\00"
define void @load(i32** nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i32* %3, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
br label %7
7: ; preds = %2, %21
%8 = phi i64 [ 0, %2 ], [ %22, %21 ]
%9 = getelementptr inbounds i32*, i32** %0, i64 %8
%10 = load i32*, i32** %9
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = getelementptr inbounds i32, i32* %10, i64 2
%13 = getelementptr inbounds i32, i32* %10, i64 3
%14 = getelementptr inbounds i32, i32* %10, i64 4
%15 = getelementptr inbounds i32, i32* %10, i64 5
%16 = tail call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32* %15)
%17 = icmp eq i32 %16, 6
br i1 %17, label %21, label %18
18: ; preds = %7
%19 = load i32*, i32** %9
%20 = tail call i32 @zeroTryte(i32* %19)
br label %21
21: ; preds = %7, %18
%22 = add nuw nsw i64 %8, 1
%23 = icmp eq i64 %22, 729
br i1 %23, label %24, label %7
24: ; preds = %21
ret void
}