#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_end();
int api_getkey(int);
int /*<<< orphan*/ api_initmalloc();
char *api_malloc(int);
int api_openwin(char *, int, int, int, char *);
int /*<<< orphan*/ api_point(int, int, int, int);
int /*<<< orphan*/ api_refreshwin(int, int, int, int, int);
int rand();
void HariMain(void) {
  char *buf;
  int win, i, x, y;
  api_initmalloc();
  buf = api_malloc(150 * 100);
  win = api_openwin(buf, 150, 100, -1, "stars2");
  api_boxfilwin(win + 1, 6, 26, 143, 93, 0);
  for (i = 0; i < 50; i++) {
    x = (rand() % 137) + 6;
    y = (rand() % 67) + 26;
    api_point(win + 1, x, y, 3);
  }
  api_refreshwin(win, 6, 26, 144, 94);
  for (;;) {
    if (api_getkey(1) == 0x0a) {
      break;
    }
  }
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <api_initmalloc@plt>
mov    $0x3a98,%edi
call   1050 <api_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x96,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
lea    0xe39(%rip),%r8
call   1090 <api_openwin@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x8f,%ecx
mov    $0x5d,%r8d
xor    %r9d,%r9d
call   10a0 <api_boxfilwin@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jge    1251 <HariMain+0xc1>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x89,%ecx
cltd
idiv   %ecx
add    $0x6,%edx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x43,%ecx
cltd
idiv   %ecx
add    $0x1a,%edx
mov    %edx,-0x18(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x3,%ecx
call   1060 <api_point@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f9 <HariMain+0x69>
mov    -0xc(%rbp),%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x90,%ecx
mov    $0x5e,%r8d
call   1080 <api_refreshwin@plt>
mov    $0x1,%edi
call   1070 <api_getkey@plt>
cmp    $0xa,%eax
jne    1286 <HariMain+0xf6>
jmp    128b <HariMain+0xfb>
jmp    126e <HariMain+0xde>
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   %rbx
push   %rax
xor    %eax,%eax
call   1040 <api_initmalloc@plt>
mov    $0x3a98,%edi
call   1050 <api_malloc@plt>
lea    0xe51(%rip),%r8
mov    %rax,%rdi
mov    $0x96,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
call   1090 <api_openwin@plt>
mov    %eax,%r14d
mov    %eax,%r15d
add    $0x1,%r15d
mov    %r15d,%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x8f,%ecx
mov    $0x5d,%r8d
xor    %r9d,%r9d
call   10a0 <api_boxfilwin@plt>
mov    $0x32,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x77975b9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
imul   $0x89,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x6,%ebx
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x7a44c6b,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
imul   $0x43,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1a,%edx
mov    %r15d,%edi
mov    %ebx,%esi
mov    $0x3,%ecx
call   1060 <api_point@plt>
add    $0xffffffff,%ebp
jne    1200 <HariMain+0x70>
mov    %r14d,%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x90,%ecx
mov    $0x5e,%r8d
call   1080 <api_refreshwin@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edi
call   1070 <api_getkey@plt>
cmp    $0xa,%eax
jne    1290 <HariMain+0x100>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <api_end@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"stars2\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 15000)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = call i32 @api_openwin(i8* %8, i32 150, i32 100, i32 -1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = call i32 @api_boxfilwin(i32 %11, i32 6, i32 26, i32 143, i32 93, i32 0)
store i32 0, i32* %3
br label %13
13: ; preds = %28, %0
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 50
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 137
%19 = add nsw i32 %18, 6
store i32 %19, i32* %4
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 67
%22 = add nsw i32 %21, 26
store i32 %22, i32* %5
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @api_point(i32 %24, i32 %25, i32 %26, i32 3)
br label %28
28: ; preds = %16
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %13
31: ; preds = %13
%32 = load i32, i32* %2
%33 = call i32 @api_refreshwin(i32 %32, i32 6, i32 26, i32 144, i32 94)
br label %34
34: ; preds = %38, %31
%35 = call i32 @api_getkey(i32 1)
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %38
37: ; preds = %34
br label %39
38: ; preds = %34
br label %34
39: ; preds = %37
%40 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"stars2\00"
define void @HariMain() {
%1 = tail call i32 (...) @api_initmalloc()
%2 = tail call i8* @api_malloc(i32 15000)
%3 = tail call i32 @api_openwin(i8* %2, i32 150, i32 100, i32 -1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = tail call i32 @api_boxfilwin(i32 %4, i32 6, i32 26, i32 143, i32 93, i32 0)
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ 0, %0 ], [ %15, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 137
%10 = add nsw i32 %9, 6
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 67
%13 = add nsw i32 %12, 26
%14 = tail call i32 @api_point(i32 %4, i32 %10, i32 %13, i32 3)
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, 50
br i1 %16, label %17, label %6
17: ; preds = %6
%18 = tail call i32 @api_refreshwin(i32 %3, i32 6, i32 26, i32 144, i32 94)
br label %19
19: ; preds = %19, %17
%20 = tail call i32 @api_getkey(i32 1)
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %19
22: ; preds = %19
%23 = tail call i32 (...) @api_end()
ret void
}