#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*/ api_closewin(int);
int /*<<< orphan*/ api_end();
int api_getkey(int);
int /*<<< orphan*/ api_initmalloc();
int /*<<< orphan*/ api_linewin(int, int, int, int, int, int);
char *api_malloc(int);
int api_openwin(char *, int, int, int, char *);
int /*<<< orphan*/ api_refreshwin(int, int, int, int, int);
void HariMain(void) {
  char *buf;
  int win, i;
  api_initmalloc();
  buf = api_malloc(160 * 100);
  win = api_openwin(buf, 160, 100, -1, "lines");
  for (i = 0; i < 8; i++) {
    api_linewin(win + 1, 8, 26, 77, i * 9 + 26, i);
    api_linewin(win + 1, 88, 26, i * 9 + 88, 89, i);
  }
  api_refreshwin(win, 6, 26, 154, 90);
  for (;;) {
    if (api_getkey(1) == 0x0a) {
      break;
    }
  }
  api_closewin(win);
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <api_initmalloc@plt>
mov    $0x3e80,%edi
call   1060 <api_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa0,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
lea    0xe49(%rip),%r8
call   1090 <api_openwin@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    122b <HariMain+0xab>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
imul   $0x9,-0x10(%rbp),%r8d
add    $0x1a,%r8d
mov    -0x10(%rbp),%r9d
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
call   10a0 <api_linewin@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
imul   $0x9,-0x10(%rbp),%ecx
add    $0x58,%ecx
mov    -0x10(%rbp),%r9d
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x59,%r8d
call   10a0 <api_linewin@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c6 <HariMain+0x46>
mov    -0xc(%rbp),%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x9a,%ecx
mov    $0x5a,%r8d
call   1080 <api_refreshwin@plt>
mov    $0x1,%edi
call   1070 <api_getkey@plt>
cmp    $0xa,%eax
jne    1260 <HariMain+0xe0>
jmp    1265 <HariMain+0xe5>
jmp    1248 <HariMain+0xc8>
mov    -0xc(%rbp),%edi
call   1050 <api_closewin@plt>
mov    $0x0,%al
call   1030 <api_end@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HariMain>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <api_initmalloc@plt>
mov    $0x3e80,%edi
call   1060 <api_malloc@plt>
lea    0xe65(%rip),%r8
mov    %rax,%rdi
mov    $0xa0,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
call   1090 <api_openwin@plt>
mov    %eax,%ebx
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x1a,%r8d
xor    %r9d,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x58,%ecx
mov    $0x59,%r8d
xor    %r9d,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x23,%r8d
mov    $0x1,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x61,%ecx
mov    $0x59,%r8d
mov    $0x1,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x2c,%r8d
mov    $0x2,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x6a,%ecx
mov    $0x59,%r8d
mov    $0x2,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x35,%r8d
mov    $0x3,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x73,%ecx
mov    $0x59,%r8d
mov    $0x3,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x3e,%r8d
mov    $0x4,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x7c,%ecx
mov    $0x59,%r8d
mov    $0x4,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x47,%r8d
mov    $0x5,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x85,%ecx
mov    $0x59,%r8d
mov    $0x5,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x50,%r8d
mov    $0x6,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x8e,%ecx
mov    $0x59,%r8d
mov    $0x6,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x4d,%ecx
mov    $0x59,%r8d
mov    $0x7,%r9d
call   10a0 <api_linewin@plt>
mov    %ebp,%edi
mov    $0x58,%esi
mov    $0x1a,%edx
mov    $0x97,%ecx
mov    $0x59,%r8d
mov    $0x7,%r9d
call   10a0 <api_linewin@plt>
mov    %ebx,%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x9a,%ecx
mov    $0x5a,%r8d
call   1080 <api_refreshwin@plt>
nopl   (%rax)
mov    $0x1,%edi
call   1070 <api_getkey@plt>
cmp    $0xa,%eax
jne    13f0 <HariMain+0x270>
mov    %ebx,%edi
call   1050 <api_closewin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <api_end@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"lines\00"
define void @HariMain() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @api_initmalloc()
%5 = call i8* @api_malloc(i32 16000)
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = call i32 @api_openwin(i8* %6, i32 160, i32 100, i32 -1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %7, i32* %2
store i32 0, i32* %3
br label %8
8: ; preds = %26, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 9
%16 = add nsw i32 %15, 26
%17 = load i32, i32* %3
%18 = call i32 @api_linewin(i32 %13, i32 8, i32 26, i32 77, i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 9
%23 = add nsw i32 %22, 88
%24 = load i32, i32* %3
%25 = call i32 @api_linewin(i32 %20, i32 88, i32 26, i32 %23, i32 89, i32 %24)
br label %26
26: ; preds = %11
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %8
29: ; preds = %8
%30 = load i32, i32* %2
%31 = call i32 @api_refreshwin(i32 %30, i32 6, i32 26, i32 154, i32 90)
br label %32
32: ; preds = %36, %29
%33 = call i32 @api_getkey(i32 1)
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %36
35: ; preds = %32
br label %37
36: ; preds = %32
br label %32
37: ; preds = %35
%38 = load i32, i32* %2
%39 = call i32 @api_closewin(i32 %38)
%40 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"lines\00"
define void @HariMain() {
%1 = tail call i32 (...) @api_initmalloc()
%2 = tail call i8* @api_malloc(i32 16000)
%3 = tail call i32 @api_openwin(i8* %2, i32 160, i32 100, i32 -1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 26, i32 0)
%6 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 88, i32 89, i32 0)
%7 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 35, i32 1)
%8 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 97, i32 89, i32 1)
%9 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 44, i32 2)
%10 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 106, i32 89, i32 2)
%11 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 53, i32 3)
%12 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 115, i32 89, i32 3)
%13 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 62, i32 4)
%14 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 124, i32 89, i32 4)
%15 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 71, i32 5)
%16 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 133, i32 89, i32 5)
%17 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 80, i32 6)
%18 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 142, i32 89, i32 6)
%19 = tail call i32 @api_linewin(i32 %4, i32 8, i32 26, i32 77, i32 89, i32 7)
%20 = tail call i32 @api_linewin(i32 %4, i32 88, i32 26, i32 151, i32 89, i32 7)
%21 = tail call i32 @api_refreshwin(i32 %3, i32 6, i32 26, i32 154, i32 90)
br label %22
22: ; preds = %22, %0
%23 = tail call i32 @api_getkey(i32 1)
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %22
25: ; preds = %22
%26 = tail call i32 @api_closewin(i32 %3)
%27 = tail call i32 (...) @api_end()
ret void
}