#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 /*<<< 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++) {
      if (j == 0) {
        printf("insira o dia da data %d \n", i + 1);
      }
      if (j == 1) {
        printf("insira o mes da data %d \n", i + 1);
      }
      if (j == 2) {
        printf("insira o ano da data %d\n", i + 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    11f0 <read_matrix+0xd0>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11dd <read_matrix+0xbd>
cmpl   $0x0,-0x18(%rbp)
jne    1174 <read_matrix+0x54>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1190 <read_matrix+0x70>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x18(%rbp)
jne    11ac <read_matrix+0x8c>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe8d(%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    0xe83(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <read_matrix+0x2c>
jmp    11e2 <read_matrix+0xc2>
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,0xc(%rsp)
test   %esi,%esi
jle    11d9 <read_matrix+0xb9>
mov    %rdi,%rbx
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%r15d
shl    $0x2,%r15
xor    %r14d,%r14d
jmp    116a <read_matrix+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%r14
cmp    0x10(%rsp),%r12
je     11d9 <read_matrix+0xb9>
lea    0x1(%r14),%r12
cmpl   $0x0,0xc(%rsp)
jle    1160 <read_matrix+0x40>
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    11af <read_matrix+0x8f>
nopl   0x0(%rax)
lea    0xe93(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
mov    (%rbx,%r14,8),%rsi
add    %rbp,%rsi
lea    0xeb0(%rip),%rdi
call   1040 <scanf@plt>
add    $0x4,%rbp
add    $0x1,%r13d
cmp    %rbp,%r15
je     1160 <read_matrix+0x40>
cmp    $0x2,%r13d
je     11d0 <read_matrix+0xb0>
cmp    $0x1,%r13d
je     1180 <read_matrix+0x60>
test   %r13d,%r13d
jne    118f <read_matrix+0x6f>
lea    0xe39(%rip),%rdi
jmp    1187 <read_matrix+0x67>
nopl   0x0(%rax)
lea    0xe5d(%rip),%rdi
jmp    1187 <read_matrix+0x67>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"insira o dia da data %d \0A\00"
@.str.1 = [26 x i8] c"insira o mes da data %d \0A\00"
@.str.2 = [25 x i8] c"insira o ano da data %d\0A\00"
@.str.3 = [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 = %53, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %56
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %49, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %52
18: ; preds = %14
%19 = load i32, i32* %8
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
%24 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %21, %18
%26 = load i32, i32* %8
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
%31 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %25
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %35, %32
%40 = load i32**, i32*** %4
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32*, i32** %40, i64 %42
%44 = load i32*, i32** %43
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %47)
br label %49
49: ; preds = %39
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %14
52: ; preds = %14
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %9
56: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"insira o dia da data %d \0A\00"
@.str.1 = [26 x i8] c"insira o mes da data %d \0A\00"
@.str.2 = [25 x i8] c"insira o ano da data %d\0A\00"
@.str.3 = [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 %34
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, %32
%10 = phi i64 [ 0, %5 ], [ %11, %32 ]
%11 = add nuw nsw i64 %10, 1
br i1 %6, label %12, label %32
12: ; preds = %9
%13 = getelementptr inbounds i32*, i32** %0, i64 %10
%14 = trunc i64 %11 to i32
%15 = trunc i64 %11 to i32
%16 = trunc i64 %11 to i32
br label %17
17: ; preds = %12, %26
%18 = phi i64 [ 0, %12 ], [ %30, %26 ]
%19 = trunc i64 %18 to i32
switch i32 %19, label %26 [
i32 0, label %20
i32 1, label %22
i32 2, label %24
]
20: ; preds = %17
%21 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %26
22: ; preds = %17
%23 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %26
24: ; preds = %17
%25 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %26
26: ; preds = %22, %20, %17, %24
%27 = load i32*, i32** %13
%28 = getelementptr inbounds i32, i32* %27, i64 %18
%29 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %28)
%30 = add nuw nsw i64 %18, 1
%31 = icmp eq i64 %30, %8
br i1 %31, label %32, label %17
32: ; preds = %26, %9
%33 = icmp eq i64 %11, %7
br i1 %33, label %34, label %9
34: ; preds = %32, %3
ret void
}