#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ scanf(char *, int *);
int **le_entrada(int n) {
  int i, j;
  int *vetor_alocado = (int *)malloc(sizeof(int) * n * n);
  int **vetor = (int **)malloc(sizeof(int *) * n);
  for (i = 0; i < n; i++) {
    vetor[i] = vetor_alocado + i * n;
    for (j = 0; j < n; j++)
      scanf("%d", &vetor[i][j]);
  }
  return vetor;
}


x86 assembly (clang, -O0):
<le_entrada>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
movslq -0x4(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e3 <le_entrada+0xc3>
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d0 <le_entrada+0xb0>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe43(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1193 <le_entrada+0x73>
jmp    11d5 <le_entrada+0xb5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1160 <le_entrada+0x40>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<le_entrada>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
imul   %edi,%edi
shl    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,0x10(%rsp)
lea    0x0(,%rbp,8),%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,(%rsp)
test   %ebp,%ebp
jle    11cb <le_entrada+0xab>
mov    (%rsp),%r13d
lea    -0x1(%r13),%rax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
lea    0xe93(%rip),%r12
jmp    1179 <le_entrada+0x59>
nop
add    $0x1,%rbp
cmp    %r13,%rbp
je     11cb <le_entrada+0xab>
mov    %rbp,%rax
imul   %r13,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,4),%rsi
mov    %rsi,(%rbx,%rbp,8)
mov    %r12,%rdi
call   1040 <scanf@plt>
cmpl   $0x1,(%rsp)
je     1170 <le_entrada+0x50>
mov    $0x4,%r14d
mov    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rsi
add    %r14,%rsi
mov    %r12,%rdi
call   1040 <scanf@plt>
add    $0x4,%r14
add    $0xffffffffffffffff,%r15
jne    11b0 <le_entrada+0x90>
jmp    1170 <le_entrada+0x50>
mov    %rbx,%rax
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 i32** @le_entrada(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32**
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 4, %8
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = mul i64 %9, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %5
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = mul i64 8, %17
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i32**
store i32** %21, i32*** %6
store i32 0, i32* %3
br label %22
22: ; preds = %55, %1
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %58
26: ; preds = %22
%27 = load i32*, i32** %5
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = mul nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
%33 = load i32**, i32*** %6
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32*, i32** %33, i64 %35
store i32* %32, i32** %36
store i32 0, i32* %4
br label %37
37: ; preds = %51, %26
%38 = load i32, i32* %4
%39 = load i32, i32* %2
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %54
41: ; preds = %37
%42 = load i32**, i32*** %6
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32*, i32** %42, i64 %44
%46 = load i32*, i32** %45
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %49)
br label %51
51: ; preds = %41
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %37
54: ; preds = %37
br label %55
55: ; preds = %54
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %22
58: ; preds = %22
%59 = load i32**, i32*** %6
ret i32** %59
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32** @le_entrada(i32 %0) {
%2 = shl i32 %0, 2
%3 = mul i32 %2, %0
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i32*
%6 = shl i32 %0, 3
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32**
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %30
10: ; preds = %1
%11 = zext i32 %0 to i64
%12 = zext i32 %0 to i64
%13 = icmp eq i32 %0, 1
br label %14
14: ; preds = %27, %10
%15 = phi i64 [ 0, %10 ], [ %28, %27 ]
%16 = mul nsw i64 %15, %11
%17 = getelementptr inbounds i32, i32* %5, i64 %16
%18 = getelementptr inbounds i32*, i32** %8, i64 %15
store i32* %17, i32** %18
%19 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
br i1 %13, label %27, label %20
20: ; preds = %14, %20
%21 = phi i64 [ %25, %20 ], [ 1, %14 ]
%22 = load i32*, i32** %18
%23 = getelementptr inbounds i32, i32* %22, i64 %21
%24 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %20
27: ; preds = %20, %14
%28 = add nuw nsw i64 %15, 1
%29 = icmp eq i64 %28, %12
br i1 %29, label %30, label %14
30: ; preds = %27, %1
ret i32** %8
}