#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*/ fscanf(int /*<<< orphan*/ *, char *, int *);
void Read_matrix(int mat[], int n, FILE *fp) {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      fscanf(fp, "%d", &mat[i * n + j]);
}


x86 assembly (clang, -O0):
<Read_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1191 <Read_matrix+0x81>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117e <Read_matrix+0x6e>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x1c(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe95(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <Read_matrix+0x2d>
jmp    1183 <Read_matrix+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <Read_matrix+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    118b <Read_matrix+0x7b>
mov    %rdx,%r12
mov    %rdi,%r14
mov    %esi,%r13d
lea    0x0(,%r13,4),%rax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
lea    0xebf(%rip),%r15
mov    %r13,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
jne    1160 <Read_matrix+0x50>
add    $0x1,%rbp
add    0x8(%rsp),%r14
mov    0x10(%rsp),%r13
cmp    %r13,%rbp
jne    1150 <Read_matrix+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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