#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 */
struct MatrixNode {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ insert(struct MatrixNode **, struct MatrixNode **, int, int,
                          int);
int /*<<< orphan*/ printf(char *);
void read(FILE *fin, struct MatrixNode **name_col, struct MatrixNode **name_row,
          int *c, int *r) {
  fgetc(fin);
  fscanf(fin, "%d%d", c, r);
  int i, j;
  for (i = 0; i < *c; ++i) {
    for (j = 0; j < *r; ++j) {
      int num;
      printf("hiii\n");
      fscanf(fin, "%d", &num);
      printf("hihi");
      insert(name_col, name_row, i, j, num);
    }
  }
}


x86 assembly (clang, -O0):
<read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    1211 <read+0xd1>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    11fe <read+0xbe>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe40(%rip),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
call   1060 <insert@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    119c <read+0x5c>
jmp    1203 <read+0xc3>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1186 <read+0x46>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rcx,%rbp
mov    %rdx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%r12
call   1060 <fgetc@plt>
lea    0xe83(%rip),%rsi
mov    %r12,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %rbp,0x8(%rsp)
mov    0x0(%rbp),%ecx
test   %ecx,%ecx
jle    124b <read+0xfb>
mov    %r14,%rdx
mov    (%r14),%eax
lea    0xe60(%rip),%r15
lea    0xe51(%rip),%rbp
lea    0x4(%rsp),%rbx
lea    0xe48(%rip),%r13
xor    %esi,%esi
mov    %r12,0x10(%rsp)
jmp    11d7 <read+0x87>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%esi
cmp    %ecx,%esi
jge    124b <read+0xfb>
test   %eax,%eax
jle    11d0 <read+0x80>
xor    %r14d,%r14d
mov    %esi,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rdx,%r12
call   1030 <puts@plt>
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%r8d
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    (%rsp),%edx
mov    %r14d,%ecx
call   1070 <insert@plt>
mov    %r12,%rdx
add    $0x1,%r14d
mov    (%r12),%eax
cmp    %eax,%r14d
jl     11f0 <read+0xa0>
mov    0x8(%rsp),%rcx
mov    (%rcx),%ecx
mov    (%rsp),%esi
jmp    11d0 <read+0x80>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.MatrixNode = type { i32 }
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [6 x i8] c"hiii\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"hihi\00"
define void @read(i32* %0, %struct.MatrixNode** %1, %struct.MatrixNode** %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca %struct.MatrixNode**
%8 = alloca %struct.MatrixNode**
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store %struct.MatrixNode** %1, %struct.MatrixNode*** %7
store %struct.MatrixNode** %2, %struct.MatrixNode*** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%14 = load i32*, i32** %6
%15 = call i32 @fgetc(i32* %14)
%16 = load i32*, i32** %6
%17 = load i32*, i32** %9
%18 = load i32*, i32** %10
%19 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %17, i32* %18)
store i32 0, i32* %11
br label %20
20: ; preds = %46, %5
%21 = load i32, i32* %11
%22 = load i32*, i32** %9
%23 = load i32, i32* %22
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %49
25: ; preds = %20
store i32 0, i32* %12
br label %26
26: ; preds = %42, %25
%27 = load i32, i32* %12
%28 = load i32*, i32** %10
%29 = load i32, i32* %28
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %45
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32*, i32** %6
%34 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %13)
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%36 = load %struct.MatrixNode**, %struct.MatrixNode*** %7
%37 = load %struct.MatrixNode**, %struct.MatrixNode*** %8
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = load i32, i32* %13
%41 = call i32 @insert(%struct.MatrixNode** %36, %struct.MatrixNode** %37, i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %31
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1
store i32 %44, i32* %12
br label %26
45: ; preds = %26
br label %46
46: ; preds = %45
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %20
49: ; preds = %20
ret void
}

LLVM IR (-O2):
%struct.MatrixNode = type { i32 }
@.str = [5 x i8] c"%d%d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"hihi\00"
@str = [5 x i8] c"hiii\00"
define void @read(i32* nocapture %0, %struct.MatrixNode** %1, %struct.MatrixNode** %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = tail call i32 @fgetc(i32* %0)
%8 = tail call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %5
%12 = bitcast i32* %6 to i8*
%13 = load i32, i32* %4
br label %14
14: ; preds = %11, %31
%15 = phi i32 [ %9, %11 ], [ %32, %31 ]
%16 = phi i32 [ %13, %11 ], [ %33, %31 ]
%17 = phi i32 [ 0, %11 ], [ %34, %31 ]
%18 = icmp sgt i32 %16, 0
br i1 %18, label %19, label %31
19: ; preds = %14, %19
%20 = phi i32 [ %26, %19 ], [ 0, %14 ]
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%22 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* %6
%25 = call i32 @insert(%struct.MatrixNode** %1, %struct.MatrixNode** %2, i32 %17, i32 %20, i32 %24)
%26 = add nuw nsw i32 %20, 1
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %19, label %29
29: ; preds = %19
%30 = load i32, i32* %3
br label %31
31: ; preds = %29, %14
%32 = phi i32 [ %30, %29 ], [ %15, %14 ]
%33 = phi i32 [ %27, %29 ], [ %16, %14 ]
%34 = add nuw nsw i32 %17, 1
%35 = icmp slt i32 %34, %32
br i1 %35, label %14, label %36
36: ; preds = %31, %5
ret void
}