#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*/ STDIN_FILENO;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setecho(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int init_terminal_noncurses(int col, int bgcol, int w, int h) {
  int n, i;
  col += 30;
  bgcol += 40;
  system("setterm -cursor off");
  system("setterm -blank 0");
  printf("\033[0m\n");
  system("clear");
  printf("\033[%dm", col);
  printf("\033[1m");
  if (bgcol != 0)
    printf("\033[%dm", bgcol);
  {
    for (n = (h); n >= 0; n--) {
      for (i = 0; i < w; i++) {
        printf(" ");
      }
      printf("\n");
    }
    printf("\033[%dA", h);
  }
  setecho(STDIN_FILENO, 0);
  return 0;
}


x86 assembly (clang, -O0):
<init_terminal_noncurses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1e,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x28,%eax
mov    %eax,-0x8(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <system@plt>
lea    0xeab(%rip),%rdi
call   1040 <system@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11c2 <init_terminal_noncurses+0x92>
mov    -0x8(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     121d <init_terminal_noncurses+0xed>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1201 <init_terminal_noncurses+0xd1>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d9 <init_terminal_noncurses+0xa9>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11c8 <init_terminal_noncurses+0x98>
mov    -0x10(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <setecho@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_terminal_noncurses>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%ebx
lea    0x1e(%rdi),%r15d
lea    0xe95(%rip),%rdi
call   1060 <system@plt>
lea    0xe9d(%rip),%rdi
call   1060 <system@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe96(%rip),%rdi
call   1060 <system@plt>
lea    0xe90(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x28,%ebx
je     11c8 <init_terminal_noncurses+0x78>
lea    0xe6c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r14d,%r14d
js     1211 <init_terminal_noncurses+0xc1>
mov    %r14d,%ebx
jmp    11f3 <init_terminal_noncurses+0xa3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%rbx),%eax
test   %ebx,%ebx
mov    %eax,%ebx
jle    1211 <init_terminal_noncurses+0xc1>
test   %r12d,%r12d
jle    11e0 <init_terminal_noncurses+0x90>
mov    %r12d,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1200 <init_terminal_noncurses+0xb0>
jmp    11e0 <init_terminal_noncurses+0x90>
lea    0xe1e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setecho@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"setterm -cursor off\00"
@.str.1 = [17 x i8] c"setterm -blank 0\00"
@.str.2 = [6 x i8] c"\1B[0m\0A\00"
@.str.3 = [6 x i8] c"clear\00"
@.str.4 = [6 x i8] c"\1B[%dm\00"
@.str.5 = [5 x i8] c"\1B[1m\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [6 x i8] c"\1B[%dA\00"
@STDIN_FILENO = global i32 0
define i32 @init_terminal_noncurses(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %5
%12 = add nsw i32 %11, 30
store i32 %12, i32* %5
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 40
store i32 %14, i32* %6
%15 = call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %4
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %4
%28 = load i32, i32* %8
store i32 %28, i32* %9
br label %29
29: ; preds = %44, %27
%30 = load i32, i32* %9
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %29
store i32 0, i32* %10
br label %33
33: ; preds = %39, %32
%34 = load i32, i32* %10
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
br label %33
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %9
%46 = add nsw i32 %45, -1
store i32 %46, i32* %9
br label %29
47: ; preds = %29
%48 = load i32, i32* %8
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %48)
%50 = load i32, i32* @STDIN_FILENO
%51 = call i32 @setecho(i32 %50, i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"setterm -cursor off\00"
@.str.1 = [17 x i8] c"setterm -blank 0\00"
@.str.3 = [6 x i8] c"clear\00"
@.str.4 = [6 x i8] c"\1B[%dm\00"
@.str.5 = [5 x i8] c"\1B[1m\00"
@.str.8 = [6 x i8] c"\1B[%dA\00"
@STDIN_FILENO = global i32 0
@str = [5 x i8] c"\1B[0m\00"
define i32 @init_terminal_noncurses(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add nsw i32 %0, 30
%6 = add nsw i32 %1, 40
%7 = tail call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %5)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%13 = icmp eq i32 %6, 0
br i1 %13, label %16, label %14
14: ; preds = %4
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %6)
br label %16
16: ; preds = %14, %4
%17 = icmp sgt i32 %3, -1
br i1 %17, label %18, label %31
18: ; preds = %16
%19 = icmp sgt i32 %2, 0
br label %20
20: ; preds = %18, %27
%21 = phi i32 [ %3, %18 ], [ %29, %27 ]
br i1 %19, label %22, label %27
22: ; preds = %20, %22
%23 = phi i32 [ %25, %22 ], [ 0, %20 ]
%24 = tail call i32 @putchar(i32 32)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %2
br i1 %26, label %27, label %22
27: ; preds = %22, %20
%28 = tail call i32 @putchar(i32 10)
%29 = add nsw i32 %21, -1
%30 = icmp sgt i32 %21, 0
br i1 %30, label %20, label %31
31: ; preds = %27, %16
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %3)
%33 = load i32, i32* @STDIN_FILENO
%34 = tail call i32 @setecho(i32 %33, i32 0)
ret i32 0
}