#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 */
struct termios {
  int *c_cc;
  scalar_t__ c_lflag;
};

/* Variables and functions */
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ b_red();
int /*<<< orphan*/ c_goto(int, int);
int /*<<< orphan*/ c_line0();
int /*<<< orphan*/ c_scrld(int);
int /*<<< orphan*/ c_scrlu(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ f_blue();
int /*<<< orphan*/ f_normal();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char, char, char, char, char, char, char);
int /*<<< orphan*/ read(int /*<<< orphan*/, char **, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ t_clear();
int t_getheight();
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int main() {
  struct termios term, bkp;
  if (tcgetattr(1, &term)) {
    perror("failed to get termios\n");
    exit(1);
  }
  bkp = term;
  term.c_lflag = 0;
  term.c_cc[VTIME] = 0;
  term.c_cc[VMIN] = 1;
  if (tcsetattr(1, TCSANOW, &term)) {
    perror("Failed to set termios\n");
    exit(1);
  }
  t_clear();
  f_normal();
  c_line0();
  char chs[7] = {0, 0, 0, 0, 0, 0, 0};
  int alive = 1;
  int interactive = 0;
  f_normal();
  b_red();
  fputs("hello", stdout);
  f_blue();
  fputs("world", stdout);
  f_normal();
  int h = t_getheight();
  int i;
  c_goto(0, 0);
  fputs("0", stdout);
  c_goto(1, 1);
  fputs("1", stdout);
  c_goto(2, 2);
  fputs("2", stdout);
  c_goto(h - 3, h - 3);
  fputs("-3", stdout);
  c_goto(h - 2, h - 2);
  fputs("-2", stdout);
  c_goto(h - 1, h - 1);
  fputs("-1", stdout);
  c_goto(h, h);
  fputs("-0", stdout);
  fflush(stdout);
  while (alive) {
    chs[0] = chs[1] = chs[2] = chs[3] = chs[4] = chs[5] = chs[6] = 0;
    read(0, &chs, 7);
    if (chs[0] == '!')
      break;
    if (chs[0] == '@') {
      c_scrlu(1);
      continue;
    }
    if (chs[0] == '#') {
      c_scrld(1);
      continue;
    }
    printf("%u %u %u %u %u %u %u\n", chs[0], chs[1], chs[2], chs[3], chs[4],
           chs[5], chs[6]);
  }
  if (tcsetattr(1, TCSANOW, &bkp)) {
    perror("failed to reset termios setting back to the backup\n");
    exit(1);
  }
  t_clear();
  c_line0();
  f_normal();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
lea    -0x18(%rbp),%rsi
call   10e0 <tcgetattr@plt>
cmp    $0x0,%rax
je     125d <main+0x3d>
lea    0xdb2(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2d48(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x2d4b(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    -0x18(%rbp),%rdx
call   10f0 <tcsetattr@plt>
cmp    $0x0,%rax
je     12d6 <main+0xb6>
lea    0xd50(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    $0x0,%al
call   10b0 <t_clear@plt>
mov    $0x0,%al
call   10d0 <f_normal@plt>
mov    $0x0,%al
call   10a0 <c_line0@plt>
lea    -0x2f(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1070 <memset@plt>
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    $0x0,%al
call   10d0 <f_normal@plt>
mov    $0x0,%al
call   1080 <b_red@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%esi
lea    0xd07(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x0,%al
call   1120 <f_blue@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
lea    0xcf1(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x0,%al
call   10d0 <f_normal@plt>
mov    $0x0,%al
call   1140 <t_getheight@plt>
mov    %eax,-0x3c(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1030 <c_goto@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%esi
lea    0xcd2(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <c_goto@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%esi
lea    0xcae(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x2,%esi
mov    %esi,%edi
call   1030 <c_goto@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%esi
lea    0xc8a(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x3c(%rbp),%edi
sub    $0x3,%edi
mov    -0x3c(%rbp),%esi
sub    $0x3,%esi
call   1030 <c_goto@plt>
mov    0x2bff(%rip),%rax
mov    (%rax),%esi
lea    0xc60(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x3c(%rbp),%edi
sub    $0x2,%edi
mov    -0x3c(%rbp),%esi
sub    $0x2,%esi
call   1030 <c_goto@plt>
mov    0x2bd9(%rip),%rax
mov    (%rax),%esi
lea    0xc3d(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x3c(%rbp),%edi
sub    $0x1,%edi
mov    -0x3c(%rbp),%esi
sub    $0x1,%esi
call   1030 <c_goto@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%esi
lea    0xc1a(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1030 <c_goto@plt>
mov    0x2b93(%rip),%rax
mov    (%rax),%esi
lea    0xbfd(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
cmpl   $0x0,-0x34(%rbp)
je     151f <main+0x2ff>
movb   $0x0,-0x29(%rbp)
movb   $0x0,-0x2a(%rbp)
movb   $0x0,-0x2b(%rbp)
movb   $0x0,-0x2c(%rbp)
movb   $0x0,-0x2d(%rbp)
movb   $0x0,-0x2e(%rbp)
movb   $0x0,-0x2f(%rbp)
lea    -0x2f(%rbp),%rsi
xor    %edi,%edi
mov    $0x7,%edx
call   1090 <read@plt>
movsbl -0x2f(%rbp),%eax
cmp    $0x21,%eax
jne    14a1 <main+0x281>
jmp    151f <main+0x2ff>
movsbl -0x2f(%rbp),%eax
cmp    $0x40,%eax
jne    14bd <main+0x29d>
mov    $0x1,%edi
call   1040 <c_scrlu@plt>
jmp    1459 <main+0x239>
movsbl -0x2f(%rbp),%eax
cmp    $0x23,%eax
jne    14d9 <main+0x2b9>
mov    $0x1,%edi
call   1110 <c_scrld@plt>
jmp    1459 <main+0x239>
mov    -0x2f(%rbp),%sil
mov    -0x2e(%rbp),%dl
mov    -0x2d(%rbp),%cl
mov    -0x2c(%rbp),%r8b
mov    -0x2b(%rbp),%r9b
mov    -0x2a(%rbp),%al
lea    0xb51(%rip),%rdi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl %r9b,%r9d
movsbl %al,%eax
mov    %eax,(%rsp)
movsbl -0x29(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1050 <printf@plt>
jmp    1459 <main+0x239>
mov    0x2ac2(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    -0x28(%rbp),%rdx
call   10f0 <tcsetattr@plt>
cmp    $0x0,%rax
je     1556 <main+0x336>
lea    0xb15(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    $0x0,%al
call   10b0 <t_clear@plt>
mov    $0x0,%al
call   10a0 <c_line0@plt>
mov    $0x0,%al
call   10d0 <f_normal@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0x10(%rsp),%rsi
mov    $0x1,%edi
call   10d0 <tcgetattr@plt>
test   %rax,%rax
jne    1486 <main+0x276>
movups 0x10(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2d76(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2d7d(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d74(%rip),%r15
mov    (%r15),%esi
lea    0x10(%rsp),%rdx
mov    $0x1,%edi
call   10e0 <tcsetattr@plt>
test   %rax,%rax
jne    148f <main+0x27f>
xor    %eax,%eax
call   10a0 <t_clear@plt>
xor    %eax,%eax
call   10c0 <f_normal@plt>
xor    %eax,%eax
call   1090 <c_line0@plt>
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
xor    %eax,%eax
call   10c0 <f_normal@plt>
xor    %eax,%eax
call   1070 <b_red@plt>
mov    0x2d07(%rip),%r14
mov    (%r14),%esi
lea    0xd5b(%rip),%rdi
call   1060 <fputs@plt>
xor    %eax,%eax
call   1110 <f_blue@plt>
mov    (%r14),%esi
lea    0xd4b(%rip),%rdi
call   1060 <fputs@plt>
xor    %eax,%eax
call   10c0 <f_normal@plt>
xor    %eax,%eax
call   1130 <t_getheight@plt>
mov    %eax,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xd33(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xd12(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x2,%edi
mov    $0x2,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xcf1(%rip),%rdi
call   1060 <fputs@plt>
lea    -0x3(%rbx),%edi
mov    %edi,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xcd4(%rip),%rdi
call   1060 <fputs@plt>
lea    -0x2(%rbx),%edi
mov    %edi,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xcbe(%rip),%rdi
call   1060 <fputs@plt>
lea    -0x1(%rbx),%edi
mov    %edi,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xca8(%rip),%rdi
call   1060 <fputs@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <c_goto@plt>
mov    (%r14),%esi
lea    0xc93(%rip),%rdi
call   1060 <fputs@plt>
mov    (%r14),%edi
call   10b0 <fflush@plt>
lea    0x8(%rsp),%r12
lea    0xc7d(%rip),%r14
jmp    13da <main+0x1ca>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1040 <c_scrlu@plt>
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
mov    $0x7,%edx
call   1080 <read@plt>
movzbl 0x8(%rsp),%eax
cmp    $0x23,%al
je     1440 <main+0x230>
cmp    $0x40,%al
je     13d0 <main+0x1c0>
cmp    $0x21,%al
je     144c <main+0x23c>
movsbl 0x9(%rsp),%edx
movsbl 0xa(%rsp),%ecx
movsbl 0xb(%rsp),%r8d
movsbl 0xc(%rsp),%r9d
movsbl 0xd(%rsp),%r10d
movsbl 0xe(%rsp),%ebx
movsbl %al,%esi
mov    %r14,%rdi
push   %rbx
push   %r10
call   1050 <printf@plt>
add    $0x10,%rsp
jmp    13da <main+0x1ca>
nop
mov    $0x1,%edi
call   1100 <c_scrld@plt>
jmp    13da <main+0x1ca>
mov    (%r15),%esi
lea    0x20(%rsp),%rdx
mov    $0x1,%edi
call   10e0 <tcsetattr@plt>
test   %rax,%rax
jne    1498 <main+0x288>
xor    %eax,%eax
call   10a0 <t_clear@plt>
xor    %eax,%eax
call   1090 <c_line0@plt>
xor    %eax,%eax
call   10c0 <f_normal@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xb73(%rip),%rdi
jmp    149f <main+0x28f>
lea    0xb81(%rip),%rdi
jmp    149f <main+0x28f>
lea    0xbbd(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.termios = type { i32*, i64 }
@.str = [23 x i8] c"failed to get termios\0A\00"
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@.str.1 = [23 x i8] c"Failed to set termios\0A\00"
@.str.2 = [6 x i8] c"hello\00"
@stdout = global i32 0
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [2 x i8] c"2\00"
@.str.7 = [3 x i8] c"-3\00"
@.str.8 = [3 x i8] c"-2\00"
@.str.9 = [3 x i8] c"-1\00"
@.str.10 = [3 x i8] c"-0\00"
@.str.11 = [22 x i8] c"%u %u %u %u %u %u %u\0A\00"
@.str.12 = [52 x i8] c"failed to reset termios setting back to the backup\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.termios
%3 = alloca %struct.termios
%4 = alloca [7 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i64 @tcgetattr(i32 1, %struct.termios* %2)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = bitcast %struct.termios* %3 to i8*
%16 = bitcast %struct.termios* %2 to i8*
%17 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 1
store i64 0, i64* %17
%18 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%19 = load i32*, i32** %18
%20 = load i64, i64* @VTIME
%21 = getelementptr inbounds i32, i32* %19, i64 %20
store i32 0, i32* %21
%22 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%23 = load i32*, i32** %22
%24 = load i64, i64* @VMIN
%25 = getelementptr inbounds i32, i32* %23, i64 %24
store i32 1, i32* %25
%26 = load i32, i32* @TCSANOW
%27 = call i64 @tcsetattr(i32 1, i32 %26, %struct.termios* %2)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %14
%30 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %14
%33 = call i32 (...) @t_clear()
%34 = call i32 (...) @f_normal()
%35 = call i32 (...) @c_line0()
%36 = bitcast [7 x i8]* %4 to i8*
store i32 1, i32* %5
store i32 0, i32* %6
%37 = call i32 (...) @f_normal()
%38 = call i32 (...) @b_red()
%39 = load i32, i32* @stdout
%40 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = call i32 (...) @f_blue()
%42 = load i32, i32* @stdout
%43 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = call i32 (...) @f_normal()
%45 = call i32 (...) @t_getheight()
store i32 %45, i32* %7
%46 = call i32 @c_goto(i32 0, i32 0)
%47 = load i32, i32* @stdout
%48 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = call i32 @c_goto(i32 1, i32 1)
%50 = load i32, i32* @stdout
%51 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = call i32 @c_goto(i32 2, i32 2)
%53 = load i32, i32* @stdout
%54 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %7
%56 = sub nsw i32 %55, 3
%57 = load i32, i32* %7
%58 = sub nsw i32 %57, 3
%59 = call i32 @c_goto(i32 %56, i32 %58)
%60 = load i32, i32* @stdout
%61 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %7
%63 = sub nsw i32 %62, 2
%64 = load i32, i32* %7
%65 = sub nsw i32 %64, 2
%66 = call i32 @c_goto(i32 %63, i32 %65)
%67 = load i32, i32* @stdout
%68 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %7
%70 = sub nsw i32 %69, 1
%71 = load i32, i32* %7
%72 = sub nsw i32 %71, 1
%73 = call i32 @c_goto(i32 %70, i32 %72)
%74 = load i32, i32* @stdout
%75 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %7
%77 = load i32, i32* %7
%78 = call i32 @c_goto(i32 %76, i32 %77)
%79 = load i32, i32* @stdout
%80 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %79)
%81 = load i32, i32* @stdout
%82 = call i32 @fflush(i32 %81)
br label %83
83: ; preds = %115, %113, %106, %32
%84 = load i32, i32* %5
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %131
86: ; preds = %83
%87 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 6
store i8 0, i8* %87
%88 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 5
store i8 0, i8* %88
%89 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 4
store i8 0, i8* %89
%90 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 3
store i8 0, i8* %90
%91 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 2
store i8 0, i8* %91
%92 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 1
store i8 0, i8* %92
%93 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
store i8 0, i8* %93
%94 = bitcast [7 x i8]* %4 to i8**
%95 = call i32 @read(i32 0, i8** %94, i32 7)
%96 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 33
br i1 %99, label %100, label %101
100: ; preds = %86
br label %131
101: ; preds = %86
%102 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp eq i32 %104, 64
br i1 %105, label %106, label %108
106: ; preds = %101
%107 = call i32 @c_scrlu(i32 1)
br label %83
108: ; preds = %101
%109 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp eq i32 %111, 35
br i1 %112, label %113, label %115
113: ; preds = %108
%114 = call i32 @c_scrld(i32 1)
br label %83
115: ; preds = %108
%116 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%117 = load i8, i8* %116
%118 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 1
%119 = load i8, i8* %118
%120 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 2
%121 = load i8, i8* %120
%122 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 3
%123 = load i8, i8* %122
%124 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 4
%125 = load i8, i8* %124
%126 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 5
%127 = load i8, i8* %126
%128 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 6
%129 = load i8, i8* %128
%130 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8 signext %117, i8 signext %119, i8 signext %121, i8 signext %123, i8 signext %125, i8 signext %127, i8 signext %129)
br label %83
131: ; preds = %100, %83
%132 = load i32, i32* @TCSANOW
%133 = call i64 @tcsetattr(i32 1, i32 %132, %struct.termios* %3)
%134 = icmp ne i64 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %131
%136 = call i32 @perror(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
%137 = call i32 @exit(i32 1)
unreachable
138: ; preds = %131
%139 = call i32 (...) @t_clear()
%140 = call i32 (...) @c_line0()
%141 = call i32 (...) @f_normal()
%142 = load i32, i32* %1
ret i32 %142
}

LLVM IR (-O2):
%struct.termios = type { i32*, i64 }
@.str = [23 x i8] c"failed to get termios\0A\00"
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@.str.1 = [23 x i8] c"Failed to set termios\0A\00"
@.str.2 = [6 x i8] c"hello\00"
@stdout = global i32 0
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [2 x i8] c"2\00"
@.str.7 = [3 x i8] c"-3\00"
@.str.8 = [3 x i8] c"-2\00"
@.str.9 = [3 x i8] c"-1\00"
@.str.10 = [3 x i8] c"-0\00"
@.str.11 = [22 x i8] c"%u %u %u %u %u %u %u\0A\00"
@.str.12 = [52 x i8] c"failed to reset termios setting back to the backup\0A\00"
define i32 @main() {
%1 = alloca %struct.termios
%2 = alloca %struct.termios
%3 = alloca [7 x i8]
%4 = bitcast %struct.termios* %1 to i8*
%5 = bitcast %struct.termios* %2 to i8*
%6 = call i64 @tcgetattr(i32 1, %struct.termios* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 1
store i64 0, i64* %12
%13 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%14 = load i32*, i32** %13
%15 = load i64, i64* @VTIME
%16 = getelementptr inbounds i32, i32* %14, i64 %15
store i32 0, i32* %16
%17 = load i64, i64* @VMIN
%18 = getelementptr inbounds i32, i32* %14, i64 %17
store i32 1, i32* %18
%19 = load i32, i32* @TCSANOW
%20 = call i64 @tcsetattr(i32 1, i32 %19, %struct.termios* %1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %11
%23 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %11
%26 = call i32 (...) @t_clear()
%27 = call i32 (...) @f_normal()
%28 = call i32 (...) @c_line0()
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%30 = call i32 (...) @f_normal()
%31 = call i32 (...) @b_red()
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = call i32 (...) @f_blue()
%35 = load i32, i32* @stdout
%36 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = call i32 (...) @f_normal()
%38 = call i32 (...) @t_getheight()
%39 = call i32 @c_goto(i32 0, i32 0)
%40 = load i32, i32* @stdout
%41 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = call i32 @c_goto(i32 1, i32 1)
%43 = load i32, i32* @stdout
%44 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = call i32 @c_goto(i32 2, i32 2)
%46 = load i32, i32* @stdout
%47 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%48 = add nsw i32 %38, -3
%49 = call i32 @c_goto(i32 %48, i32 %48)
%50 = load i32, i32* @stdout
%51 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %50)
%52 = add nsw i32 %38, -2
%53 = call i32 @c_goto(i32 %52, i32 %52)
%54 = load i32, i32* @stdout
%55 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %54)
%56 = add nsw i32 %38, -1
%57 = call i32 @c_goto(i32 %56, i32 %56)
%58 = load i32, i32* @stdout
%59 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %58)
%60 = call i32 @c_goto(i32 %38, i32 %38)
%61 = load i32, i32* @stdout
%62 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %61)
%63 = load i32, i32* @stdout
%64 = call i32 @fflush(i32 %63)
%65 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 6
%66 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
%67 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
%68 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%69 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%70 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%71 = bitcast [7 x i8]* %3 to i8**
br label %72
72: ; preds = %77, %25
%73 = call i32 @read(i32 0, i8** %71, i32 7)
%74 = load i8, i8* %29
switch i8 %74, label %80 [
i8 33, label %88
i8 64, label %75
i8 35, label %78
]
75: ; preds = %72
%76 = call i32 @c_scrlu(i32 1)
br label %77
77: ; preds = %75, %78, %80
br label %72
78: ; preds = %72
%79 = call i32 @c_scrld(i32 1)
br label %77
80: ; preds = %72
%81 = load i8, i8* %70
%82 = load i8, i8* %69
%83 = load i8, i8* %68
%84 = load i8, i8* %67
%85 = load i8, i8* %66
%86 = load i8, i8* %65
%87 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8 signext %74, i8 signext %81, i8 signext %82, i8 signext %83, i8 signext %84, i8 signext %85, i8 signext %86)
br label %77
88: ; preds = %72
%89 = load i32, i32* @TCSANOW
%90 = call i64 @tcsetattr(i32 1, i32 %89, %struct.termios* %2)
%91 = icmp eq i64 %90, 0
br i1 %91, label %95, label %92
92: ; preds = %88
%93 = call i32 @perror(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
%94 = call i32 @exit(i32 1)
unreachable
95: ; preds = %88
%96 = call i32 (...) @t_clear()
%97 = call i32 (...) @c_line0()
%98 = call i32 (...) @f_normal()
ret i32 0
}