#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *);
int Lab1_loadinput(int *A, int *B, int *n) {
  FILE *ip;
  int i, j;
  if ((ip = fopen("data_input", "r")) == NULL) {
    printf("error opening the input data.\n");
    return 1;
  }
  fscanf(ip, "%d\n", n);
  for (i = 0; i < *n; i++)
    for (j = 0; j < *n; j++)
      fscanf(ip, "%d\t", A + *n * i + j);
  for (i = 0; i < *n; i++)
    for (j = 0; j < *n; j++)
      fscanf(ip, "%d\t", B + *n * i + j);
  fclose(ip);
  return 0;
}


x86 assembly (clang, -O0):
<Lab1_loadinput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xea5(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    118d <Lab1_loadinput+0x4d>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12af <Lab1_loadinput+0x16f>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe90(%rip),%rsi
call   1050 <fscanf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    1220 <Lab1_loadinput+0xe0>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    120d <Lab1_loadinput+0xcd>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
imul   -0x2c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe36(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11be <Lab1_loadinput+0x7e>
jmp    1212 <Lab1_loadinput+0xd2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a8 <Lab1_loadinput+0x68>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    129f <Lab1_loadinput+0x15f>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    128c <Lab1_loadinput+0x14c>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
imul   -0x2c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdb7(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    123d <Lab1_loadinput+0xfd>
jmp    1291 <Lab1_loadinput+0x151>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1227 <Lab1_loadinput+0xe7>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Lab1_loadinput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,0x8(%rsp)
mov    %rdi,0x10(%rsp)
lea    0xe9e(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e6 <Lab1_loadinput+0xa6>
mov    %rax,%r13
lea    0xe90(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1050 <fscanf@plt>
mov    (%r15),%eax
test   %eax,%eax
jle    1257 <Lab1_loadinput+0x117>
xor    %ebp,%ebp
lea    0xe75(%rip),%rbx
jmp    11a7 <Lab1_loadinput+0x67>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %eax,%ebp
jge    11f9 <Lab1_loadinput+0xb9>
test   %eax,%eax
jle    11a0 <Lab1_loadinput+0x60>
mov    0x10(%rsp),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
imul   %ebp,%eax
cltq
lea    (%r12,%rax,4),%rdx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <fscanf@plt>
add    $0x1,%r14
movslq (%r15),%rax
add    $0x4,%r12
cmp    %rax,%r14
jl     11c0 <Lab1_loadinput+0x80>
jmp    11a0 <Lab1_loadinput+0x60>
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1261 <Lab1_loadinput+0x121>
test   %eax,%eax
jle    1257 <Lab1_loadinput+0x117>
xor    %r14d,%r14d
lea    0xe0a(%rip),%r12
jmp    1219 <Lab1_loadinput+0xd9>
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    %eax,%r14d
jge    1257 <Lab1_loadinput+0x117>
test   %eax,%eax
jle    1210 <Lab1_loadinput+0xd0>
mov    0x8(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
imul   %r14d,%eax
cltq
lea    (%rbx,%rax,4),%rdx
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <fscanf@plt>
add    $0x1,%rbp
movslq (%r15),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1230 <Lab1_loadinput+0xf0>
jmp    1210 <Lab1_loadinput+0xd0>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"data_input\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [4 x i8] c"%d\09\00"
@str = [30 x i8] c"error opening the input data.\00"
define i32 @Lab1_loadinput(i32* %0, i32* %1, i32* %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %56
8: ; preds = %3
%9 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %54
12: ; preds = %8, %30
%13 = phi i32 [ %31, %30 ], [ %10, %8 ]
%14 = phi i32 [ %32, %30 ], [ 0, %8 ]
%15 = icmp sgt i32 %13, 0
br i1 %15, label %18, label %30
16: ; preds = %30
%17 = icmp sgt i32 %31, 0
br i1 %17, label %34, label %54
18: ; preds = %12, %18
%19 = phi i64 [ %26, %18 ], [ 0, %12 ]
%20 = phi i32 [ %27, %18 ], [ %13, %12 ]
%21 = mul nsw i32 %20, %14
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = getelementptr inbounds i32, i32* %23, i64 %19
%25 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %24)
%26 = add nuw nsw i64 %19, 1
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %18, label %30
30: ; preds = %18, %12
%31 = phi i32 [ %13, %12 ], [ %27, %18 ]
%32 = add nuw nsw i32 %14, 1
%33 = icmp slt i32 %32, %31
br i1 %33, label %12, label %16
34: ; preds = %16, %50
%35 = phi i32 [ %51, %50 ], [ %31, %16 ]
%36 = phi i32 [ %52, %50 ], [ 0, %16 ]
%37 = icmp sgt i32 %35, 0
br i1 %37, label %38, label %50
38: ; preds = %34, %38
%39 = phi i64 [ %46, %38 ], [ 0, %34 ]
%40 = phi i32 [ %47, %38 ], [ %35, %34 ]
%41 = mul nsw i32 %40, %36
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %1, i64 %42
%44 = getelementptr inbounds i32, i32* %43, i64 %39
%45 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %44)
%46 = add nuw nsw i64 %39, 1
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %38, label %50
50: ; preds = %38, %34
%51 = phi i32 [ %35, %34 ], [ %47, %38 ]
%52 = add nuw nsw i32 %36, 1
%53 = icmp slt i32 %52, %51
br i1 %53, label %34, label %54
54: ; preds = %50, %8, %16
%55 = tail call i32 @fclose(i32* %4)
br label %56
56: ; preds = %54, %6
%57 = phi i32 [ 1, %6 ], [ 0, %54 ]
ret i32 %57
}