#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 uint32_t;

/* Variables and functions */
int bcm2835_read(int);
int /*<<< orphan*/ bcm2835_write(int, int);
int /*<<< orphan*/ delay(int);
uint32_t early_debug_init(void) {
  uint32_t old;
  bcm2835_write((0 + 0x201000 + 0x30), 0x0);
  old = bcm2835_read(((0 + 0x200000) + 0x04));
  old &= ~(0x7 << 12);
  old |= (4 << 12);
  old &= ~(0x7 << 15);
  old |= (4 << 15);
  bcm2835_write(((0 + 0x200000) + 0x04), old);
  bcm2835_write(((0 + 0x200000) + 0x94), 0x0);
  delay(150);
  bcm2835_write(((0 + 0x200000) + 0x98), (1 << 14) | (1 << 15));
  delay(150);
  bcm2835_write(((0 + 0x200000) + 0x98), 0x0);
  bcm2835_write((0 + 0x201000 + 0x44), 0x7FF);
  bcm2835_write((0 + 0x201000 + 0x24), 26);
  bcm2835_write((0 + 0x201000 + 0x28), 3);
  bcm2835_write((0 + 0x201000 + 0x2C), (1 << 4) | (3 << 5));
  bcm2835_write((0 + 0x201000 + 0x38), 0);
  bcm2835_write((0 + 0x201000 + 0x30), (1 << 0) | (1 << 8) | (1 << 9));
  return 0;
}


x86 assembly (clang, -O0):
<early_debug_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x201030,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x200004,%edi
call   1040 <bcm2835_read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff8fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x4000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffc7fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x20000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x200004,%edi
call   1050 <bcm2835_write@plt>
mov    $0x200094,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x96,%edi
call   1030 <delay@plt>
mov    $0x200098,%edi
mov    $0xc000,%esi
call   1050 <bcm2835_write@plt>
mov    $0x96,%edi
call   1030 <delay@plt>
mov    $0x200098,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201044,%edi
mov    $0x7ff,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201024,%edi
mov    $0x1a,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201028,%edi
mov    $0x3,%esi
call   1050 <bcm2835_write@plt>
mov    $0x20102c,%edi
mov    $0x70,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201038,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201030,%edi
mov    $0x301,%esi
call   1050 <bcm2835_write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<early_debug_init>:
push   %rax
mov    $0x201030,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x200004,%edi
call   1040 <bcm2835_read@plt>
and    $0xfffc0fff,%eax
lea    0x24000(%rax),%esi
mov    $0x200004,%edi
call   1050 <bcm2835_write@plt>
mov    $0x200094,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x96,%edi
call   1030 <delay@plt>
mov    $0x200098,%edi
mov    $0xc000,%esi
call   1050 <bcm2835_write@plt>
mov    $0x96,%edi
call   1030 <delay@plt>
mov    $0x200098,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201044,%edi
mov    $0x7ff,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201024,%edi
mov    $0x1a,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201028,%edi
mov    $0x3,%esi
call   1050 <bcm2835_write@plt>
mov    $0x20102c,%edi
mov    $0x70,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201038,%edi
xor    %esi,%esi
call   1050 <bcm2835_write@plt>
mov    $0x201030,%edi
mov    $0x301,%esi
call   1050 <bcm2835_write@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @early_debug_init() {
%1 = alloca i32
%2 = call i32 @bcm2835_write(i32 2101296, i32 0)
%3 = call i32 @bcm2835_read(i32 2097156)
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = and i32 %4, -28673
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = or i32 %6, 16384
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = and i32 %8, -229377
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = or i32 %10, 131072
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = call i32 @bcm2835_write(i32 2097156, i32 %12)
%14 = call i32 @bcm2835_write(i32 2097300, i32 0)
%15 = call i32 @delay(i32 150)
%16 = call i32 @bcm2835_write(i32 2097304, i32 49152)
%17 = call i32 @delay(i32 150)
%18 = call i32 @bcm2835_write(i32 2097304, i32 0)
%19 = call i32 @bcm2835_write(i32 2101316, i32 2047)
%20 = call i32 @bcm2835_write(i32 2101284, i32 26)
%21 = call i32 @bcm2835_write(i32 2101288, i32 3)
%22 = call i32 @bcm2835_write(i32 2101292, i32 112)
%23 = call i32 @bcm2835_write(i32 2101304, i32 0)
%24 = call i32 @bcm2835_write(i32 2101296, i32 769)
ret i32 0
}

LLVM IR (-O2):
define i32 @early_debug_init() {
%1 = tail call i32 @bcm2835_write(i32 2101296, i32 0)
%2 = tail call i32 @bcm2835_read(i32 2097156)
%3 = and i32 %2, -258049
%4 = or i32 %3, 147456
%5 = tail call i32 @bcm2835_write(i32 2097156, i32 %4)
%6 = tail call i32 @bcm2835_write(i32 2097300, i32 0)
%7 = tail call i32 @delay(i32 150)
%8 = tail call i32 @bcm2835_write(i32 2097304, i32 49152)
%9 = tail call i32 @delay(i32 150)
%10 = tail call i32 @bcm2835_write(i32 2097304, i32 0)
%11 = tail call i32 @bcm2835_write(i32 2101316, i32 2047)
%12 = tail call i32 @bcm2835_write(i32 2101284, i32 26)
%13 = tail call i32 @bcm2835_write(i32 2101288, i32 3)
%14 = tail call i32 @bcm2835_write(i32 2101292, i32 112)
%15 = tail call i32 @bcm2835_write(i32 2101304, i32 0)
%16 = tail call i32 @bcm2835_write(i32 2101296, i32 769)
ret i32 0
}