#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*/ arquiteto(int, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int m, n;
  int *ponteiro;
  printf("\nBem vindo ao programa TheMatrixCriatividade0!\nEste programa cria "
         "uma matriz de dimensoes definidas por voce e preenche ela com\n");
  printf("numeros aleatorios. Recomendo o maximo de 10x10 para melhor leitura "
         "e formatacao\nno terminal.\n");
  printf("Digite o numero de colunas:\t");
  scanf("%i", &m);
  while (m <= 0) {
    printf("Sua entrada eh invalida. Digite um valor estritamente maior que "
           "zero.\n");
    scanf("%i", &m);
  }
  printf("Digite o numero de linhas:\t");
  scanf("%i", &n);
  while (n <= 0) {
    printf("Sua entrada eh invalida. Digite um valor estritamente maior que "
           "zero.\n");
    scanf("%i", &n);
  }
  int matrix[m * n];
  ponteiro = &matrix[0];
  srand(time(NULL));
  arquiteto(m, n, ponteiro);
  printf("\n\nObrigado por usar o programa!\n\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
call   1030 <printf@plt>
lea    0xf62(%rip),%rdi
call   1030 <printf@plt>
lea    0xf73(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     11be <main+0x6e>
lea    0xf5c(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
jmp    1193 <main+0x43>
lea    0xf82(%rip),%rdi
call   1030 <printf@plt>
lea    0xf2c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jg     1205 <main+0xb5>
lea    0xf15(%rip),%rdi
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
jmp    11da <main+0x8a>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,%rsp
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1070 <arquiteto@plt>
lea    0xf09(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jg     11d9 <main+0x79>
lea    0xf90(%rip),%r14
lea    0xe6b(%rip),%r15
lea    -0x1c(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    11c0 <main+0x60>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
lea    0xe31(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%eax
test   %eax,%eax
jg     122a <main+0xca>
lea    0xf38(%rip),%r14
lea    0xe13(%rip),%r15
lea    -0x20(%rbp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%eax
test   %eax,%eax
jle    1210 <main+0xb0>
mov    %rsp,%r14
imul   -0x1c(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    %rbx,%rdx
call   1080 <arquiteto@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [129 x i8] c"\0ABem vindo ao programa TheMatrixCriatividade0!\0AEste programa cria uma matriz de dimensoes definidas por voce e preenche ela com\0A\00"
@.str.1 = [95 x i8] c"numeros aleatorios. Recomendo o maximo de 10x10 para melhor leitura e formatacao\0Ano terminal.\0A\00"
@.str.2 = [29 x i8] c"Digite o numero de colunas:\09\00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [71 x i8] c"Sua entrada eh invalida. Digite um valor estritamente maior que zero.\0A\00"
@.str.5 = [28 x i8] c"Digite o numero de linhas:\09\00"
@.str.6 = [34 x i8] c"\0A\0AObrigado por usar o programa!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
br label %11
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
br label %20
20: ; preds = %23, %17
%21 = load i32, i32* %3
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
br label %20
26: ; preds = %20
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = mul nsw i32 %27, %28
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %5
%32 = alloca i32, i64 %30
store i64 %30, i64* %6
%33 = getelementptr inbounds i32, i32* %32, i64 0
store i32* %33, i32** %4
%34 = call i32 @time(i32* null)
%35 = call i32 @srand(i32 %34)
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = load i32*, i32** %4
%39 = call i32 @arquiteto(i32 %36, i32 %37, i32* %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
%41 = load i8*, i8** %5
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str.2 = [29 x i8] c"Digite o numero de colunas:\09\00"
@.str.3 = [3 x i8] c"%i\00"
@.str.5 = [28 x i8] c"Digite o numero de linhas:\09\00"
@str = [128 x i8] c"\0ABem vindo ao programa TheMatrixCriatividade0!\0AEste programa cria uma matriz de dimensoes definidas por voce e preenche ela com\00"
@str.7 = [94 x i8] c"numeros aleatorios. Recomendo o maximo de 10x10 para melhor leitura e formatacao\0Ano terminal.\00"
@str.8 = [33 x i8] c"\0A\0AObrigado por usar o programa!\0A\00"
@str.10 = [70 x i8] c"Sua entrada eh invalida. Digite um valor estritamente maior que zero.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @str.7, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %0, %11
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.10, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 1
br i1 %15, label %11, label %16
16: ; preds = %11, %0
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %26
21: ; preds = %16, %21
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.10, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 1
br i1 %25, label %21, label %26
26: ; preds = %21, %16
%27 = phi i32 [ %19, %16 ], [ %24, %21 ]
%28 = load i32, i32* %1
%29 = mul nsw i32 %28, %27
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
%32 = alloca i32, i64 %30
%33 = call i32 @time(i32* null)
%34 = call i32 @srand(i32 %33)
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = call i32 @arquiteto(i32 %35, i32 %36, i32* %32)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}