#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 i8253_get();
int /*<<< orphan*/ i8253_set(int);
int /*<<< orphan*/ init_display();
int /*<<< orphan*/ update_field(int, int);
void clock() {
  int hours, mins, secs, hund;
  init_display();
  hours = mins = secs = hund = 0;
  update_field(0, hours);
  update_field(3, mins);
  update_field(6, secs);
  update_field(9, hund);
  i8253_set((1193181 / 100));
  while (1) {
    while (i8253_get() != (1193181 / 100))
      ;
    hund++;
    if (hund > 99) {
      hund = 0;
      secs++;
      if (secs > 59) {
        secs = 0;
        mins++;
        if (mins > 59) {
          mins = 0;
          hours++;
          if (hours > 23)
            hours = 0;
          update_field(0, hours);
        }
        update_field(3, mins);
      }
      update_field(6, secs);
    }
    update_field(9, hund);
    while (i8253_get() == (1193181 / 100))
      ;
  }
}


x86 assembly (clang, -O0):
<clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <init_display@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1030 <update_field@plt>
mov    -0x8(%rbp),%esi
mov    $0x3,%edi
call   1030 <update_field@plt>
mov    -0xc(%rbp),%esi
mov    $0x6,%edi
call   1030 <update_field@plt>
mov    -0x10(%rbp),%esi
mov    $0x9,%edi
call   1030 <update_field@plt>
mov    $0x2e9b,%edi
call   1040 <i8253_set@plt>
jmp    11ab <clock+0x6b>
mov    $0x0,%al
call   1060 <i8253_get@plt>
cmp    $0x2e9b,%eax
je     11c2 <clock+0x82>
jmp    11ab <clock+0x6b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x63,-0x10(%rbp)
jle    124e <clock+0x10e>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3b,-0xc(%rbp)
jle    1241 <clock+0x101>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x3b,-0x8(%rbp)
jle    1234 <clock+0xf4>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x17,-0x4(%rbp)
jle    122a <clock+0xea>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1030 <update_field@plt>
mov    -0x8(%rbp),%esi
mov    $0x3,%edi
call   1030 <update_field@plt>
mov    -0xc(%rbp),%esi
mov    $0x6,%edi
call   1030 <update_field@plt>
mov    -0x10(%rbp),%esi
mov    $0x9,%edi
call   1030 <update_field@plt>
mov    $0x0,%al
call   1060 <i8253_get@plt>
cmp    $0x2e9b,%eax
jne    1272 <clock+0x132>
jmp    125b <clock+0x11b>
jmp    11a6 <clock+0x66>

x86 assembly (clang, -O2):
<clock>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <init_display@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <update_field@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1030 <update_field@plt>
mov    $0x6,%edi
xor    %esi,%esi
call   1030 <update_field@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <update_field@plt>
mov    $0x2e9b,%edi
call   1040 <i8253_set@plt>
xor    %r15d,%r15d
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1060 <i8253_get@plt>
cmp    $0x2e9b,%eax
jne    1190 <clock+0x50>
cmp    $0x63,%ebx
jl     11b4 <clock+0x74>
cmp    $0x3b,%ebp
jl     11b9 <clock+0x79>
cmp    $0x3b,%r14d
jge    11be <clock+0x7e>
add    $0x1,%r14d
jmp    11d9 <clock+0x99>
add    $0x1,%ebx
jmp    11f6 <clock+0xb6>
add    $0x1,%ebp
jmp    11e8 <clock+0xa8>
lea    0x1(%r15),%ebx
xor    %r14d,%r14d
cmp    $0x17,%r15d
cmovge %r14d,%ebx
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <update_field@plt>
mov    %ebx,%r15d
mov    $0x3,%edi
mov    %r14d,%esi
call   1030 <update_field@plt>
xor    %ebp,%ebp
mov    $0x6,%edi
mov    %ebp,%esi
call   1030 <update_field@plt>
xor    %ebx,%ebx
mov    $0x9,%edi
mov    %ebx,%esi
call   1030 <update_field@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <i8253_get@plt>
cmp    $0x2e9b,%eax
je     1210 <clock+0xd0>
jmp    1190 <clock+0x50>

LLVM IR (-O0):
define void @clock() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @init_display()
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @update_field(i32 0, i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @update_field(i32 3, i32 %8)
%10 = load i32, i32* %3
%11 = call i32 @update_field(i32 6, i32 %10)
%12 = load i32, i32* %4
%13 = call i32 @update_field(i32 9, i32 %12)
%14 = call i32 @i8253_set(i32 11931)
br label %15
15: ; preds = %0, %57
br label %16
16: ; preds = %19, %15
%17 = call i32 (...) @i8253_get()
%18 = icmp ne i32 %17, 11931
br i1 %18, label %19, label %20
19: ; preds = %16
br label %16
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 99
br i1 %24, label %25, label %50
25: ; preds = %20
store i32 0, i32* %4
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 59
br i1 %29, label %30, label %47
30: ; preds = %25
store i32 0, i32* %3
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = icmp sgt i32 %33, 59
br i1 %34, label %35, label %44
35: ; preds = %30
store i32 0, i32* %2
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
%38 = load i32, i32* %1
%39 = icmp sgt i32 %38, 23
br i1 %39, label %40, label %41
40: ; preds = %35
store i32 0, i32* %1
br label %41
41: ; preds = %40, %35
%42 = load i32, i32* %1
%43 = call i32 @update_field(i32 0, i32 %42)
br label %44
44: ; preds = %41, %30
%45 = load i32, i32* %2
%46 = call i32 @update_field(i32 3, i32 %45)
br label %47
47: ; preds = %44, %25
%48 = load i32, i32* %3
%49 = call i32 @update_field(i32 6, i32 %48)
br label %50
50: ; preds = %47, %20
%51 = load i32, i32* %4
%52 = call i32 @update_field(i32 9, i32 %51)
br label %53
53: ; preds = %56, %50
%54 = call i32 (...) @i8253_get()
%55 = icmp eq i32 %54, 11931
br i1 %55, label %56, label %57
56: ; preds = %53
br label %53
57: ; preds = %53
br label %15
}

LLVM IR (-O2):
define void @clock() {
%1 = tail call i32 (...) @init_display()
%2 = tail call i32 @update_field(i32 0, i32 0)
%3 = tail call i32 @update_field(i32 3, i32 0)
%4 = tail call i32 @update_field(i32 6, i32 0)
%5 = tail call i32 @update_field(i32 9, i32 0)
%6 = tail call i32 @i8253_set(i32 11931)
br label %7
7: ; preds = %44, %0
%8 = phi i32 [ 0, %0 ], [ %39, %44 ]
%9 = phi i32 [ 0, %0 ], [ %40, %44 ]
%10 = phi i32 [ 0, %0 ], [ %41, %44 ]
%11 = phi i32 [ 0, %0 ], [ %42, %44 ]
br label %12
12: ; preds = %12, %7
%13 = tail call i32 (...) @i8253_get()
%14 = icmp eq i32 %13, 11931
br i1 %14, label %15, label %12
15: ; preds = %12
%16 = add nsw i32 %11, 1
%17 = icmp sgt i32 %11, 98
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = add nsw i32 %10, 1
%20 = icmp sgt i32 %10, 58
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = add nsw i32 %9, 1
%23 = icmp sgt i32 %9, 58
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = add nsw i32 %8, 1
%26 = icmp sgt i32 %8, 22
%27 = select i1 %26, i32 0, i32 %25
%28 = tail call i32 @update_field(i32 0, i32 %27)
br label %29
29: ; preds = %24, %21
%30 = phi i32 [ %27, %24 ], [ %8, %21 ]
%31 = phi i32 [ 0, %24 ], [ %22, %21 ]
%32 = tail call i32 @update_field(i32 3, i32 %31)
br label %33
33: ; preds = %29, %18
%34 = phi i32 [ %30, %29 ], [ %8, %18 ]
%35 = phi i32 [ %31, %29 ], [ %9, %18 ]
%36 = phi i32 [ 0, %29 ], [ %19, %18 ]
%37 = tail call i32 @update_field(i32 6, i32 %36)
br label %38
38: ; preds = %33, %15
%39 = phi i32 [ %34, %33 ], [ %8, %15 ]
%40 = phi i32 [ %35, %33 ], [ %9, %15 ]
%41 = phi i32 [ %36, %33 ], [ %10, %15 ]
%42 = phi i32 [ 0, %33 ], [ %16, %15 ]
%43 = tail call i32 @update_field(i32 9, i32 %42)
br label %44
44: ; preds = %44, %38
%45 = tail call i32 (...) @i8253_get()
%46 = icmp eq i32 %45, 11931
br i1 %46, label %44, label %7
}