#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 */
char getchar();
int /*<<< orphan*/ input_setcan();
int /*<<< orphan*/ input_setraw();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("\e7\e[?47h");
  printf("\e[%d;%dH", 0, 0);
  for (int i = 1; i < 10; i++) {
    printf("\e[%d;%dH", i * i, i);
    printf("+");
  }
  printf("\n");
  input_setraw();
  while (getchar() != 'q')
    ;
  input_setcan();
  printf("\e[2J\e[?47l\e8");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11b4 <main+0x74>
mov    -0x8(%rbp),%esi
imul   -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <main+0x36>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <input_setraw@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0x71,%eax
je     11e1 <main+0xa1>
jmp    11c9 <main+0x89>
mov    $0x0,%al
call   1030 <input_setcan@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea3(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x24,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x31,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x51,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2b,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <input_setraw@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x71,%al
jne    12a0 <main+0x150>
xor    %eax,%eax
call   1040 <input_setcan@plt>
lea    0xd59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"\1B7\1B[?47h\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [13 x i8] c"\1B[2J\1B[?47l\1B8\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0)
store i32 1, i32* %2
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* %2
%11 = mul nsw i32 %9, %10
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %8
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %5
18: ; preds = %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (...) @input_setraw()
br label %21
21: ; preds = %25, %18
%22 = call signext i8 (...) @getchar()
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 113
br i1 %24, label %25, label %26
25: ; preds = %21
br label %21
26: ; preds = %21
%27 = call i32 (...) @input_setcan()
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"\1B7\1B[?47h\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.4 = [13 x i8] c"\1B[2J\1B[?47l\1B8\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1)
%4 = tail call i32 @putchar(i32 43)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 2)
%6 = tail call i32 @putchar(i32 43)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 3)
%8 = tail call i32 @putchar(i32 43)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 16, i32 4)
%10 = tail call i32 @putchar(i32 43)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 25, i32 5)
%12 = tail call i32 @putchar(i32 43)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 36, i32 6)
%14 = tail call i32 @putchar(i32 43)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 49, i32 7)
%16 = tail call i32 @putchar(i32 43)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 64, i32 8)
%18 = tail call i32 @putchar(i32 43)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 81, i32 9)
%20 = tail call i32 @putchar(i32 43)
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 (...) @input_setraw()
br label %23
23: ; preds = %23, %0
%24 = tail call signext i8 (...) @getchar()
%25 = icmp eq i8 %24, 113
br i1 %25, label %26, label %23
26: ; preds = %23
%27 = tail call i32 (...) @input_setcan()
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}