#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 *);
void read_matrix(int **mat, int m, int n) {
  int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      printf("lendo posição |%d|%d|\t", i + 1, j + 1);
      scanf("%d", &mat[i][j]);
    }
  }
}


x86 assembly (clang, -O0):
<read_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b4 <read_matrix+0x94>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a1 <read_matrix+0x81>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
add    $0x1,%edx
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8b(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <read_matrix+0x2c>
jmp    11a6 <read_matrix+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <read_matrix+0x19>
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
mov    %edx,0x4(%rsp)
mov    %rdi,0x10(%rsp)
test   %esi,%esi
jle    11b2 <read_matrix+0x92>
mov    %esi,%eax
mov    %rax,0x8(%rsp)
mov    0x4(%rsp),%r15d
shl    $0x2,%r15
xor    %r14d,%r14d
lea    0xeab(%rip),%r13
jmp    116a <read_matrix+0x4a>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%r14
cmp    0x8(%rsp),%rbp
je     11b2 <read_matrix+0x92>
lea    0x1(%r14),%rbp
cmpl   $0x0,0x4(%rsp)
jle    1160 <read_matrix+0x40>
mov    $0x1,%ebx
xor    %r12d,%r12d
nopl   (%rax)
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    0x10(%rsp),%rax
mov    (%rax,%r14,8),%rsi
add    %r12,%rsi
lea    0xe7a(%rip),%rdi
call   1040 <scanf@plt>
add    $0x4,%r12
add    $0x1,%ebx
cmp    %r12,%r15
jne    1180 <read_matrix+0x60>
jmp    1160 <read_matrix+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"lendo posi\C3\A7\C3\A3o |%d|%d|\09\00"
@.str.1 = [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 = %37, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %40
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %33, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %22)
%24 = load i32**, i32*** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32*, i32** %24, i64 %26
%28 = load i32*, i32** %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %31)
br label %33
33: ; preds = %18
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %14
36: ; preds = %14
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %9
40: ; preds = %9
ret void
}

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