#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 */
void driver_mfc_write_dword(uint8_t space_control, uint32_t flash_address,
                            uint32_t flash_data) {
  (*((volatile uint32_t *)(0x800000 + 0x10))) = 0XA5;
  (*((volatile uint32_t *)(0x800000 + 0x14))) = 0XC3;
  (*((volatile uint32_t *)(0x800000 + 0xC))) = flash_data;
  (*((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))) = (1 << 2);
  (*((volatile uint32_t *)(0x800000 + 0x4))) |= (space_control << 5);
  (*((volatile uint32_t *)(0x800000 + 0x4))) |= (1 << 0);
  while ((*((volatile uint32_t *)(0x800000 + 0x4))) & 0x00000001)
    ;
}


x86 assembly (clang, -O0):
<driver_mfc_write_dword>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x800010,%eax
movl   $0xa5,(%rax)
mov    $0x800014,%eax
movl   $0xc3,(%rax)
mov    -0xc(%rbp),%ecx
mov    $0x80000c,%eax
mov    %ecx,(%rax)
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   $0x4,(%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     11a1 <driver_mfc_write_dword+0xa1>
jmp    1189 <driver_mfc_write_dword+0x89>
pop    %rbp
ret

x86 assembly (clang, -O2):
<driver_mfc_write_dword>:
movl   $0xa5,0x800010
movl   $0xc3,0x800014
mov    %edx,0x80000c
lea    0x3(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
sar    $0x2,%eax
mov    %eax,0x800008
movl   $0x58a9,0x800000
movl   $0xa958,0x800000
movl   $0x4,0x800004
shl    $0x5,%edi
or     %edi,0x800004
orl    $0x1,0x800004
01
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x800004,%eax
test   $0x1,%al
jne    1170 <driver_mfc_write_dword+0x70>
ret

LLVM IR (-O0):
define void @driver_mfc_write_dword(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store volatile i32 165, i32* inttoptr (i64 8388624 to i32*)
store volatile i32 195, i32* inttoptr (i64 8388628 to i32*)
%7 = load i32, i32* %6
store volatile i32 %7, i32* inttoptr (i64 8388620 to i32*)
%8 = load i32, i32* %5
%9 = sdiv i32 %8, 4
store volatile i32 %9, 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 4, i32* inttoptr (i64 8388612 to i32*)
%10 = load i32, i32* %4
%11 = shl i32 %10, 5
%12 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%13 = or i32 %12, %11
store volatile i32 %13, i32* inttoptr (i64 8388612 to i32*)
%14 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%15 = or i32 %14, 1
store volatile i32 %15, i32* inttoptr (i64 8388612 to i32*)
br label %16
16: ; preds = %20, %3
%17 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%18 = and i32 %17, 1
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %16
21: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @driver_mfc_write_dword(i32 %0, i32 %1, i32 %2) {
store volatile i32 165, i32* inttoptr (i64 8388624 to i32*)
store volatile i32 195, i32* inttoptr (i64 8388628 to i32*)
store volatile i32 %2, i32* inttoptr (i64 8388620 to i32*)
%4 = sdiv i32 %1, 4
store volatile i32 %4, 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 4, i32* inttoptr (i64 8388612 to i32*)
%5 = shl i32 %0, 5
%6 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%7 = or i32 %6, %5
store volatile i32 %7, i32* inttoptr (i64 8388612 to i32*)
%8 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%9 = or i32 %8, 1
store volatile i32 %9, i32* inttoptr (i64 8388612 to i32*)
br label %10
10: ; preds = %10, %3
%11 = load volatile i32, i32* inttoptr (i64 8388612 to i32*)
%12 = and i32 %11, 1
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %10
14: ; preds = %10
ret void
}