#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 */
long num(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int l;
  printf("Enter number of lines: ");
  scanf("%d", &l);
  if (l < 1) {
    printf("Wrong input!");
    return 0;
  }
  printf("\n\n\n\n");
  int a, b, c;
  for (a = 0; a < l; a++) {
    for (b = 9 - a; b > 0; b--)
      printf("    ");
    for (c = 0; c <= a; c++) {
      long int r = num(a, c);
      if (r < 1) {
        printf("\n\n**** Memory Error! ****\n\n");
        return 0;
      } else if (r < 10)
        printf("    %d   ", r);
      else if (r < 100)
        printf("   %d   ", r);
      else if (r < 1000)
        printf("   %d  ", r);
      else if (r < 10000)
        printf("  %d  ", r);
      else if (r < 100000)
        printf("  %d ", r);
      else if (r < 1000000)
        printf(" %d ", r);
      else if (r < 10000000)
        printf(" %d", r);
      else if (r >= 10000000)
        printf("%d", r);
    }
    printf("\n\n\n");
  }
  printf("\n\n\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf10(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jge    1181 <main+0x51>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a3 <main+0x273>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    138e <main+0x25e>
mov    $0x9,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11d3 <main+0xa3>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11ad <main+0x7d>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1372 <main+0x242>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <num@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
jge    121a <main+0xea>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a3 <main+0x273>
cmpq   $0xa,-0x20(%rbp)
jge    123c <main+0x10c>
mov    -0x20(%rbp),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    135a <main+0x22a>
cmpq   $0x64,-0x20(%rbp)
jge    125e <main+0x12e>
mov    -0x20(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1355 <main+0x225>
cmpq   $0x3e8,-0x20(%rbp)
jge    1283 <main+0x153>
mov    -0x20(%rbp),%rsi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1350 <main+0x220>
cmpq   $0x2710,-0x20(%rbp)
jge    12a8 <main+0x178>
mov    -0x20(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    134b <main+0x21b>
cmpq   $0x186a0,-0x20(%rbp)
jge    12cd <main+0x19d>
mov    -0x20(%rbp),%rsi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1346 <main+0x216>
cmpq   $0xf4240,-0x20(%rbp)
jge    12f2 <main+0x1c2>
mov    -0x20(%rbp),%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1341 <main+0x211>
cmpq   $0x989680,-0x20(%rbp)
jge    1317 <main+0x1e7>
mov    -0x20(%rbp),%rsi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133c <main+0x20c>
cmpq   $0x989680,-0x20(%rbp)
jl     1337 <main+0x207>
mov    -0x20(%rbp),%rsi
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133c <main+0x20c>
jmp    1341 <main+0x211>
jmp    1346 <main+0x216>
jmp    134b <main+0x21b>
jmp    1350 <main+0x220>
jmp    1355 <main+0x225>
jmp    135a <main+0x22a>
jmp    135f <main+0x22f>
jmp    1364 <main+0x234>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11da <main+0xaa>
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x66>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee3(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    129a <main+0x15a>
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,(%rsp)
jle    1291 <main+0x151>
mov    $0x1,%r13d
movl   $0xa,0x4(%rsp)
lea    0xe88(%rip),%r12
lea    0xe86(%rip),%r14
lea    0xe80(%rip),%r15
xor    %ebp,%ebp
cmp    $0x8,%ebp
ja     11d2 <main+0x92>
mov    0x4(%rsp),%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     11c0 <main+0x80>
xor    %ebx,%ebx
jmp    11f2 <main+0xb2>
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
je     1270 <main+0x130>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <num@plt>
test   %rax,%rax
jle    12aa <main+0x16a>
mov    %r14,%rdi
cmp    $0xa,%rax
jb     11e0 <main+0xa0>
mov    %r15,%rdi
cmp    $0x64,%rax
jb     11e0 <main+0xa0>
lea    0xe17(%rip),%rdi
cmp    $0x3e8,%rax
jb     11e0 <main+0xa0>
lea    0xe09(%rip),%rdi
cmp    $0x2710,%rax
jb     11e0 <main+0xa0>
lea    0xe01(%rip),%rdi
cmp    $0x186a0,%rax
jb     11e0 <main+0xa0>
lea    0xdf3(%rip),%rdi
cmp    $0xf4240,%rax
jb     11e0 <main+0xa0>
cmp    $0x989680,%rax
lea    0xde4(%rip),%rdi
lea    0xddc(%rip),%rcx
cmovb  %rcx,%rdi
jmp    11e0 <main+0xa0>
nop
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%ebp
add    $0x1,%r13d
addl   $0xffffffff,0x4(%rsp)
cmp    (%rsp),%ebp
jl     11ad <main+0x6d>
lea    0xdae(%rip),%rdi
jmp    12b1 <main+0x171>
lea    0xd77(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12b6 <main+0x176>
lea    0xd99(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter number of lines: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Wrong input!\00"
@.str.3 = [5 x i8] c"\0A\0A\0A\0A\00"
@.str.4 = [5 x i8] c" \00"
@.str.5 = [28 x i8] c"\0A\0A**** Memory Error! ****\0A\0A\00"
@.str.6 = [10 x i8] c" %d \00"
@.str.7 = [9 x i8] c" %d \00"
@.str.8 = [8 x i8] c" %d \00"
@.str.9 = [7 x i8] c" %d \00"
@.str.10 = [6 x i8] c" %d \00"
@.str.11 = [5 x i8] c" %d \00"
@.str.12 = [4 x i8] c" %d\00"
@.str.13 = [4 x i8] c"\0A\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, 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* %2
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %110
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %15
15: ; preds = %105, %13
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %108
19: ; preds = %15
%20 = load i32, i32* %3
%21 = sub nsw i32 9, %20
store i32 %21, i32* %4
br label %22
22: ; preds = %27, %19
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = load i32, i32* %4
%29 = add nsw i32 %28, -1
store i32 %29, i32* %4
br label %22
30: ; preds = %22
store i32 0, i32* %5
br label %31
31: ; preds = %100, %30
%32 = load i32, i32* %5
%33 = load i32, i32* %3
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %103
35: ; preds = %31
%36 = load i32, i32* %3
%37 = load i32, i32* %5
%38 = call i64 @num(i32 %36, i32 %37)
store i64 %38, i64* %6
%39 = load i64, i64* %6
%40 = icmp slt i64 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %110
43: ; preds = %35
%44 = load i64, i64* %6
%45 = icmp slt i64 %44, 10
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i64, i64* %6
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %47)
br label %98
49: ; preds = %43
%50 = load i64, i64* %6
%51 = icmp slt i64 %50, 100
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i64, i64* %6
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i64 %53)
br label %97
55: ; preds = %49
%56 = load i64, i64* %6
%57 = icmp slt i64 %56, 1000
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i64, i64* %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i64 %59)
br label %96
61: ; preds = %55
%62 = load i64, i64* %6
%63 = icmp slt i64 %62, 10000
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i64, i64* %6
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i64 %65)
br label %95
67: ; preds = %61
%68 = load i64, i64* %6
%69 = icmp slt i64 %68, 100000
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load i64, i64* %6
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 %71)
br label %94
73: ; preds = %67
%74 = load i64, i64* %6
%75 = icmp slt i64 %74, 1000000
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = load i64, i64* %6
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i64 %77)
br label %93
79: ; preds = %73
%80 = load i64, i64* %6
%81 = icmp slt i64 %80, 10000000
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i64, i64* %6
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64 %83)
br label %92
85: ; preds = %79
%86 = load i64, i64* %6
%87 = icmp sge i64 %86, 10000000
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = load i64, i64* %6
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %89)
br label %91
91: ; preds = %88, %85
br label %92
92: ; preds = %91, %82
br label %93
93: ; preds = %92, %76
br label %94
94: ; preds = %93, %70
br label %95
95: ; preds = %94, %64
br label %96
96: ; preds = %95, %58
br label %97
97: ; preds = %96, %52
br label %98
98: ; preds = %97, %46
br label %99
99: ; preds = %98
br label %100
100: ; preds = %99
%101 = load i32, i32* %5
%102 = add nsw i32 %101, 1
store i32 %102, i32* %5
br label %31
103: ; preds = %31
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
br label %105
105: ; preds = %103
%106 = load i32, i32* %3
%107 = add nsw i32 %106, 1
store i32 %107, i32* %3
br label %15
108: ; preds = %15
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %110
110: ; preds = %108, %41, %11
%111 = load i32, i32* %1
ret i32 %111
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter number of lines: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Wrong input!\00"
@.str.4 = [5 x i8] c" \00"
@.str.6 = [10 x i8] c" %d \00"
@.str.7 = [9 x i8] c" %d \00"
@.str.8 = [8 x i8] c" %d \00"
@.str.9 = [7 x i8] c" %d \00"
@.str.10 = [6 x i8] c" %d \00"
@.str.11 = [5 x i8] c" %d \00"
@.str.12 = [4 x i8] c" %d\00"
@str.14 = [4 x i8] c"\0A\0A\0A\00"
@str.15 = [3 x i8] c"\0A\0A\00"
@str.16 = [27 x i8] c"\0A\0A**** Memory Error! ****\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %59
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.14, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %57
13: ; preds = %9, %51
%14 = phi i32 [ %56, %51 ], [ 1, %9 ]
%15 = phi i32 [ %53, %51 ], [ 0, %9 ]
%16 = icmp ult i32 %15, 9
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = sub nuw nsw i32 9, %15
br label %19
19: ; preds = %17, %19
%20 = phi i32 [ %22, %19 ], [ %18, %17 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = add nsw i32 %20, -1
%23 = icmp ugt i32 %20, 1
br i1 %23, label %19, label %24
24: ; preds = %19, %13
br label %25
25: ; preds = %24, %46
%26 = phi i32 [ %49, %46 ], [ 0, %24 ]
%27 = call i64 @num(i32 %15, i32 %26)
%28 = icmp slt i64 %27, 1
br i1 %28, label %44, label %29
29: ; preds = %25
%30 = icmp ult i64 %27, 10
br i1 %30, label %46, label %31
31: ; preds = %29
%32 = icmp ult i64 %27, 100
br i1 %32, label %46, label %33
33: ; preds = %31
%34 = icmp ult i64 %27, 1000
br i1 %34, label %46, label %35
35: ; preds = %33
%36 = icmp ult i64 %27, 10000
br i1 %36, label %46, label %37
37: ; preds = %35
%38 = icmp ult i64 %27, 100000
br i1 %38, label %46, label %39
39: ; preds = %37
%40 = icmp ult i64 %27, 1000000
br i1 %40, label %46, label %41
41: ; preds = %39
%42 = icmp ult i64 %27, 10000000
%43 = select i1 %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
br label %46
44: ; preds = %25
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.16, i64 0, i64 0))
br label %59
46: ; preds = %41, %39, %37, %35, %33, %31, %29
%47 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %29 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %31 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %33 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), %35 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), %37 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), %39 ], [ %43, %41 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %47, i64 %27)
%49 = add nuw nsw i32 %26, 1
%50 = icmp eq i32 %49, %14
br i1 %50, label %51, label %25
51: ; preds = %46
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.15, i64 0, i64 0))
%53 = add nuw nsw i32 %15, 1
%54 = load i32, i32* %1
%55 = icmp slt i32 %53, %54
%56 = add nuw i32 %14, 1
br i1 %55, label %13, label %57
57: ; preds = %51, %9
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.14, i64 0, i64 0))
br label %59
59: ; preds = %44, %57, %7
ret i32 0
}