#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *);
void init_instance(char *filename, int **instance, int cities) {
  FILE *file = fopen(filename, "r");
  int i;
  for (i = 0; i < cities; i++) {
    fscanf(file, "%d %d %d", &instance[i][0], &instance[i][1], &instance[i][2]);
  };
}


x86 assembly (clang, -O0):
<init_instance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a4 <init_instance+0x84>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
add    $0x4,%rcx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rsi
mov    (%rax,%rsi,8),%r8
add    $0x8,%r8
lea    0xe71(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114e <init_instance+0x2e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_instance>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
lea    0xecc(%rip),%rsi
call   1040 <fopen@plt>
test   %ebp,%ebp
jle    1170 <init_instance+0x50>
mov    %rax,%r12
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xeb7(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdx
lea    0x4(%rdx),%rcx
lea    0x8(%rdx),%r8
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <fscanf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <init_instance+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
define void @init_instance(i8* %0, i32** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %4
store i32** %1, i32*** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
store i32 0, i32* %8
br label %11
11: ; preds = %36, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32*, i32** %7
%17 = load i32**, i32*** %5
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32*, i32** %17, i64 %19
%21 = load i32*, i32** %20
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32**, i32*** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = load i32**, i32*** %5
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32*, i32** %29, i64 %31
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 2
%35 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %22, i32* %28, i32* %34)
br label %36
36: ; preds = %15
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %11
39: ; preds = %11
ret void
}

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