#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*/ local_irq_restore(unsigned long);
int /*<<< orphan*/ local_irq_save(unsigned long);
unsigned int readl(int);
int /*<<< orphan*/ udelay(int);
int /*<<< orphan*/ wait_ms(int);
int /*<<< orphan*/ writel(unsigned int, int);
void hiusb_start_hcd(void) {
  unsigned long flags;
  unsigned int reg;
  local_irq_save(flags);
  writel(0x301, (0x1204016c));
  wait_ms(2);
  reg = readl((0x12040000 + 0x12c));
  reg |= (1 << 13);
  writel(reg, (0x12040000 + 0x12c));
  wait_ms(10);
  reg = readl((0x12040000 + 0x120));
  reg |= (1 << 11);
  writel(reg, (0x12040000 + 0x120));
  wait_ms(10);
  reg = readl((0x12040000 + 0x120));
  reg &= ~(1 << 11);
  writel(reg, (0x12040000 + 0x120));
  wait_ms(10);
  writel(0x1, (0x1204016c));
  wait_ms(2);
  reg = readl((0x12120000 + 0x12c));
  reg |= ((0x1 << 5) | (0x6 << 0) | (0x4 << 8));
  writel(reg, (0x12120000 + 0x12c));
  wait_ms(100);
  writel(0x0, (0x12120000 + 0x12c));
  wait_ms(2);
  reg = readl((0x12040000 + 0x12c));
  reg |= (1 << 13);
  reg |= (1 << 12);
  reg |= (1 << 11);
  reg |= (1 << 10);
  reg |= (1 << 9);
  reg |= (1 << 8);
  writel(reg, (0x12040000 + 0x12c));
  wait_ms(100);
  reg = readl((0x12040000 + 0x12c));
  reg &= ~((1 << 13));
  writel(reg, (0x12040000 + 0x12c));
  wait_ms(100);
  reg = readl((0x11000000) + 0xC2C0);
  reg |= (1 << 31);
  writel(reg, (0x11000000) + 0xC2C0);
  reg = readl((0x11000000) + 0xC200);
  reg &= ~(1 << 4);
  reg &= ~(1 << 3);
  reg &= ~(0x1 << 6);
  writel(reg, (0x11000000) + 0xC200);
  wait_ms(20);
  reg = readl((0x11000000) + 0xC110);
  reg &= ~((1 << 12) | (1 << 13));
  reg |= (1 << 12);
  writel(reg, (0x11000000) + 0xC110);
  writel(0x0, (0x12120000 + 0x94));
  udelay(10);
  writel(0x1820, (0x12120000 + 0x94));
  udelay(100);
  writel(0xa, (0x12120000 + 0x94));
  udelay(10);
  writel(0xbb2a, (0x12120000 + 0x94));
  udelay(100);
  reg = readl((0x11000000) + 0xC2C0);
  reg &= ~(1 << 31);
  reg &= ~(1 << 17);
  reg &= ~(0x7 << 3);
  reg |= (1 << 3);
  reg &= ~(0x3 << 1);
  reg |= (1 << 1);
  writel(reg, (0x11000000) + 0xC2C0);
  wait_ms(100);
  reg = (1 << 29) | (3 << 24) | (0x10 << 16);
  writel(reg, (0x11000000) + 0xC108);
  reg = (1 << 29) | (3 << 24) | (0x10 << 16);
  writel(reg, (0x11000000) + 0xC10C);
  wait_ms(20);
  local_irq_restore(flags);
}


x86 assembly (clang, -O0):
<hiusb_start_hcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    -0x8(%rbp),%rdi
call   1030 <local_irq_save@plt>
mov    $0x301,%edi
mov    $0x1204016c,%esi
call   1070 <writel@plt>
mov    $0x2,%edi
call   1080 <wait_ms@plt>
mov    $0x1204012c,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x2000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1204012c,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1080 <wait_ms@plt>
mov    $0x12040120,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x800,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x12040120,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1080 <wait_ms@plt>
mov    $0x12040120,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffff7ff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x12040120,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1080 <wait_ms@plt>
mov    $0x1,%edi
mov    $0x1204016c,%esi
call   1070 <writel@plt>
mov    $0x2,%edi
call   1080 <wait_ms@plt>
mov    $0x1212012c,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x426,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1212012c,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
xor    %edi,%edi
mov    $0x1212012c,%esi
call   1070 <writel@plt>
mov    $0x2,%edi
call   1080 <wait_ms@plt>
mov    $0x1204012c,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x2000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x1000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x800,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x400,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x200,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x100,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1204012c,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
mov    $0x1204012c,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffffdfff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1204012c,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
mov    $0x1100c2c0,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x80000000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1100c2c0,%esi
call   1070 <writel@plt>
mov    $0x1100c200,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffffffef,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffffff7,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffffffbf,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1100c200,%esi
call   1070 <writel@plt>
mov    $0x14,%edi
call   1080 <wait_ms@plt>
mov    $0x1100c110,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffffcfff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x1000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1100c110,%esi
call   1070 <writel@plt>
xor    %edi,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1060 <udelay@plt>
mov    $0x1820,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1060 <udelay@plt>
mov    $0xa,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1060 <udelay@plt>
mov    $0xbb2a,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1060 <udelay@plt>
mov    $0x1100c2c0,%edi
call   1040 <readl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7fffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffdffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffffffc7,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffffff9,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1100c2c0,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
movl   $0x23100000,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1100c108,%esi
call   1070 <writel@plt>
movl   $0x23100000,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1100c10c,%esi
call   1070 <writel@plt>
mov    $0x14,%edi
call   1080 <wait_ms@plt>
mov    -0x8(%rbp),%rdi
call   1050 <local_irq_restore@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hiusb_start_hcd>:
push   %rax
call   1030 <local_irq_save@plt>
mov    $0x301,%edi
mov    $0x1204016c,%esi
call   1070 <writel@plt>
mov    $0x2,%edi
call   1080 <wait_ms@plt>
mov    $0x1204012c,%edi
call   1040 <readl@plt>
or     $0x2000,%eax
mov    %eax,%edi
mov    $0x1204012c,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1080 <wait_ms@plt>
mov    $0x12040120,%edi
call   1040 <readl@plt>
or     $0x800,%eax
mov    %eax,%edi
mov    $0x12040120,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1080 <wait_ms@plt>
mov    $0x12040120,%edi
call   1040 <readl@plt>
and    $0xfffff7ff,%eax
mov    %eax,%edi
mov    $0x12040120,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1080 <wait_ms@plt>
mov    $0x1,%edi
mov    $0x1204016c,%esi
call   1070 <writel@plt>
mov    $0x2,%edi
call   1080 <wait_ms@plt>
mov    $0x1212012c,%edi
call   1040 <readl@plt>
or     $0x426,%eax
mov    %eax,%edi
mov    $0x1212012c,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
xor    %edi,%edi
mov    $0x1212012c,%esi
call   1070 <writel@plt>
mov    $0x2,%edi
call   1080 <wait_ms@plt>
mov    $0x1204012c,%edi
call   1040 <readl@plt>
or     $0x3f00,%eax
mov    %eax,%edi
mov    $0x1204012c,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
mov    $0x1204012c,%edi
call   1040 <readl@plt>
and    $0xffffdfff,%eax
mov    %eax,%edi
mov    $0x1204012c,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
mov    $0x1100c2c0,%edi
call   1040 <readl@plt>
or     $0x80000000,%eax
mov    %eax,%edi
mov    $0x1100c2c0,%esi
call   1070 <writel@plt>
mov    $0x1100c200,%edi
call   1040 <readl@plt>
and    $0xffffffa7,%eax
mov    %eax,%edi
mov    $0x1100c200,%esi
call   1070 <writel@plt>
mov    $0x14,%edi
call   1080 <wait_ms@plt>
mov    $0x1100c110,%edi
call   1040 <readl@plt>
and    $0xffffcfff,%eax
lea    0x1000(%rax),%edi
mov    $0x1100c110,%esi
call   1070 <writel@plt>
xor    %edi,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1060 <udelay@plt>
mov    $0x1820,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1060 <udelay@plt>
mov    $0xa,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0xa,%edi
call   1060 <udelay@plt>
mov    $0xbb2a,%edi
mov    $0x12120094,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1060 <udelay@plt>
mov    $0x1100c2c0,%edi
call   1040 <readl@plt>
and    $0x7ffdffc1,%eax
lea    0xa(%rax),%edi
mov    $0x1100c2c0,%esi
call   1070 <writel@plt>
mov    $0x64,%edi
call   1080 <wait_ms@plt>
mov    $0x23100000,%edi
mov    $0x1100c108,%esi
call   1070 <writel@plt>
mov    $0x23100000,%edi
mov    $0x1100c10c,%esi
call   1070 <writel@plt>
mov    $0x14,%edi
call   1080 <wait_ms@plt>
pop    %rax
jmp    1050 <local_irq_restore@plt>

LLVM IR (-O0):
define void @hiusb_start_hcd() {
%1 = alloca i64
%2 = alloca i32
%3 = load i64, i64* %1
%4 = call i32 @local_irq_save(i64 %3)
%5 = call i32 @writel(i32 769, i32 302252396)
%6 = call i32 @wait_ms(i32 2)
%7 = call i32 @readl(i32 302252332)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = or i32 %8, 8192
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 @writel(i32 %10, i32 302252332)
%12 = call i32 @wait_ms(i32 10)
%13 = call i32 @readl(i32 302252320)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = or i32 %14, 2048
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @writel(i32 %16, i32 302252320)
%18 = call i32 @wait_ms(i32 10)
%19 = call i32 @readl(i32 302252320)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = and i32 %20, -2049
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = call i32 @writel(i32 %22, i32 302252320)
%24 = call i32 @wait_ms(i32 10)
%25 = call i32 @writel(i32 1, i32 302252396)
%26 = call i32 @wait_ms(i32 2)
%27 = call i32 @readl(i32 303169836)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = or i32 %28, 1062
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = call i32 @writel(i32 %30, i32 303169836)
%32 = call i32 @wait_ms(i32 100)
%33 = call i32 @writel(i32 0, i32 303169836)
%34 = call i32 @wait_ms(i32 2)
%35 = call i32 @readl(i32 302252332)
store i32 %35, i32* %2
%36 = load i32, i32* %2
%37 = or i32 %36, 8192
store i32 %37, i32* %2
%38 = load i32, i32* %2
%39 = or i32 %38, 4096
store i32 %39, i32* %2
%40 = load i32, i32* %2
%41 = or i32 %40, 2048
store i32 %41, i32* %2
%42 = load i32, i32* %2
%43 = or i32 %42, 1024
store i32 %43, i32* %2
%44 = load i32, i32* %2
%45 = or i32 %44, 512
store i32 %45, i32* %2
%46 = load i32, i32* %2
%47 = or i32 %46, 256
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = call i32 @writel(i32 %48, i32 302252332)
%50 = call i32 @wait_ms(i32 100)
%51 = call i32 @readl(i32 302252332)
store i32 %51, i32* %2
%52 = load i32, i32* %2
%53 = and i32 %52, -8193
store i32 %53, i32* %2
%54 = load i32, i32* %2
%55 = call i32 @writel(i32 %54, i32 302252332)
%56 = call i32 @wait_ms(i32 100)
%57 = call i32 @readl(i32 285262528)
store i32 %57, i32* %2
%58 = load i32, i32* %2
%59 = or i32 %58, -2147483648
store i32 %59, i32* %2
%60 = load i32, i32* %2
%61 = call i32 @writel(i32 %60, i32 285262528)
%62 = call i32 @readl(i32 285262336)
store i32 %62, i32* %2
%63 = load i32, i32* %2
%64 = and i32 %63, -17
store i32 %64, i32* %2
%65 = load i32, i32* %2
%66 = and i32 %65, -9
store i32 %66, i32* %2
%67 = load i32, i32* %2
%68 = and i32 %67, -65
store i32 %68, i32* %2
%69 = load i32, i32* %2
%70 = call i32 @writel(i32 %69, i32 285262336)
%71 = call i32 @wait_ms(i32 20)
%72 = call i32 @readl(i32 285262096)
store i32 %72, i32* %2
%73 = load i32, i32* %2
%74 = and i32 %73, -12289
store i32 %74, i32* %2
%75 = load i32, i32* %2
%76 = or i32 %75, 4096
store i32 %76, i32* %2
%77 = load i32, i32* %2
%78 = call i32 @writel(i32 %77, i32 285262096)
%79 = call i32 @writel(i32 0, i32 303169684)
%80 = call i32 @udelay(i32 10)
%81 = call i32 @writel(i32 6176, i32 303169684)
%82 = call i32 @udelay(i32 100)
%83 = call i32 @writel(i32 10, i32 303169684)
%84 = call i32 @udelay(i32 10)
%85 = call i32 @writel(i32 47914, i32 303169684)
%86 = call i32 @udelay(i32 100)
%87 = call i32 @readl(i32 285262528)
store i32 %87, i32* %2
%88 = load i32, i32* %2
%89 = and i32 %88, 2147483647
store i32 %89, i32* %2
%90 = load i32, i32* %2
%91 = and i32 %90, -131073
store i32 %91, i32* %2
%92 = load i32, i32* %2
%93 = and i32 %92, -57
store i32 %93, i32* %2
%94 = load i32, i32* %2
%95 = or i32 %94, 8
store i32 %95, i32* %2
%96 = load i32, i32* %2
%97 = and i32 %96, -7
store i32 %97, i32* %2
%98 = load i32, i32* %2
%99 = or i32 %98, 2
store i32 %99, i32* %2
%100 = load i32, i32* %2
%101 = call i32 @writel(i32 %100, i32 285262528)
%102 = call i32 @wait_ms(i32 100)
store i32 588251136, i32* %2
%103 = load i32, i32* %2
%104 = call i32 @writel(i32 %103, i32 285262088)
store i32 588251136, i32* %2
%105 = load i32, i32* %2
%106 = call i32 @writel(i32 %105, i32 285262092)
%107 = call i32 @wait_ms(i32 20)
%108 = load i64, i64* %1
%109 = call i32 @local_irq_restore(i64 %108)
ret void
}

LLVM IR (-O2):
define void @hiusb_start_hcd() {
%1 = tail call i32 @local_irq_save(i64 undef)
%2 = tail call i32 @writel(i32 769, i32 302252396)
%3 = tail call i32 @wait_ms(i32 2)
%4 = tail call i32 @readl(i32 302252332)
%5 = or i32 %4, 8192
%6 = tail call i32 @writel(i32 %5, i32 302252332)
%7 = tail call i32 @wait_ms(i32 10)
%8 = tail call i32 @readl(i32 302252320)
%9 = or i32 %8, 2048
%10 = tail call i32 @writel(i32 %9, i32 302252320)
%11 = tail call i32 @wait_ms(i32 10)
%12 = tail call i32 @readl(i32 302252320)
%13 = and i32 %12, -2049
%14 = tail call i32 @writel(i32 %13, i32 302252320)
%15 = tail call i32 @wait_ms(i32 10)
%16 = tail call i32 @writel(i32 1, i32 302252396)
%17 = tail call i32 @wait_ms(i32 2)
%18 = tail call i32 @readl(i32 303169836)
%19 = or i32 %18, 1062
%20 = tail call i32 @writel(i32 %19, i32 303169836)
%21 = tail call i32 @wait_ms(i32 100)
%22 = tail call i32 @writel(i32 0, i32 303169836)
%23 = tail call i32 @wait_ms(i32 2)
%24 = tail call i32 @readl(i32 302252332)
%25 = or i32 %24, 16128
%26 = tail call i32 @writel(i32 %25, i32 302252332)
%27 = tail call i32 @wait_ms(i32 100)
%28 = tail call i32 @readl(i32 302252332)
%29 = and i32 %28, -8193
%30 = tail call i32 @writel(i32 %29, i32 302252332)
%31 = tail call i32 @wait_ms(i32 100)
%32 = tail call i32 @readl(i32 285262528)
%33 = or i32 %32, -2147483648
%34 = tail call i32 @writel(i32 %33, i32 285262528)
%35 = tail call i32 @readl(i32 285262336)
%36 = and i32 %35, -89
%37 = tail call i32 @writel(i32 %36, i32 285262336)
%38 = tail call i32 @wait_ms(i32 20)
%39 = tail call i32 @readl(i32 285262096)
%40 = and i32 %39, -12289
%41 = or i32 %40, 4096
%42 = tail call i32 @writel(i32 %41, i32 285262096)
%43 = tail call i32 @writel(i32 0, i32 303169684)
%44 = tail call i32 @udelay(i32 10)
%45 = tail call i32 @writel(i32 6176, i32 303169684)
%46 = tail call i32 @udelay(i32 100)
%47 = tail call i32 @writel(i32 10, i32 303169684)
%48 = tail call i32 @udelay(i32 10)
%49 = tail call i32 @writel(i32 47914, i32 303169684)
%50 = tail call i32 @udelay(i32 100)
%51 = tail call i32 @readl(i32 285262528)
%52 = and i32 %51, 2147352513
%53 = or i32 %52, 10
%54 = tail call i32 @writel(i32 %53, i32 285262528)
%55 = tail call i32 @wait_ms(i32 100)
%56 = tail call i32 @writel(i32 588251136, i32 285262088)
%57 = tail call i32 @writel(i32 588251136, i32 285262092)
%58 = tail call i32 @wait_ms(i32 20)
%59 = tail call i32 @local_irq_restore(i64 undef)
ret void
}