#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 readmatrix(int **a, int n, FILE *f) {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      fscanf(f, "%d", &a[i][j]);
}


x86 assembly (clang, -O0):
<readmatrix>:
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 <readmatrix+0x81>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117e <readmatrix+0x6e>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x20(%rbp),%rax
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 <readmatrix+0x2d>
jmp    1183 <readmatrix+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <readmatrix+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1176 <readmatrix+0x66>
mov    %rdx,%r14
mov    %rdi,%r13
mov    %esi,%eax
mov    %rax,(%rsp)
lea    0x0(,%rax,4),%rbx
xor    %ebp,%ebp
lea    0xec4(%rip),%r15
nopl   0x0(%rax)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rdx
add    %r12,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fscanf@plt>
add    $0x4,%r12
cmp    %r12,%rbx
jne    1150 <readmatrix+0x40>
add    $0x1,%rbp
cmp    (%rsp),%rbp
jne    1140 <readmatrix+0x30>
add    $0x8,%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 @readmatrix(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 = sext i32 %21 to i64
%23 = getelementptr inbounds i32*, i32** %20, i64 %22
%24 = load i32*, i32** %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, 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 @readmatrix(i32** nocapture %0, i32 %1, i32* nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %17, %5
%8 = phi i64 [ 0, %5 ], [ %18, %17 ]
%9 = getelementptr inbounds i32*, i32** %0, i64 %8
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %15, %10 ]
%12 = load i32*, i32** %9
%13 = getelementptr inbounds i32, i32* %12, i64 %11
%14 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %17, label %10
17: ; preds = %10
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %17, %3
ret void
}