#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 GET32(int);
int /*<<< orphan*/ PUT32(int, int);
void clock_init(void) {
  (*(volatile unsigned int *)((0x40023800 + 0x00))) &= ~(0xF << 16);
  (*(volatile unsigned int *)((0x40023800 + 0x00))) |= 1 << 16;
  while (1) {
    if ((*(volatile unsigned int *)((0x40023800 + 0x00))) & (1 << 17))
      break;
  }
  PUT32((0x40023800 + 0x08), 0x00009401);
  PUT32(0x40023C00, 0x00000703);
  (*(volatile unsigned int *)((0x40023800 + 0x04))) =
      (5 << 24) | (1 << 22) | (((2 >> 1) - 1) << 16) | (240 << 6) | (25 << 0);
  (*(volatile unsigned int *)((0x40023800 + 0x00))) |= (1 << 24);
  while (1) {
    if (GET32((0x40023800 + 0x00)) & (1 << 25))
      break;
  }
  PUT32((0x40023800 + 0x08), 0x00009402);
  while (1) {
    if ((GET32((0x40023800 + 0x08)) & 0xC) == 0x8)
      break;
  }
}


x86 assembly (clang, -O0):
<clock_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x40023800,%eax
mov    (%rax),%ecx
and    $0xfff0ffff,%ecx
mov    $0x40023800,%eax
mov    %ecx,(%rax)
mov    $0x40023800,%eax
mov    (%rax),%ecx
or     $0x10000,%ecx
mov    $0x40023800,%eax
mov    %ecx,(%rax)
mov    $0x40023800,%eax
mov    (%rax),%eax
and    $0x20000,%eax
cmp    $0x0,%eax
je     1166 <clock_init+0x46>
jmp    116b <clock_init+0x4b>
jmp    114c <clock_init+0x2c>
mov    $0x40023808,%edi
mov    $0x9401,%esi
call   1030 <PUT32@plt>
mov    $0x40023c00,%edi
mov    $0x703,%esi
call   1030 <PUT32@plt>
mov    $0x40023804,%eax
movl   $0x5403c19,(%rax)
mov    $0x40023800,%eax
mov    (%rax),%ecx
or     $0x1000000,%ecx
mov    $0x40023800,%eax
mov    %ecx,(%rax)
mov    $0x40023800,%edi
call   1040 <GET32@plt>
and    $0x2000000,%eax
cmp    $0x0,%eax
je     11c5 <clock_init+0xa5>
jmp    11ca <clock_init+0xaa>
jmp    11a8 <clock_init+0x88>
mov    $0x40023808,%edi
mov    $0x9402,%esi
call   1030 <PUT32@plt>
mov    $0x40023808,%edi
call   1040 <GET32@plt>
and    $0xc,%eax
cmp    $0x8,%eax
jne    11f4 <clock_init+0xd4>
jmp    11f9 <clock_init+0xd9>
jmp    11d9 <clock_init+0xb9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_init>:
push   %rax
andl   $0xfff0ffff,0x40023800
ff ff f0 ff
orl    $0x10000,0x40023800
nopw   0x0(%rax,%rax,1)
testl  $0x20000,0x40023800
je     1140 <clock_init+0x20>
mov    $0x40023808,%edi
mov    $0x9401,%esi
call   1030 <PUT32@plt>
mov    $0x40023c00,%edi
mov    $0x703,%esi
call   1030 <PUT32@plt>
movl   $0x5403c19,0x40023804
19 3c 40 05
orl    $0x1000000,0x40023800
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x40023800,%edi
call   1040 <GET32@plt>
test   $0x2000000,%eax
je     1190 <clock_init+0x70>
mov    $0x40023808,%edi
mov    $0x9402,%esi
call   1030 <PUT32@plt>
mov    $0x40023808,%edi
call   1040 <GET32@plt>
and    $0xc,%eax
cmp    $0x8,%eax
jne    11b0 <clock_init+0x90>
pop    %rax
ret

LLVM IR (-O0):
define void @clock_init() {
%1 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%2 = and i32 %1, -983041
store volatile i32 %2, i32* inttoptr (i64 1073887232 to i32*)
%3 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%4 = or i32 %3, 65536
store volatile i32 %4, i32* inttoptr (i64 1073887232 to i32*)
br label %5
5: ; preds = %0, %10
%6 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%7 = and i32 %6, 131072
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
br label %11
10: ; preds = %5
br label %5
11: ; preds = %9
%12 = call i32 @PUT32(i32 1073887240, i32 37889)
%13 = call i32 @PUT32(i32 1073888256, i32 1795)
store volatile i32 88095769, i32* inttoptr (i64 1073887236 to i32*)
%14 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%15 = or i32 %14, 16777216
store volatile i32 %15, i32* inttoptr (i64 1073887232 to i32*)
br label %16
16: ; preds = %11, %21
%17 = call i32 @GET32(i32 1073887232)
%18 = and i32 %17, 33554432
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %22
21: ; preds = %16
br label %16
22: ; preds = %20
%23 = call i32 @PUT32(i32 1073887240, i32 37890)
br label %24
24: ; preds = %22, %29
%25 = call i32 @GET32(i32 1073887240)
%26 = and i32 %25, 12
%27 = icmp eq i32 %26, 8
br i1 %27, label %28, label %29
28: ; preds = %24
br label %30
29: ; preds = %24
br label %24
30: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @clock_init() {
%1 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%2 = and i32 %1, -983041
store volatile i32 %2, i32* inttoptr (i64 1073887232 to i32*)
%3 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%4 = or i32 %3, 65536
store volatile i32 %4, i32* inttoptr (i64 1073887232 to i32*)
br label %5
5: ; preds = %5, %0
%6 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%7 = and i32 %6, 131072
%8 = icmp eq i32 %7, 0
br i1 %8, label %5, label %9
9: ; preds = %5
%10 = tail call i32 @PUT32(i32 1073887240, i32 37889)
%11 = tail call i32 @PUT32(i32 1073888256, i32 1795)
store volatile i32 88095769, i32* inttoptr (i64 1073887236 to i32*)
%12 = load volatile i32, i32* inttoptr (i64 1073887232 to i32*)
%13 = or i32 %12, 16777216
store volatile i32 %13, i32* inttoptr (i64 1073887232 to i32*)
br label %14
14: ; preds = %14, %9
%15 = tail call i32 @GET32(i32 1073887232)
%16 = and i32 %15, 33554432
%17 = icmp eq i32 %16, 0
br i1 %17, label %14, label %18
18: ; preds = %14
%19 = tail call i32 @PUT32(i32 1073887240, i32 37890)
br label %20
20: ; preds = %20, %18
%21 = tail call i32 @GET32(i32 1073887240)
%22 = and i32 %21, 12
%23 = icmp eq i32 %22, 8
br i1 %23, label %24, label %20
24: ; preds = %20
ret void
}