#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int valor, mult;
  int alcance = 0;
  printf("[[[Tabuada Inteligente]]]\nDigite um numero que sera a nossa base "
         "(BASE):\n");
  scanf("%d", &valor);
  printf("Agora digite ate qual numero esse numero seja multiplicado "
         "(ALCANCE):\n");
  scanf("%d", &mult);
  while (valor <= 0) {
    printf("Valor para BASE invalido, digite outro!\n");
    scanf("%d", &valor);
  }
  while (mult <= 0) {
    printf("Valor para ALCANCE invalido, digite outro!\n");
    scanf("%d", &mult);
  }
  while (alcance <= mult) {
    printf("%d x %d = %d\n", alcance, valor, alcance * valor);
    alcance++;
  }
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     11af <main+0x7f>
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1182 <main+0x52>
jmp    11b4 <main+0x84>
cmpl   $0x0,-0xc(%rbp)
jg     11e1 <main+0xb1>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    11b4 <main+0x84>
jmp    11e6 <main+0xb6>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     121b <main+0xeb>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
imul   -0x8(%rbp),%ecx
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e6 <main+0xb6>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jg     11ba <main+0x7a>
lea    0xf3b(%rip),%r14
lea    0xe69(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11a0 <main+0x60>
cmpl   $0x0,0x8(%rsp)
jg     11fa <main+0xba>
lea    0xed8(%rip),%r14
lea    0xe31(%rip),%r15
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11e0 <main+0xa0>
mov    $0xffffffff,%ebx
lea    0xdfd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    0xc(%rsp),%edx
mov    %edx,%ecx
imul   %ebx,%ecx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x8(%rsp),%ebx
jl     1210 <main+0xd0>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [74 x i8] c"[[[Tabuada Inteligente]]]\0ADigite um numero que sera a nossa base (BASE):\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [71 x i8] c"Agora digite ate qual numero esse numero seja multiplicado (ALCANCE):\0A\00"
@.str.3 = [41 x i8] c"Valor para BASE invalido, digite outro!\0A\00"
@.str.4 = [44 x i8] c"Valor para ALCANCE invalido, digite outro!\0A\00"
@.str.5 = [14 x i8] c"%d x %d = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
15: ; preds = %9
br label %16
16: ; preds = %19, %15
%17 = load i32, i32* %3
%18 = icmp sle i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %16
22: ; preds = %16
br label %23
23: ; preds = %27, %22
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* %4
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = load i32, i32* %2
%32 = mul nsw i32 %30, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %28, i32 %29, i32 %32)
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %23
36: ; preds = %23
%37 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [14 x i8] c"%d x %d = %d\0A\00"
@str = [73 x i8] c"[[[Tabuada Inteligente]]]\0ADigite um numero que sera a nossa base (BASE):\00"
@str.6 = [70 x i8] c"Agora digite ate qual numero esse numero seja multiplicado (ALCANCE):\00"
@str.7 = [43 x i8] c"Valor para ALCANCE invalido, digite outro!\00"
@str.8 = [40 x i8] c"Valor para BASE invalido, digite outro!\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 ([73 x i8], [73 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.6, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %14, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 1
br i1 %13, label %19, label %24
14: ; preds = %0, %14
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 1
br i1 %18, label %14, label %11
19: ; preds = %11, %19
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.7, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 1
br i1 %23, label %19, label %24
24: ; preds = %19, %11
br label %25
25: ; preds = %24, %25
%26 = phi i32 [ %30, %25 ], [ 0, %24 ]
%27 = load i32, i32* %1
%28 = mul nsw i32 %27, %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
%30 = add nuw nsw i32 %26, 1
%31 = load i32, i32* %2
%32 = icmp slt i32 %26, %31
br i1 %32, label %25, label %33
33: ; preds = %25
%34 = call i32 (...) @getch()
ret i32 0
}