#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, ...);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int lin, col, i, j, def, def2, opt;
  double val;
  FILE *f;
  srand(time(NULL));
  f = fopen("matriz1.txt", "w");
  if (f == NULL) {
    exit(0);
  }
  printf("# Gerador Randomico de Matrizes # \n\n");
  printf("Digite o numero de linhas da matriz: ");
  scanf("%d", &lin);
  printf("\n\nDigite o numero de colunas da matriz: ");
  scanf("%d", &col);
  fprintf(f, "%d %d\n", lin, col);
  printf("(1) Matriz Cheia\n");
  printf("(2) Matriz Esparsa\n\n");
  printf("Selecione uma opt: ");
  scanf("%d", &opt);
  switch (opt) {
  case 1:
    for (i = 0; i < lin; i++) {
      for (j = 0; j < col; j++) {
        val = rand() % 50;
        fprintf(f, "%d %d %f\n", i, j, val);
      }
    }
    break;
  case 2:
    for (i = 0; i < lin; i++) {
      for (j = 0; j < col; j++) {
        def = rand() % 1000;
        def2 = rand() % 1000 + rand() % 2;
        if (def > def2) {
          if ((i + j / 2) == 0) {
            val = rand() % 50;
            fprintf(f, "%d %d %f\n", i, j, val);
          }
        } else {
          if ((i + j / 2) != 0) {
            val = rand() % 50;
            fprintf(f, "%d %d %f\n", i, j, val);
          }
        }
      }
    }
    break;
  default:
    for (i = 0; i < lin; i++) {
      for (j = 0; j < col; j++) {
        val = rand() % 50;
        fprintf(f, "%d %d %f\n", i, j, val);
      }
    }
    break;
  }
  printf("\n\n@ matriz1.txt criada com sucesso\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe5a(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c8 <main+0x48>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
lea    0xe72(%rip),%rdi
mov    %rdi,-0x40(%rbp)
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe67(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x1,%eax
je     127b <main+0xfb>
jmp    126a <main+0xea>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     12fc <main+0x17c>
jmp    144c <main+0x2cc>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f7 <main+0x177>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12e4 <main+0x164>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
lea    0xdf8(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1295 <main+0x115>
jmp    12e9 <main+0x169>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1282 <main+0x102>
jmp    14cd <main+0x34d>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1447 <main+0x2c7>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1434 <main+0x2b4>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x44(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x44(%rbp),%edx
add    %eax,%edx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    13c6 <main+0x246>
mov    -0x10(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
cmp    $0x0,%eax
jne    13c1 <main+0x241>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
lea    0xd0d(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    1421 <main+0x2a1>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
cmp    $0x0,%eax
je     141c <main+0x29c>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
lea    0xcb2(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    1421 <main+0x2a1>
jmp    1426 <main+0x2a6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1316 <main+0x196>
jmp    1439 <main+0x2b9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1303 <main+0x183>
jmp    14cd <main+0x34d>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14c8 <main+0x348>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    14b5 <main+0x335>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
lea    0xc27(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1466 <main+0x2e6>
jmp    14ba <main+0x33a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1453 <main+0x2d3>
jmp    14cd <main+0x34d>
lea    0xbfd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe4d(%rip),%rdi
lea    0xe52(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     14b8 <main+0x328>
mov    %rax,%r15
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4a(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe41(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x1,%eax
je     138e <main+0x1fe>
cmp    $0x2,%eax
jne    141b <main+0x28b>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    149b <main+0x30b>
mov    0xc(%rsp),%ecx
lea    0xdf4(%rip),%r14
xor    %r12d,%r12d
jmp    12a1 <main+0x111>
nopl   0x0(%rax)
mov    0x10(%rsp),%eax
add    $0x1,%r12d
cmp    %eax,%r12d
jge    149b <main+0x30b>
test   %ecx,%ecx
jle    1294 <main+0x104>
xor    %r13d,%r13d
jmp    12f9 <main+0x169>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x1,%r13d
mov    0xc(%rsp),%ecx
cmp    %ecx,%r13d
jge    1290 <main+0x100>
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rbp
imul   $0x10624dd3,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ebp
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rbx
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   10b0 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
add    %ebx,%eax
mov    %r13d,%ecx
shr    %ecx
neg    %ecx
cmp    %eax,%ebp
jle    1380 <main+0x1f0>
cmp    %ecx,%r12d
je     12b0 <main+0x120>
jmp    12ec <main+0x15c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ecx,%r12d
jne    12b0 <main+0x120>
jmp    12ec <main+0x15c>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    149b <main+0x30b>
mov    0xc(%rsp),%ecx
lea    0xcd6(%rip),%r14
xor    %ebp,%ebp
jmp    13bb <main+0x22b>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %eax,%ebp
jge    149b <main+0x30b>
test   %ecx,%ecx
jle    13b0 <main+0x220>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebx
jl     13d0 <main+0x240>
mov    0x10(%rsp),%eax
jmp    13b0 <main+0x220>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    149b <main+0x30b>
mov    0xc(%rsp),%ecx
lea    0xc4d(%rip),%r14
xor    %ebp,%ebp
jmp    1447 <main+0x2b7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %eax,%ebp
jge    149b <main+0x30b>
test   %ecx,%ecx
jle    1440 <main+0x2b0>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebx
jl     1450 <main+0x2c0>
mov    0x10(%rsp),%eax
jmp    1440 <main+0x2b0>
lea    0xc2c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"matriz1.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [37 x i8] c"# Gerador Randomico de Matrizes # \0A\0A\00"
@.str.3 = [38 x i8] c"Digite o numero de linhas da matriz: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [41 x i8] c"\0A\0ADigite o numero de colunas da matriz: \00"
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [18 x i8] c"(1) Matriz Cheia\0A\00"
@.str.8 = [21 x i8] c"(2) Matriz Esparsa\0A\0A\00"
@.str.9 = [20 x i8] c"Selecione uma opt: \00"
@.str.10 = [10 x i8] c"%d %d %f\0A\00"
@.str.11 = [37 x i8] c"\0A\0A@ matriz1.txt criada com sucesso\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32*
store i32 0, i32* %1
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
%13 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %10
%14 = load i32*, i32** %10
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%22 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%24 = load i32*, i32** %10
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%32 = load i32, i32* %8
switch i32 %32, label %122 [
i32 1, label %33
i32 2, label %60
]
33: ; preds = %18
store i32 0, i32* %4
br label %34
34: ; preds = %56, %33
%35 = load i32, i32* %4
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %59
38: ; preds = %34
store i32 0, i32* %5
br label %39
39: ; preds = %52, %38
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 50
%46 = sitofp i32 %45 to double
store double %46, double* %9
%47 = load i32*, i32** %10
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = load double, double* %9
%51 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %48, i32 %49, double %50)
br label %52
52: ; preds = %43
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %39
55: ; preds = %39
br label %56
56: ; preds = %55
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %34
59: ; preds = %34
br label %149
60: ; preds = %18
store i32 0, i32* %4
br label %61
61: ; preds = %118, %60
%62 = load i32, i32* %4
%63 = load i32, i32* %2
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %121
65: ; preds = %61
store i32 0, i32* %5
br label %66
66: ; preds = %114, %65
%67 = load i32, i32* %5
%68 = load i32, i32* %3
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %117
70: ; preds = %66
%71 = call i32 (...) @rand()
%72 = srem i32 %71, 1000
store i32 %72, i32* %6
%73 = call i32 (...) @rand()
%74 = srem i32 %73, 1000
%75 = call i32 (...) @rand()
%76 = srem i32 %75, 2
%77 = add nsw i32 %74, %76
store i32 %77, i32* %7
%78 = load i32, i32* %6
%79 = load i32, i32* %7
%80 = icmp sgt i32 %78, %79
br i1 %80, label %81, label %97
81: ; preds = %70
%82 = load i32, i32* %4
%83 = load i32, i32* %5
%84 = sdiv i32 %83, 2
%85 = add nsw i32 %82, %84
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %96
87: ; preds = %81
%88 = call i32 (...) @rand()
%89 = srem i32 %88, 50
%90 = sitofp i32 %89 to double
store double %90, double* %9
%91 = load i32*, i32** %10
%92 = load i32, i32* %4
%93 = load i32, i32* %5
%94 = load double, double* %9
%95 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %92, i32 %93, double %94)
br label %96
96: ; preds = %87, %81
br label %113
97: ; preds = %70
%98 = load i32, i32* %4
%99 = load i32, i32* %5
%100 = sdiv i32 %99, 2
%101 = add nsw i32 %98, %100
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %112
103: ; preds = %97
%104 = call i32 (...) @rand()
%105 = srem i32 %104, 50
%106 = sitofp i32 %105 to double
store double %106, double* %9
%107 = load i32*, i32** %10
%108 = load i32, i32* %4
%109 = load i32, i32* %5
%110 = load double, double* %9
%111 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %107, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %108, i32 %109, double %110)
br label %112
112: ; preds = %103, %97
br label %113
113: ; preds = %112, %96
br label %114
114: ; preds = %113
%115 = load i32, i32* %5
%116 = add nsw i32 %115, 1
store i32 %116, i32* %5
br label %66
117: ; preds = %66
br label %118
118: ; preds = %117
%119 = load i32, i32* %4
%120 = add nsw i32 %119, 1
store i32 %120, i32* %4
br label %61
121: ; preds = %61
br label %149
122: ; preds = %18
store i32 0, i32* %4
br label %123
123: ; preds = %145, %122
%124 = load i32, i32* %4
%125 = load i32, i32* %2
%126 = icmp slt i32 %124, %125
br i1 %126, label %127, label %148
127: ; preds = %123
store i32 0, i32* %5
br label %128
128: ; preds = %141, %127
%129 = load i32, i32* %5
%130 = load i32, i32* %3
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %144
132: ; preds = %128
%133 = call i32 (...) @rand()
%134 = srem i32 %133, 50
%135 = sitofp i32 %134 to double
store double %135, double* %9
%136 = load i32*, i32** %10
%137 = load i32, i32* %4
%138 = load i32, i32* %5
%139 = load double, double* %9
%140 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %136, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %137, i32 %138, double %139)
br label %141
141: ; preds = %132
%142 = load i32, i32* %5
%143 = add nsw i32 %142, 1
store i32 %143, i32* %5
br label %128
144: ; preds = %128
br label %145
145: ; preds = %144
%146 = load i32, i32* %4
%147 = add nsw i32 %146, 1
store i32 %147, i32* %4
br label %123
148: ; preds = %123
br label %149
149: ; preds = %148, %121, %59
%150 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%151 = load i32, i32* %1
ret i32 %151
}

LLVM IR (-O2):
@.str = [12 x i8] c"matriz1.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [38 x i8] c"Digite o numero de linhas da matriz: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [41 x i8] c"\0A\0ADigite o numero de colunas da matriz: \00"
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.9 = [20 x i8] c"Selecione uma opt: \00"
@.str.10 = [10 x i8] c"%d %d %f\0A\00"
@str = [36 x i8] c"# Gerador Randomico de Matrizes # \0A\00"
@str.12 = [17 x i8] c"(1) Matriz Cheia\00"
@str.13 = [20 x i8] c"(2) Matriz Esparsa\0A\00"
@str.14 = [36 x i8] c"\0A\0A@ matriz1.txt criada com sucesso\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %19, i32 %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0))
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %3
switch i32 %26, label %37 [
i32 1, label %32
i32 2, label %27
]
27: ; preds = %13
%28 = load i32, i32* %1
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %120
30: ; preds = %27
%31 = load i32, i32* %2
br label %63
32: ; preds = %13
%33 = load i32, i32* %1
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %120
35: ; preds = %32
%36 = load i32, i32* %2
br label %42
37: ; preds = %13
%38 = load i32, i32* %1
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %120
40: ; preds = %37
%41 = load i32, i32* %2
br label %99
42: ; preds = %35, %58
%43 = phi i32 [ %59, %58 ], [ %33, %35 ]
%44 = phi i32 [ %60, %58 ], [ %36, %35 ]
%45 = phi i32 [ %61, %58 ], [ 0, %35 ]
%46 = icmp sgt i32 %44, 0
br i1 %46, label %47, label %58
47: ; preds = %42, %47
%48 = phi i32 [ %53, %47 ], [ 0, %42 ]
%49 = call i32 (...) @rand()
%50 = srem i32 %49, 50
%51 = sitofp i32 %50 to double
%52 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %45, i32 %48, double %51)
%53 = add nuw nsw i32 %48, 1
%54 = load i32, i32* %2
%55 = icmp slt i32 %53, %54
br i1 %55, label %47, label %56
56: ; preds = %47
%57 = load i32, i32* %1
br label %58
58: ; preds = %56, %42
%59 = phi i32 [ %57, %56 ], [ %43, %42 ]
%60 = phi i32 [ %54, %56 ], [ %44, %42 ]
%61 = add nuw nsw i32 %45, 1
%62 = icmp slt i32 %61, %59
br i1 %62, label %42, label %120
63: ; preds = %30, %94
%64 = phi i32 [ %95, %94 ], [ %28, %30 ]
%65 = phi i32 [ %96, %94 ], [ %31, %30 ]
%66 = phi i32 [ %97, %94 ], [ 0, %30 ]
%67 = icmp sgt i32 %65, 0
br i1 %67, label %68, label %94
68: ; preds = %63, %88
%69 = phi i32 [ %89, %88 ], [ 0, %63 ]
%70 = call i32 (...) @rand()
%71 = srem i32 %70, 1000
%72 = call i32 (...) @rand()
%73 = srem i32 %72, 1000
%74 = call i32 (...) @rand()
%75 = srem i32 %74, 2
%76 = add nsw i32 %75, %73
%77 = icmp sgt i32 %71, %76
%78 = lshr i32 %69, 1
%79 = sub nsw i32 0, %78
%80 = icmp eq i32 %66, %79
br i1 %77, label %81, label %82
81: ; preds = %68
br i1 %80, label %83, label %88
82: ; preds = %68
br i1 %80, label %88, label %83
83: ; preds = %82, %81
%84 = call i32 (...) @rand()
%85 = srem i32 %84, 50
%86 = sitofp i32 %85 to double
%87 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %66, i32 %69, double %86)
br label %88
88: ; preds = %83, %81, %82
%89 = add nuw nsw i32 %69, 1
%90 = load i32, i32* %2
%91 = icmp slt i32 %89, %90
br i1 %91, label %68, label %92
92: ; preds = %88
%93 = load i32, i32* %1
br label %94
94: ; preds = %92, %63
%95 = phi i32 [ %93, %92 ], [ %64, %63 ]
%96 = phi i32 [ %90, %92 ], [ %65, %63 ]
%97 = add nuw nsw i32 %66, 1
%98 = icmp slt i32 %97, %95
br i1 %98, label %63, label %120
99: ; preds = %40, %115
%100 = phi i32 [ %116, %115 ], [ %38, %40 ]
%101 = phi i32 [ %117, %115 ], [ %41, %40 ]
%102 = phi i32 [ %118, %115 ], [ 0, %40 ]
%103 = icmp sgt i32 %101, 0
br i1 %103, label %104, label %115
104: ; preds = %99, %104
%105 = phi i32 [ %110, %104 ], [ 0, %99 ]
%106 = call i32 (...) @rand()
%107 = srem i32 %106, 50
%108 = sitofp i32 %107 to double
%109 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %102, i32 %105, double %108)
%110 = add nuw nsw i32 %105, 1
%111 = load i32, i32* %2
%112 = icmp slt i32 %110, %111
br i1 %112, label %104, label %113
113: ; preds = %104
%114 = load i32, i32* %1
br label %115
115: ; preds = %113, %99
%116 = phi i32 [ %114, %113 ], [ %100, %99 ]
%117 = phi i32 [ %111, %113 ], [ %101, %99 ]
%118 = add nuw nsw i32 %102, 1
%119 = icmp slt i32 %118, %116
br i1 %119, label %99, label %120
120: ; preds = %94, %58, %115, %27, %32, %37
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.14, i64 0, i64 0))
ret i32 0
}