#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int **read(int *n) {
  FILE *f = fopen("date.in", "r");
  int **ingraph;
  if (f == NULL) {
    perror("msg:");
    exit(1);
  }
  int i, j;
  fscanf(f, "%d", n);
  ingraph = (int **)malloc(sizeof(int *) * (*n));
  for (i = 0; i < *n; i++) {
    ingraph[i] = (int *)malloc(sizeof(int) * (*n));
  }
  for (i = 0; i < *n; i++)
    for (j = 0; j < *n; j++)
      fscanf(f, "%d", &ingraph[i][j]);
  return ingraph;
}


x86 assembly (clang, -O0):
<read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1194 <read+0x44>
lea    0xe85(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe6c(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1203 <read+0xb3>
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c5 <read+0x75>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1277 <read+0x127>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1264 <read+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdbe(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1220 <read+0xd0>
jmp    1269 <read+0x119>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120a <read+0xba>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xe98(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     125a <read+0x10a>
lea    0xe8b(%rip),%rsi
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
mov    (%rbx),%edi
shl    $0x3,%edi
call   1040 <malloc@plt>
mov    %rax,(%rsp)
mov    %rbx,0x8(%rsp)
mov    (%rbx),%edi
test   %edi,%edi
jle    1247 <read+0xf7>
xor    %ebx,%ebx
mov    0x8(%rsp),%r14
mov    (%rsp),%rbp
nopl   0x0(%rax)
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
movslq (%r14),%rdi
cmp    %rdi,%rbx
jl     11c0 <read+0x70>
test   %edi,%edi
jle    1247 <read+0xf7>
xor    %r15d,%r15d
lea    0xe28(%rip),%r14
mov    0x8(%rsp),%r13
mov    (%rsp),%rbx
jmp    120c <read+0xbc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %edi,%rax
add    $0x1,%r15
cmp    %rax,%r15
jge    1247 <read+0xf7>
test   %edi,%edi
jle    1200 <read+0xb0>
xor    %ebp,%ebp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%r15,8),%rdx
add    %rbp,%rdx
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1030 <fscanf@plt>
add    $0x1,%r12
movslq 0x0(%r13),%rdi
add    $0x4,%rbp
cmp    %rdi,%r12
jl     1220 <read+0xd0>
jmp    1200 <read+0xb0>
mov    (%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda9(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"date.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"msg:\00"
@.str.3 = [3 x i8] c"%d\00"
define i32** @read(i32* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %0)
%9 = load i32, i32* %0
%10 = shl i32 %9, 3
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32**
%13 = load i32, i32* %0
%14 = icmp sgt i32 %13, 0
br i1 %14, label %17, label %48
15: ; preds = %17
%16 = icmp sgt i32 %25, 0
br i1 %16, label %28, label %48
17: ; preds = %7, %17
%18 = phi i64 [ %24, %17 ], [ 0, %7 ]
%19 = phi i32 [ %25, %17 ], [ %13, %7 ]
%20 = shl i32 %19, 2
%21 = tail call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
%23 = getelementptr inbounds i32*, i32** %12, i64 %18
store i32* %22, i32** %23
%24 = add nuw nsw i64 %18, 1
%25 = load i32, i32* %0
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %17, label %15
28: ; preds = %15, %43
%29 = phi i32 [ %44, %43 ], [ %25, %15 ]
%30 = phi i64 [ %46, %43 ], [ 0, %15 ]
%31 = icmp sgt i32 %29, 0
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = getelementptr inbounds i32*, i32** %12, i64 %30
br label %34
34: ; preds = %32, %34
%35 = phi i64 [ 0, %32 ], [ %39, %34 ]
%36 = load i32*, i32** %33
%37 = getelementptr inbounds i32, i32* %36, i64 %35
%38 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %37)
%39 = add nuw nsw i64 %35, 1
%40 = load i32, i32* %0
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %34, label %43
43: ; preds = %34, %28
%44 = phi i32 [ %29, %28 ], [ %40, %34 ]
%45 = sext i32 %44 to i64
%46 = add nuw nsw i64 %30, 1
%47 = icmp slt i64 %46, %45
br i1 %47, label %28, label %48
48: ; preds = %43, %7, %15
ret i32** %12
}