#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  char tm_mday;
};

/* Variables and functions */
int /*<<< orphan*/ clrscr();
int /*<<< orphan*/ drawCalendar(struct tm *);
int /*<<< orphan*/ drawDate(struct tm *);
int /*<<< orphan*/ drawTime(struct tm *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char day;
  time_t rawtime;
  struct tm *timeinfo;
  day = 0;
  clrscr();
  while (1) {
    time(&rawtime);
    timeinfo = localtime(&rawtime);
    drawTime(timeinfo);
    if (day != timeinfo->tm_mday) {
      day = timeinfo->tm_mday;
      drawDate(timeinfo);
      drawCalendar(timeinfo);
    }
    fflush(stdout);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
mov    $0x0,%al
call   1040 <clrscr@plt>
lea    -0xc(%rbp),%rdi
call   1060 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <drawTime@plt>
movsbl -0x5(%rbp),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e7 <main+0x67>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x5(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <drawDate@plt>
mov    -0x18(%rbp),%rdi
call   1080 <drawCalendar@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
jmp    119a <main+0x1a>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <clrscr@plt>
lea    0xc(%rsp),%r14
mov    0x2e3f(%rip),%r15
jmp    11c2 <main+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    %r14,%rdi
call   1060 <time@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <drawTime@plt>
movzbl (%rbx),%r12d
cmp    %r12b,%bpl
je     11b0 <main+0x30>
mov    %rbx,%rdi
call   1090 <drawDate@plt>
mov    %rbx,%rdi
call   1080 <drawCalendar@plt>
mov    %r12d,%ebp
jmp    11b0 <main+0x30>

LLVM IR (-O0):
%struct.tm = type { i8 }
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca %struct.tm*
store i32 0, i32* %1
store i8 0, i8* %2
%5 = call i32 (...) @clrscr()
br label %6
6: ; preds = %0, %26
%7 = call i32 @time(i32* %3)
%8 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %8, %struct.tm** %4
%9 = load %struct.tm*, %struct.tm** %4
%10 = call i32 @drawTime(%struct.tm* %9)
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = load %struct.tm*, %struct.tm** %4
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %12, %16
br i1 %17, label %18, label %26
18: ; preds = %6
%19 = load %struct.tm*, %struct.tm** %4
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load i8, i8* %20
store i8 %21, i8* %2
%22 = load %struct.tm*, %struct.tm** %4
%23 = call i32 @drawDate(%struct.tm* %22)
%24 = load %struct.tm*, %struct.tm** %4
%25 = call i32 @drawCalendar(%struct.tm* %24)
br label %26
26: ; preds = %18, %6
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
%29 = call i32 @sleep(i32 1)
br label %6
}

LLVM IR (-O2):
%struct.tm = type { i8 }
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @clrscr()
br label %4
4: ; preds = %15, %0
%5 = phi i8 [ 0, %0 ], [ %16, %15 ]
%6 = call i32 @time(i32* %1)
%7 = call %struct.tm* @localtime(i32* %1)
%8 = call i32 @drawTime(%struct.tm* %7)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%10 = load i8, i8* %9
%11 = icmp eq i8 %5, %10
br i1 %11, label %15, label %12
12: ; preds = %4
%13 = call i32 @drawDate(%struct.tm* %7)
%14 = call i32 @drawCalendar(%struct.tm* %7)
br label %15
15: ; preds = %12, %4
%16 = phi i8 [ %10, %12 ], [ %5, %4 ]
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = call i32 @sleep(i32 1)
br label %4
}