#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t driver_mfc_read_dword(uint8_t space_control, uint32_t flash_address) {
  (*((volatile uint32_t *)(0x800000 + 0x8))) = (flash_address / 4);
  (*((volatile uint32_t *)(0x800000 + 0x0))) = 0x58a9;
  (*((volatile uint32_t *)(0x800000 + 0x0))) = 0xa958;
  (*((volatile uint32_t *)(0x800000 + 0x4))) = (0 << 2);
  (*((volatile uint32_t *)(0x800000 + 0x4))) |= (space_control << 5);
  (*((volatile uint32_t *)(0x800000 + 0x4))) |= (1 << 0);
  while ((*((volatile uint32_t *)(0x800000 + 0x4))) & 0x00000001)
    ;
  return (*((volatile uint32_t *)(0x800000 + 0xC)));
}


x86 assembly (clang, -O0):
<driver_mfc_read_dword>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x800008,%eax
mov    %ecx,(%rax)
mov    $0x800000,%eax
movl   $0x58a9,(%rax)
mov    $0x800000,%eax
movl   $0xa958,(%rax)
mov    $0x800004,%eax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%eax
shl    $0x5,%eax
mov    $0x800004,%ecx
mov    (%rcx),%ecx
or     %eax,%ecx
mov    $0x800004,%eax
mov    %ecx,(%rax)
mov    $0x800004,%eax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    $0x800004,%eax
mov    %ecx,(%rax)
mov    $0x800004,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117e <driver_mfc_read_dword+0x7e>
jmp    1166 <driver_mfc_read_dword+0x66>
mov    $0x80000c,%eax
mov    (%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<driver_mfc_read_dword>:
lea    0x3(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
sar    $0x2,%eax
mov    %eax,0x800008
movl   $0x58a9,0x800000
movl   $0xa958,0x800000
movl   $0x0,0x800004
shl    $0x5,%edi
or     %edi,0x800004
orl    $0x1,0x800004
01
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x800004,%eax
test   $0x1,%al
jne    1150 <driver_mfc_read_dword+0x50>
mov    0x80000c,%eax
ret

LLVM IR (-O0):
define i32 @driver_mfc_read_dword(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = sdiv i32 %5, 4
store volatile i32 %6, i32* inttoptr (i64 8388616 to i32*)
store volatile i32 22697, i32* inttoptr (i64 8388608 to i32*)
store volatile i32 43352, i32* inttoptr (i64 8388608 to i32*)
store volatile i32 0, i32* inttoptr (i64 8388612 to i32*)
%7 = load i32, i32* %3
%8 = shl i32 %7, 5
%9 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%10 = or i32 %9, %8
store volatile i32 %10, i32* inttoptr (i64 8388612 to i32*)
%11 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%12 = or i32 %11, 1
store volatile i32 %12, i32* inttoptr (i64 8388612 to i32*)
br label %13
13: ; preds = %17, %2
%14 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%15 = and i32 %14, 1
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = load volatile i32, i32* inttoptr (i64 8388620 to i32*)
ret i32 %19
}

LLVM IR (-O2):
define i32 @driver_mfc_read_dword(i32 %0, i32 %1) {
%3 = sdiv i32 %1, 4
store volatile i32 %3, i32* inttoptr (i64 8388616 to i32*)
store volatile i32 22697, i32* inttoptr (i64 8388608 to i32*)
store volatile i32 43352, i32* inttoptr (i64 8388608 to i32*)
store volatile i32 0, i32* inttoptr (i64 8388612 to i32*)
%4 = shl i32 %0, 5
%5 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%6 = or i32 %5, %4
store volatile i32 %6, i32* inttoptr (i64 8388612 to i32*)
%7 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%8 = or i32 %7, 1
store volatile i32 %8, i32* inttoptr (i64 8388612 to i32*)
br label %9
9: ; preds = %9, %2
%10 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %9
13: ; preds = %9
%14 = load volatile i32, i32* inttoptr (i64 8388620 to i32*)
ret i32 %14
}