#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*/ HIMCI_DEBUG_FUN(char *);
unsigned int himci_readl(int);
int /*<<< orphan*/ himci_writel(unsigned int, int);
int /*<<< orphan*/ udelay(int);
void hi_mci_sys_init(unsigned int dev_num) {
  unsigned int tmp_reg;
  HIMCI_DEBUG_FUN("Function Call");
  if (dev_num == 1) {
    tmp_reg = himci_readl((0x12040000 + 0xC4));
    tmp_reg &= ~(0x3 << 2);
    tmp_reg |= (0x1 << 2);
    himci_writel(tmp_reg, (0x12040000 + 0xC4));
    tmp_reg |= (0x1 << 0);
    himci_writel(tmp_reg, (0x12040000 + 0xC4));
    udelay(1000);
    tmp_reg &= ~(0x1 << 0);
    tmp_reg |= (0x1 << 1);
    himci_writel(tmp_reg, (0x12040000 + 0xC4));
    udelay(1000);
  } else if (dev_num == 0) {
    tmp_reg = himci_readl((0x12040000 + 0x210));
    tmp_reg &= ~(0x7 << 4);
    tmp_reg |= (0x0 << 4);
    himci_writel(tmp_reg, (0x12040000 + 0x210));
    tmp_reg |= (0x1 << 0);
    himci_writel(tmp_reg, (0x12040000 + 0x210));
    udelay(1000);
    tmp_reg &= ~(0x1 << 0);
    tmp_reg |= (0x1 << 1);
    himci_writel(tmp_reg, (0x12040000 + 0x210));
    udelay(1000);
  }
}


x86 assembly (clang, -O0):
<hi_mci_sys_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeae(%rip),%rdi
call   1060 <HIMCI_DEBUG_FUN@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11db <hi_mci_sys_init+0x9b>
mov    $0x120400c4,%edi
call   1030 <himci_readl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfffffff3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x120400c4,%esi
call   1040 <himci_writel@plt>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x120400c4,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
call   1050 <udelay@plt>
mov    -0x8(%rbp),%eax
and    $0xfffffffe,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x120400c4,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
call   1050 <udelay@plt>
jmp    125f <hi_mci_sys_init+0x11f>
cmpl   $0x0,-0x4(%rbp)
jne    125a <hi_mci_sys_init+0x11a>
mov    $0x12040210,%edi
call   1030 <himci_readl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffffff8f,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x12040210,%esi
call   1040 <himci_writel@plt>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x12040210,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
call   1050 <udelay@plt>
mov    -0x8(%rbp),%eax
and    $0xfffffffe,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x12040210,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
call   1050 <udelay@plt>
jmp    125f <hi_mci_sys_init+0x11f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hi_mci_sys_init>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xeb3(%rip),%rdi
call   1060 <HIMCI_DEBUG_FUN@plt>
test   %ebx,%ebx
je     119f <hi_mci_sys_init+0x5f>
cmp    $0x1,%ebx
jne    11f9 <hi_mci_sys_init+0xb9>
mov    $0x120400c4,%r14d
mov    $0x120400c4,%edi
call   1030 <himci_readl@plt>
mov    %eax,%ebx
and    $0xfffffff3,%ebx
lea    0x4(%rbx),%edi
mov    $0x120400c4,%esi
call   1040 <himci_writel@plt>
or     $0x5,%ebx
mov    %ebx,%edi
mov    $0x120400c4,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
call   1050 <udelay@plt>
and    $0xfffffff4,%ebx
jmp    11de <hi_mci_sys_init+0x9e>
mov    $0x12040210,%r14d
mov    $0x12040210,%edi
call   1030 <himci_readl@plt>
mov    %eax,%ebx
mov    %eax,%ebp
and    $0xffffff8f,%ebp
mov    %ebp,%edi
mov    $0x12040210,%esi
call   1040 <himci_writel@plt>
or     $0x1,%ebp
mov    %ebp,%edi
mov    $0x12040210,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
call   1050 <udelay@plt>
and    $0xffffff8c,%ebx
or     $0x2,%ebx
mov    %ebx,%edi
mov    %r14d,%esi
call   1040 <himci_writel@plt>
mov    $0x3e8,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <udelay@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Function Call\00"
define void @hi_mci_sys_init(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @HIMCI_DEBUG_FUN(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %27
7: ; preds = %1
%8 = call i32 @himci_readl(i32 302252228)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = and i32 %9, -13
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = or i32 %11, 4
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @himci_writel(i32 %13, i32 302252228)
%15 = load i32, i32* %3
%16 = or i32 %15, 1
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @himci_writel(i32 %17, i32 302252228)
%19 = call i32 @udelay(i32 1000)
%20 = load i32, i32* %3
%21 = and i32 %20, -2
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = or i32 %22, 2
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 @himci_writel(i32 %24, i32 302252228)
%26 = call i32 @udelay(i32 1000)
br label %51
27: ; preds = %1
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %50
30: ; preds = %27
%31 = call i32 @himci_readl(i32 302252560)
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = and i32 %32, -113
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = or i32 %34, 0
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = call i32 @himci_writel(i32 %36, i32 302252560)
%38 = load i32, i32* %3
%39 = or i32 %38, 1
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 @himci_writel(i32 %40, i32 302252560)
%42 = call i32 @udelay(i32 1000)
%43 = load i32, i32* %3
%44 = and i32 %43, -2
store i32 %44, i32* %3
%45 = load i32, i32* %3
%46 = or i32 %45, 2
store i32 %46, i32* %3
%47 = load i32, i32* %3
%48 = call i32 @himci_writel(i32 %47, i32 302252560)
%49 = call i32 @udelay(i32 1000)
br label %50
50: ; preds = %30, %27
br label %51
51: ; preds = %50, %7
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Function Call\00"
define void @hi_mci_sys_init(i32 %0) {
%2 = tail call i32 @HIMCI_DEBUG_FUN(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
switch i32 %0, label %26 [
i32 1, label %3
i32 0, label %12
]
3: ; preds = %1
%4 = tail call i32 @himci_readl(i32 302252228)
%5 = and i32 %4, -13
%6 = or i32 %5, 4
%7 = tail call i32 @himci_writel(i32 %6, i32 302252228)
%8 = or i32 %5, 5
%9 = tail call i32 @himci_writel(i32 %8, i32 302252228)
%10 = tail call i32 @udelay(i32 1000)
%11 = and i32 %8, -12
br label %20
12: ; preds = %1
%13 = tail call i32 @himci_readl(i32 302252560)
%14 = and i32 %13, -113
%15 = tail call i32 @himci_writel(i32 %14, i32 302252560)
%16 = or i32 %14, 1
%17 = tail call i32 @himci_writel(i32 %16, i32 302252560)
%18 = tail call i32 @udelay(i32 1000)
%19 = and i32 %13, -116
br label %20
20: ; preds = %3, %12
%21 = phi i32 [ %19, %12 ], [ %11, %3 ]
%22 = phi i32 [ 302252560, %12 ], [ 302252228, %3 ]
%23 = or i32 %21, 2
%24 = tail call i32 @himci_writel(i32 %23, i32 %22)
%25 = tail call i32 @udelay(i32 1000)
br label %26
26: ; preds = %20, %1
ret void
}