#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int **readmat(int **adj_mat, int sizegr) {
  int i, j;
  for (i = 0; i < sizegr; i++) {
    for (j = 0; j < sizegr; j++) {
      printf("\nadj_mat[%d][%d]=", i, j);
      scanf("%d", *(adj_mat + i) + j);
    }
  }
  return adj_mat;
}


x86 assembly (clang, -O0):
<readmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ab <readmat+0x8b>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1198 <readmat+0x78>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8d(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <readmat+0x29>
jmp    119d <readmat+0x7d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <readmat+0x16>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %esi,%esi
jle    1195 <readmat+0x75>
mov    %esi,%eax
mov    %rax,(%rsp)
lea    0x0(,%rax,4),%r13
xor    %ebx,%ebx
lea    0xeb7(%rip),%r12
nopl   0x0(%rax)
xor    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    (%r14,%rbx,8),%rsi
add    %r15,%rsi
lea    0xe98(%rip),%rdi
call   1040 <scanf@plt>
add    $0x1,%ebp
add    $0x4,%r15
cmp    %r15,%r13
jne    1160 <readmat+0x40>
add    $0x1,%rbx
cmp    (%rsp),%rbx
jne    1150 <readmat+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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