#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 create_timer();
int getkey(int);
int /*<<< orphan*/ init_mem();
int /*<<< orphan*/ init_timer(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ set_timer(int, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ win_fill(int, int, int, int, int, int);
int win_open(char *, int, int, int, char *);
int /*<<< orphan*/ win_puts(int, int, int, int /*<<< orphan*/, int, char *);
void HariMain(void) {
  char *buf;
  char str[32];
  int win, timer, sec = 0, min = 0, hour = 0;
  int key;
  init_mem();
  buf = (char *)malloc(150 * 50);
  win = win_open(buf, 150, 50, -1, "Win-NOODLE");
  timer = create_timer();
  init_timer(timer, 128);
  for (;;) {
    sprintf(str, "%05d:%02d:%02d", hour, min, sec);
    win_fill(win, 28, 27, 115, 41, 7);
    win_puts(win, 28, 27, 0, 11, str);
    set_timer(timer, 100);
    key = getkey(1);
    if (128 != key)
      break;
    ++sec;
    if (60 == sec) {
      sec = 0;
      ++min;
      if (60 == min) {
        min = 0;
        ++hour;
      }
    }
  }
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    $0x0,%al
call   1060 <init_mem@plt>
mov    $0x1d4c,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x96,%esi
mov    $0x32,%edx
mov    $0xffffffff,%ecx
lea    0xe04(%rip),%r8
call   10c0 <win_open@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <create_timer@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    $0x80,%esi
call   10a0 <init_timer@plt>
lea    -0x30(%rbp),%rdi
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
lea    0xddb(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x34(%rbp),%edi
mov    $0x1c,%esi
mov    $0x1b,%edx
mov    $0x73,%ecx
mov    $0x29,%r8d
mov    $0x7,%r9d
call   1050 <win_fill@plt>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%r9
mov    $0x1c,%esi
mov    $0x1b,%edx
xor    %ecx,%ecx
mov    $0xb,%r8d
call   1090 <win_puts@plt>
mov    -0x38(%rbp),%edi
mov    $0x64,%esi
call   10b0 <set_timer@plt>
mov    $0x1,%edi
call   1080 <getkey@plt>
mov    %eax,-0x48(%rbp)
mov    $0x80,%eax
cmp    -0x48(%rbp),%eax
je     12a3 <HariMain+0xf3>
jmp    12f2 <HariMain+0x142>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    $0x3c,%eax
cmp    -0x3c(%rbp),%eax
jne    12ed <HariMain+0x13d>
movl   $0x0,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    $0x3c,%eax
cmp    -0x40(%rbp),%eax
jne    12e8 <HariMain+0x138>
movl   $0x0,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12ed <HariMain+0x13d>
jmp    121b <HariMain+0x6b>
mov    $0x0,%al
call   1030 <api_end@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HariMain>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1060 <init_mem@plt>
mov    $0x1d4c,%edi
call   1070 <malloc@plt>
lea    0xe2a(%rip),%r8
mov    %rax,%rdi
mov    $0x96,%esi
mov    $0x32,%edx
mov    $0xffffffff,%ecx
call   10c0 <win_open@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <create_timer@plt>
mov    %eax,%r15d
mov    %eax,%edi
mov    $0x80,%esi
call   10a0 <init_timer@plt>
mov    %rsp,%r12
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %r14d,%r14d
mov    %r12,%rdi
lea    0xdf1(%rip),%rsi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   10d0 <sprintf@plt>
mov    %ebx,%edi
mov    $0x1c,%esi
mov    $0x1b,%edx
mov    $0x73,%ecx
mov    $0x29,%r8d
mov    $0x7,%r9d
call   1050 <win_fill@plt>
mov    %ebx,%edi
mov    $0x1c,%esi
mov    $0x1b,%edx
xor    %ecx,%ecx
mov    $0xb,%r8d
mov    %r12,%r9
call   1090 <win_puts@plt>
mov    %r15d,%edi
mov    $0x64,%esi
call   10b0 <set_timer@plt>
mov    $0x1,%edi
call   1080 <getkey@plt>
cmp    $0x80,%eax
jne    12a8 <HariMain+0xf8>
add    $0x1,%r14d
cmp    $0x3c,%r14d
jne    1210 <HariMain+0x60>
add    $0x1,%ebp
xor    %eax,%eax
cmp    $0x3c,%ebp
sete   %al
mov    $0x0,%ecx
cmove  %ecx,%ebp
add    %eax,%r13d
jmp    120d <HariMain+0x5d>
xor    %eax,%eax
call   1030 <api_end@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Win-NOODLE\00"
@.str.1 = [15 x i8] c"%05d:%02d:%02d\00"
define void @HariMain() {
%1 = alloca i8*
%2 = alloca [32 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = call i32 (...) @init_mem()
%10 = call i64 @malloc(i32 7500)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %1
%12 = load i8*, i8** %1
%13 = call i32 @win_open(i8* %12, i32 150, i32 50, i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %3
%14 = call i32 (...) @create_timer()
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = call i32 @init_timer(i32 %15, i32 128)
br label %17
17: ; preds = %48, %0
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
%23 = load i32, i32* %3
%24 = call i32 @win_fill(i32 %23, i32 28, i32 27, i32 115, i32 41, i32 7)
%25 = load i32, i32* %3
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%27 = call i32 @win_puts(i32 %25, i32 28, i32 27, i32 0, i32 11, i8* %26)
%28 = load i32, i32* %4
%29 = call i32 @set_timer(i32 %28, i32 100)
%30 = call i32 @getkey(i32 1)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp ne i32 128, %31
br i1 %32, label %33, label %34
33: ; preds = %17
br label %49
34: ; preds = %17
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = icmp eq i32 60, %37
br i1 %38, label %39, label %48
39: ; preds = %34
store i32 0, i32* %5
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
%42 = load i32, i32* %6
%43 = icmp eq i32 60, %42
br i1 %43, label %44, label %47
44: ; preds = %39
store i32 0, i32* %6
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %47
47: ; preds = %44, %39
br label %48
48: ; preds = %47, %34
br label %17
49: ; preds = %33
%50 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Win-NOODLE\00"
@.str.1 = [15 x i8] c"%05d:%02d:%02d\00"
define void @HariMain() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @init_mem()
%4 = tail call i64 @malloc(i32 7500)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @win_open(i8* %5, i32 150, i32 50, i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @create_timer()
%8 = tail call i32 @init_timer(i32 %7, i32 128)
br label %9
9: ; preds = %23, %0
%10 = phi i32 [ %26, %23 ], [ 0, %0 ]
%11 = phi i32 [ %28, %23 ], [ 0, %0 ]
br label %12
12: ; preds = %9, %20
%13 = phi i32 [ %21, %20 ], [ 0, %9 ]
%14 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %10, i32 %13)
%15 = call i32 @win_fill(i32 %6, i32 28, i32 27, i32 115, i32 41, i32 7)
%16 = call i32 @win_puts(i32 %6, i32 28, i32 27, i32 0, i32 11, i8* %2)
%17 = call i32 @set_timer(i32 %7, i32 100)
%18 = call i32 @getkey(i32 1)
%19 = icmp eq i32 %18, 128
br i1 %19, label %20, label %29
20: ; preds = %12
%21 = add nuw nsw i32 %13, 1
%22 = icmp eq i32 %21, 60
br i1 %22, label %23, label %12
23: ; preds = %20
%24 = add nsw i32 %10, 1
%25 = icmp eq i32 %24, 60
%26 = select i1 %25, i32 0, i32 %24
%27 = zext i1 %25 to i32
%28 = add nuw nsw i32 %11, %27
br label %9
29: ; preds = %12
%30 = call i32 (...) @api_end()
ret void
}