#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_boxfilwin(int, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ api_closewin(int);
int /*<<< orphan*/ api_end();
int api_getkey(int);
int /*<<< orphan*/ api_initmalloc();
char *api_malloc(int);
int api_openwin(char *, int, int, int, char *);
int /*<<< orphan*/ api_putstrwin(int, int, int, int, int, char *);
void HariMain(void) {
  char *buf;
  int win, i, x, y;
  api_initmalloc();
  buf = api_malloc(160 * 100);
  win = api_openwin(buf, 160, 100, -1, "walk");
  api_boxfilwin(win, 4, 24, 155, 95, 0);
  x = 76;
  y = 56;
  api_putstrwin(win, x, y, 3, 1, "*");
  for (;;) {
    i = api_getkey(1);
    api_putstrwin(win, x, y, 0, 1, "*");
    if (i == '4' && x > 4) {
      x -= 8;
    }
    if (i == '6' && x < 148) {
      x += 8;
    }
    if (i == '8' && y > 24) {
      y -= 8;
    }
    if (i == '2' && y < 80) {
      y += 8;
    }
    if (i == 0x0a) {
      break;
    }
    api_putstrwin(win, x, y, 3, 1, "*");
  }
  api_closewin(win);
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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)
mov    -0xc(%rbp),%edi
mov    $0x4,%esi
mov    $0x18,%edx
mov    $0x9b,%ecx
mov    $0x5f,%r8d
xor    %r9d,%r9d
call   10a0 <api_boxfilwin@plt>
movl   $0x4c,-0x14(%rbp)
movl   $0x38,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
lea    0xdfd(%rip),%r9
call   1080 <api_putstrwin@plt>
mov    $0x1,%edi
call   1070 <api_getkey@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
lea    0xdd3(%rip),%r9
call   1080 <api_putstrwin@plt>
cmpl   $0x34,-0x10(%rbp)
jne    1254 <HariMain+0xd4>
cmpl   $0x4,-0x14(%rbp)
jle    1254 <HariMain+0xd4>
mov    -0x14(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x36,-0x10(%rbp)
jne    1274 <HariMain+0xf4>
cmpl   $0x94,-0x14(%rbp)
jge    1274 <HariMain+0xf4>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x38,-0x10(%rbp)
jne    1291 <HariMain+0x111>
cmpl   $0x18,-0x18(%rbp)
jle    1291 <HariMain+0x111>
mov    -0x18(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x32,-0x10(%rbp)
jne    12ae <HariMain+0x12e>
cmpl   $0x50,-0x18(%rbp)
jge    12ae <HariMain+0x12e>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x10(%rbp)
jne    12bd <HariMain+0x13d>
jmp    12e2 <HariMain+0x162>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
lea    0xd2d(%rip),%r9
call   1080 <api_putstrwin@plt>
jmp    120d <HariMain+0x8d>
mov    -0xc(%rbp),%edi
call   1050 <api_closewin@plt>
mov    $0x0,%al
call   1030 <api_end@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HariMain>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1040 <api_initmalloc@plt>
mov    $0x3e80,%edi
call   1060 <api_malloc@plt>
lea    0xe60(%rip),%r8
mov    %rax,%rdi
mov    $0xa0,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
call   1090 <api_openwin@plt>
mov    %eax,%r15d
mov    %eax,%edi
mov    $0x4,%esi
mov    $0x18,%edx
mov    $0x9b,%ecx
mov    $0x5f,%r8d
xor    %r9d,%r9d
call   10a0 <api_boxfilwin@plt>
lea    0xe25(%rip),%r14
mov    $0x4c,%ebx
mov    $0x38,%ebp
mov    %r15d,%edi
mov    $0x4c,%esi
mov    $0x38,%edx
nopw   0x0(%rax,%rax,1)
mov    $0x3,%ecx
mov    $0x1,%r8d
mov    %r14,%r9
call   1080 <api_putstrwin@plt>
mov    $0x1,%edi
call   1070 <api_getkey@plt>
mov    %eax,%r12d
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
mov    %r14,%r9
call   1080 <api_putstrwin@plt>
lea    -0x8(%rbx),%eax
cmp    $0x5,%ebx
cmovl  %ebx,%eax
cmp    $0x34,%r12d
cmovne %ebx,%eax
lea    0x8(%rax),%ebx
cmp    $0x94,%eax
cmovge %eax,%ebx
cmp    $0x36,%r12d
cmovne %eax,%ebx
lea    -0x8(%rbp),%eax
cmp    $0x19,%ebp
cmovl  %ebp,%eax
cmp    $0x38,%r12d
cmovne %ebp,%eax
lea    0x8(%rax),%ebp
cmp    $0x50,%eax
cmovge %eax,%ebp
cmp    $0x32,%r12d
cmovne %eax,%ebp
cmp    $0xa,%r12d
je     128b <HariMain+0x10b>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
jmp    1200 <HariMain+0x80>
mov    %r15d,%edi
call   1050 <api_closewin@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <api_end@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"walk\00"
@.str.1 = [2 x i8] c"*\00"
define void @HariMain() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @api_initmalloc()
%7 = call i8* @api_malloc(i32 16000)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = call i32 @api_openwin(i8* %8, i32 160, i32 100, i32 -1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 @api_boxfilwin(i32 %10, i32 4, i32 24, i32 155, i32 95, i32 0)
store i32 76, i32* %4
store i32 56, i32* %5
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = call i32 @api_putstrwin(i32 %12, i32 %13, i32 %14, i32 3, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %61, %0
%17 = call i32 @api_getkey(i32 1)
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = call i32 @api_putstrwin(i32 %18, i32 %19, i32 %20, i32 0, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 52
br i1 %23, label %24, label %30
24: ; preds = %16
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 4
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 8
store i32 %29, i32* %4
br label %30
30: ; preds = %27, %24, %16
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 54
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 148
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 8
store i32 %38, i32* %4
br label %39
39: ; preds = %36, %33, %30
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 56
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %5
%44 = icmp sgt i32 %43, 24
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %5
%47 = sub nsw i32 %46, 8
store i32 %47, i32* %5
br label %48
48: ; preds = %45, %42, %39
%49 = load i32, i32* %3
%50 = icmp eq i32 %49, 50
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = load i32, i32* %5
%53 = icmp slt i32 %52, 80
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 8
store i32 %56, i32* %5
br label %57
57: ; preds = %54, %51, %48
%58 = load i32, i32* %3
%59 = icmp eq i32 %58, 10
br i1 %59, label %60, label %61
60: ; preds = %57
br label %66
61: ; preds = %57
%62 = load i32, i32* %2
%63 = load i32, i32* %4
%64 = load i32, i32* %5
%65 = call i32 @api_putstrwin(i32 %62, i32 %63, i32 %64, i32 3, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %16
66: ; preds = %60
%67 = load i32, i32* %2
%68 = call i32 @api_closewin(i32 %67)
%69 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"walk\00"
@.str.1 = [2 x i8] c"*\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @api_boxfilwin(i32 %3, i32 4, i32 24, i32 155, i32 95, i32 0)
%5 = tail call i32 @api_putstrwin(i32 %3, i32 76, i32 56, i32 3, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %32, %0
%7 = phi i32 [ 76, %0 ], [ %20, %32 ]
%8 = phi i32 [ 56, %0 ], [ %30, %32 ]
%9 = tail call i32 @api_getkey(i32 1)
%10 = tail call i32 @api_putstrwin(i32 %3, i32 %7, i32 %8, i32 0, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %9, 52
%12 = icmp sgt i32 %7, 4
%13 = select i1 %11, i1 %12, i1 false
%14 = add nsw i32 %7, -8
%15 = select i1 %13, i32 %14, i32 %7
%16 = icmp eq i32 %9, 54
%17 = icmp slt i32 %15, 148
%18 = select i1 %16, i1 %17, i1 false
%19 = add nsw i32 %15, 8
%20 = select i1 %18, i32 %19, i32 %15
%21 = icmp eq i32 %9, 56
%22 = icmp sgt i32 %8, 24
%23 = select i1 %21, i1 %22, i1 false
%24 = add nsw i32 %8, -8
%25 = select i1 %23, i32 %24, i32 %8
%26 = icmp eq i32 %9, 50
%27 = icmp slt i32 %25, 80
%28 = select i1 %26, i1 %27, i1 false
%29 = add nsw i32 %25, 8
%30 = select i1 %28, i32 %29, i32 %25
%31 = icmp eq i32 %9, 10
br i1 %31, label %34, label %32
32: ; preds = %6
%33 = tail call i32 @api_putstrwin(i32 %3, i32 %20, i32 %30, i32 3, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %6
34: ; preds = %6
%35 = tail call i32 @api_closewin(i32 %3)
%36 = tail call i32 (...) @api_end()
ret void
}