#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 scanf(char *, ...);
int main() {
  int i = 0;
  int d = 0;
  do {
    printf("Please input num (1~9): ");
    d = scanf("%d", &i);
    scanf("%*[^\n]%*c");
  } while ((d != 1) || i < 1 || i > 9);
  int m, n;
  for (m = 1; m <= i; m++) {
    for (n = 1; n <= m; n++) {
      printf("%d*%d=%d%c", n, m, n * m, (n != m ? ',' : '\n'));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %eax,-0xc(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jne    1196 <main+0x76>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x15(%rbp)
jl     1196 <main+0x76>
cmpl   $0x9,-0x8(%rbp)
setg   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    113d <main+0x1d>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     121c <main+0xfc>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1209 <main+0xe9>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%r9d
mov    $0xa,%r8d
mov    $0x2c,%eax
cmp    %r9d,%edi
cmovne %eax,%r8d
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <main+0x9b>
jmp    120e <main+0xee>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a8 <main+0x88>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xec6(%rip),%r14
lea    0xed8(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xecf(%rip),%rbp
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x1,%ebx
jne    1150 <main+0x30>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1150 <main+0x30>
cmp    $0x9,%eax
jg     1150 <main+0x30>
mov    $0x1,%r12d
mov    $0xa,%r15d
lea    0xe8e(%rip),%r14
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    $0xffffffff,%ebx
mov    %r12d,%ebp
nopl   0x0(%rax,%rax,1)
lea    0x2(%rbx),%esi
lea    (%rbx,%r13,1),%eax
cmp    $0xffffffff,%eax
mov    $0x2c,%r8d
cmove  %r15d,%r8d
mov    %r14,%rdi
mov    %r12d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebx
add    %r12d,%ebp
mov    %r13d,%eax
add    %ebx,%eax
jne    11b0 <main+0x90>
lea    0x1(%r12),%eax
add    $0xffffffff,%r13d
cmp    0x4(%rsp),%r12d
mov    %eax,%r12d
jl     11a0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please input num (1~9): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"%*[^\0A]%*c\00"
@.str.3 = [11 x i8] c"%d*%d=%d%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %19, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 %8, i32* %3
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %6
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 1
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 9
br label %19
19: ; preds = %16, %13, %10
%20 = phi i1 [ true, %13 ], [ true, %10 ], [ %18, %16 ]
br i1 %20, label %6, label %21
21: ; preds = %19
store i32 1, i32* %4
br label %22
22: ; preds = %47, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %50
26: ; preds = %22
store i32 1, i32* %5
br label %27
27: ; preds = %43, %26
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %46
31: ; preds = %27
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = icmp ne i32 %37, %38
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 44, i32 10
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %33, i32 %36, i32 %41)
br label %43
43: ; preds = %31
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %27
46: ; preds = %27
br label %47
47: ; preds = %46
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %22
50: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Please input num (1~9): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"%*[^\0A]%*c\00"
@.str.3 = [11 x i8] c"%d*%d=%d%c\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp ne i32 %5, 1
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
%10 = select i1 %7, i1 true, i1 %9
%11 = icmp sgt i32 %8, 9
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %3, label %13
13: ; preds = %3, %24
%14 = phi i32 [ %28, %24 ], [ 2, %3 ]
%15 = phi i32 [ %25, %24 ], [ 1, %3 ]
br label %16
16: ; preds = %13, %16
%17 = phi i32 [ 1, %13 ], [ %22, %16 ]
%18 = mul nuw nsw i32 %17, %15
%19 = icmp eq i32 %17, %15
%20 = select i1 %19, i32 10, i32 44
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %15, i32 %18, i32 %20)
%22 = add nuw i32 %17, 1
%23 = icmp eq i32 %22, %14
br i1 %23, label %24, label %16
24: ; preds = %16
%25 = add nuw nsw i32 %15, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %15, %26
%28 = add nuw i32 %14, 1
br i1 %27, label %13, label %29
29: ; preds = %24
ret i32 0
}