void flash_writecommand(unsigned int flashaddress, unsigned char flashdata) {
  unsigned int datatosend;
  unsigned int flashcommand = 0xE0000000;
  datatosend = flashcommand | (flashaddress << 9) | (flashdata << 1);
  *(volatile unsigned int *)0xCC006814 = 0x000000C0;
  *(volatile unsigned int *)0xCC006824 = datatosend;
  *(volatile unsigned int *)0xCC006820 = 0x35;
  while ((*(volatile unsigned int *)0xCC006820) & 1)
    ;
  *(volatile unsigned int *)0xCC006814 = 0x000000C0;
  *(volatile unsigned int *)0xCC006820 = 0x35;
  while ((*(volatile unsigned int *)0xCC006820) & 1)
    ;
  *(volatile unsigned int *)0xCC006814 = 0x0;
}


x86 assembly (clang, -O0):
<flash_writecommand>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0xe0000000,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x9,%ecx
or     %ecx,%eax
movzbl -0x5(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    $0xcc006814,%eax
movl   $0xc0,(%rax)
mov    -0xc(%rbp),%ecx
mov    $0xcc006824,%eax
mov    %ecx,(%rax)
mov    $0xcc006820,%eax
movl   $0x35,(%rax)
mov    $0xcc006820,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1163 <flash_writecommand+0x63>
jmp    114b <flash_writecommand+0x4b>
mov    $0xcc006814,%eax
movl   $0xc0,(%rax)
mov    $0xcc006820,%eax
movl   $0x35,(%rax)
mov    $0xcc006820,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1191 <flash_writecommand+0x91>
jmp    1179 <flash_writecommand+0x79>
mov    $0xcc006814,%eax
movl   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<flash_writecommand>:
mov    $0xcc006820,%eax
shl    $0x9,%edi
lea    (%rdi,%rsi,2),%ecx
or     $0xe0000000,%ecx
movl   $0xc0,-0xc(%rax)
mov    %ecx,0x4(%rax)
movl   $0x35,(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rax),%ecx
test   $0x1,%cl
jne    1130 <flash_writecommand+0x30>
movl   $0xc0,-0xc(%rax)
movl   $0x35,(%rax)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rax),%ecx
test   $0x1,%cl
jne    1150 <flash_writecommand+0x50>
movl   $0x0,-0xc(%rax)
ret

LLVM IR (-O0):
define void @flash_writecommand(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
store i32 -536870912, i32* %6
%7 = load i32, i32* %6
%8 = load i32, i32* %3
%9 = shl i32 %8, 9
%10 = or i32 %7, %9
%11 = load i8, i8* %4
%12 = zext i8 %11 to i32
%13 = shl i32 %12, 1
%14 = or i32 %10, %13
store i32 %14, i32* %5
store volatile i32 192, i32* inttoptr (i64 3422578708 to i32*)
%15 = load i32, i32* %5
store volatile i32 %15, i32* inttoptr (i64 3422578724 to i32*)
store volatile i32 53, i32* inttoptr (i64 3422578720 to i32*)
br label %16
16: ; preds = %20, %2
%17 = load volatile i32, i32* inttoptr (i64 3422578720 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
store volatile i32 192, i32* inttoptr (i64 3422578708 to i32*)
store volatile i32 53, i32* inttoptr (i64 3422578720 to i32*)
br label %22
22: ; preds = %26, %21
%23 = load volatile i32, i32* inttoptr (i64 3422578720 to i32*)
%24 = and i32 %23, 1
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
br label %22
27: ; preds = %22
store volatile i32 0, i32* inttoptr (i64 3422578708 to i32*)
ret void
}

LLVM IR (-O2):
define void @flash_writecommand(i32 %0, i8 zeroext %1) {
%3 = shl i32 %0, 9
%4 = zext i8 %1 to i32
%5 = shl nuw nsw i32 %4, 1
%6 = or i32 %5, %3
%7 = or i32 %6, -536870912
store volatile i32 192, i32* inttoptr (i64 3422578708 to i32*)
store volatile i32 %7, i32* inttoptr (i64 3422578724 to i32*)
store volatile i32 53, i32* inttoptr (i64 3422578720 to i32*)
br label %8
8: ; preds = %8, %2
%9 = load volatile i32, i32* inttoptr (i64 3422578720 to i32*)
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %8
12: ; preds = %8
store volatile i32 192, i32* inttoptr (i64 3422578708 to i32*)
store volatile i32 53, i32* inttoptr (i64 3422578720 to i32*)
br label %13
13: ; preds = %13, %12
%14 = load volatile i32, i32* inttoptr (i64 3422578720 to i32*)
%15 = and i32 %14, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %13
17: ; preds = %13
store volatile i32 0, i32* inttoptr (i64 3422578708 to i32*)
ret void
}