#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_end();
int /*<<< orphan*/ init_mem();
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ win_fill(int, int, int, int, int, int /*<<< orphan*/);
int win_open(char *, int, int, int, char *);
int /*<<< orphan*/ win_point(int, int, int, int);
int /*<<< orphan*/ win_refresh(int, int, int, int, int);
void HariMain(void) {
  char *buf;
  int win, i, x, y;
  init_mem();
  buf = (char *)malloc(150 * 100);
  win = win_open(buf, 150, 100, -1, "Win-STARS");
  win_fill(win + 1, 6, 26, 143, 93, 0);
  for (i = 0; i < 100; ++i) {
    x = (rand() % 137) + 6;
    y = (rand() % 67) + 26;
    win_point(win + 1, x, y, 3);
  }
  win_refresh(win, 6, 26, 144, 94);
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <init_mem@plt>
mov    $0x3a98,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x96,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
lea    0xe49(%rip),%r8
call   1090 <win_open@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   1040 <win_fill@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jge    1241 <HariMain+0xc1>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x89,%ecx
cltd
idiv   %ecx
add    $0x6,%edx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   10a0 <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   1080 <win_point@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e9 <HariMain+0x69>
mov    -0xc(%rbp),%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x90,%ecx
mov    $0x5e,%r8d
call   1070 <win_refresh@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   %rbx
push   %rax
xor    %eax,%eax
call   1050 <init_mem@plt>
mov    $0x3a98,%edi
call   1060 <malloc@plt>
lea    0xe61(%rip),%r8
mov    $0x64,%ebp
mov    %rax,%rdi
mov    $0x96,%esi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
call   1090 <win_open@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   1040 <win_fill@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10a0 <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   10a0 <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   1080 <win_point@plt>
add    $0xffffffff,%ebp
jne    11f0 <HariMain+0x70>
mov    %r14d,%edi
mov    $0x6,%esi
mov    $0x1a,%edx
mov    $0x90,%ecx
mov    $0x5e,%r8d
call   1070 <win_refresh@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <api_end@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Win-STARS\00"
define void @HariMain() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @init_mem()
%7 = call i64 @malloc(i32 15000)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %1
%9 = load i8*, i8** %1
%10 = call i32 @win_open(i8* %9, i32 150, i32 100, i32 -1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = call i32 @win_fill(i32 %12, i32 6, i32 26, i32 143, i32 93, i32 0)
store i32 0, i32* %3
br label %14
14: ; preds = %29, %0
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 100
br i1 %16, label %17, label %32
17: ; preds = %14
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 137
%20 = add nsw i32 %19, 6
store i32 %20, i32* %4
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 67
%23 = add nsw i32 %22, 26
store i32 %23, i32* %5
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = call i32 @win_point(i32 %25, i32 %26, i32 %27, i32 3)
br label %29
29: ; preds = %17
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %14
32: ; preds = %14
%33 = load i32, i32* %2
%34 = call i32 @win_refresh(i32 %33, i32 6, i32 26, i32 144, i32 94)
%35 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Win-STARS\00"
define void @HariMain() {
%1 = tail call i32 (...) @init_mem()
%2 = tail call i64 @malloc(i32 15000)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @win_open(i8* %3, i32 150, i32 100, i32 -1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = add nsw i32 %4, 1
%6 = tail call i32 @win_fill(i32 %5, i32 6, i32 26, i32 143, i32 93, i32 0)
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %16, %7 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 137
%11 = add nsw i32 %10, 6
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 67
%14 = add nsw i32 %13, 26
%15 = tail call i32 @win_point(i32 %5, i32 %11, i32 %14, i32 3)
%16 = add nuw nsw i32 %8, 1
%17 = icmp eq i32 %16, 100
br i1 %17, label %18, label %7
18: ; preds = %7
%19 = tail call i32 @win_refresh(i32 %4, i32 6, i32 26, i32 144, i32 94)
%20 = tail call i32 (...) @api_end()
ret void
}