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

/* Variables and functions */
void LCD_WriteData(uint32_t databyte, uint8_t chipnum) {
  uint32_t csmask = chipnum ? (1 << 12) : (1 << 13);
  uint32_t csmask2 = chipnum ? (1 << 13) : (1 << 12);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x18)) = csmask;
  (*(volatile unsigned long *)(0x3FFFC000 + 0x1C)) = csmask2;
  (*(volatile unsigned long *)(0x3FFFC000 + 0x20)) = 0x000000;
  (*(volatile unsigned long *)(0x3FFFC000 + 0x1C)) = (1 << 22);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x18)) = (1 << 19);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x18)) = (1 << 18);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  while ((*(volatile unsigned long *)(0x3FFFC000 + 0x34)) & 0x800000)
    ;
  ;
  (*(volatile unsigned long *)(0x3FFFC000 + 0x1C)) = (1 << 18) | (1 << 19);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x18)) = (1 << 22);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x20)) = 0xff0000;
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34)) = databyte << 16;
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x18)) = (1 << 18);
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x34));
  (*(volatile unsigned long *)(0x3FFFC000 + 0x1C)) = (1 << 18);
}


x86 assembly (clang, -O0):
<LCD_WriteData>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
mov    $0x2000,%eax
mov    $0x1000,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdx
mov    $0x1000,%eax
mov    $0x2000,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x18(%rbp)
movslq -0x14(%rbp),%rcx
mov    $0x3fffc018,%eax
mov    %rcx,(%rax)
movslq -0x18(%rbp),%rcx
mov    $0x3fffc01c,%eax
mov    %rcx,(%rax)
mov    $0x3fffc020,%eax
movq   $0x0,(%rax)
mov    $0x3fffc01c,%eax
movq   $0x400000,(%rax)
mov    $0x3fffc018,%eax
movq   $0x80000,(%rax)
mov    $0x3fffc018,%eax
movq   $0x40000,(%rax)
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
and    $0x800000,%rax
cmp    $0x0,%rax
je     11d0 <LCD_WriteData+0xd0>
jmp    11b3 <LCD_WriteData+0xb3>
mov    $0x3fffc01c,%eax
movq   $0xc0000,(%rax)
mov    $0x3fffc018,%eax
movq   $0x400000,(%rax)
mov    $0x3fffc020,%eax
movq   $0xff0000,(%rax)
mov    -0x4(%rbp),%eax
shl    $0x10,%eax
movslq %eax,%rcx
mov    $0x3fffc034,%eax
mov    %rcx,(%rax)
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc018,%eax
movq   $0x40000,(%rax)
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc034,%eax
mov    (%rax),%rax
mov    $0x3fffc01c,%eax
movq   $0x40000,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCD_WriteData>:
xor    %eax,%eax
xor    %ecx,%ecx
test   %rsi,%rsi
setne  %al
sete   %cl
shl    $0xc,%rcx
add    $0x1000,%rcx
mov    %rcx,0x3fffc018
3f
shl    $0xc,%rax
add    $0x1000,%rax
mov    %rax,0x3fffc01c
3f
movq   $0x0,0x3fffc020
movq   $0x400000,0x3fffc01c
movq   $0x80000,0x3fffc018
movq   $0x40000,0x3fffc018
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x800000,0x3fffc034
jne    11a0 <LCD_WriteData+0xa0>
movq   $0xc0000,0x3fffc01c
movq   $0x400000,0x3fffc018
movq   $0xff0000,0x3fffc020
shl    $0x10,%edi
movslq %edi,%rax
mov    %rax,0x3fffc034
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
movq   $0x40000,0x3fffc018
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
mov    0x3fffc034,%rax
3f
movq   $0x40000,0x3fffc01c
ret

LLVM IR (-O0):
define void @LCD_WriteData(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 4096, i32 8192
store i32 %10, i32* %5
%11 = load i64, i64* %4
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 8192, i32 4096
store i32 %14, i32* %6
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
store volatile i64 %16, i64* inttoptr (i64 1073725464 to i64*)
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
store volatile i64 %18, i64* inttoptr (i64 1073725468 to i64*)
store volatile i64 0, i64* inttoptr (i64 1073725472 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 1073725468 to i64*)
store volatile i64 524288, i64* inttoptr (i64 1073725464 to i64*)
store volatile i64 262144, i64* inttoptr (i64 1073725464 to i64*)
%19 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%20 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%21 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%22 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%23 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%24 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
br label %25
25: ; preds = %29, %2
%26 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%27 = and i64 %26, 8388608
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
br label %25
30: ; preds = %25
store volatile i64 786432, i64* inttoptr (i64 1073725468 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 1073725464 to i64*)
store volatile i64 16711680, i64* inttoptr (i64 1073725472 to i64*)
%31 = load i32, i32* %3
%32 = shl i32 %31, 16
%33 = sext i32 %32 to i64
store volatile i64 %33, i64* inttoptr (i64 1073725492 to i64*)
%34 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%35 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%36 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%37 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%38 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%39 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
store volatile i64 262144, i64* inttoptr (i64 1073725464 to i64*)
%40 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%41 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%42 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%43 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%44 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%45 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%46 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%47 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%48 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
store volatile i64 262144, i64* inttoptr (i64 1073725468 to i64*)
ret void
}

LLVM IR (-O2):
define void @LCD_WriteData(i32 %0, i64 %1) {
%3 = icmp eq i64 %1, 0
%4 = select i1 %3, i64 8192, i64 4096
store volatile i64 %4, i64* inttoptr (i64 1073725464 to i64*)
%5 = select i1 %3, i64 4096, i64 8192
store volatile i64 %5, i64* inttoptr (i64 1073725468 to i64*)
store volatile i64 0, i64* inttoptr (i64 1073725472 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 1073725468 to i64*)
store volatile i64 524288, i64* inttoptr (i64 1073725464 to i64*)
store volatile i64 262144, i64* inttoptr (i64 1073725464 to i64*)
%6 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%7 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%8 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%9 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%10 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%11 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
br label %12
12: ; preds = %12, %2
%13 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%14 = and i64 %13, 8388608
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %12
16: ; preds = %12
store volatile i64 786432, i64* inttoptr (i64 1073725468 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 1073725464 to i64*)
store volatile i64 16711680, i64* inttoptr (i64 1073725472 to i64*)
%17 = shl i32 %0, 16
%18 = sext i32 %17 to i64
store volatile i64 %18, i64* inttoptr (i64 1073725492 to i64*)
%19 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%20 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%21 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%22 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%23 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%24 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
store volatile i64 262144, i64* inttoptr (i64 1073725464 to i64*)
%25 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%26 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%27 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%28 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%29 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%30 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%31 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%32 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
%33 = load volatile i64, i64* inttoptr (i64 1073725492 to i64*)
store volatile i64 262144, i64* inttoptr (i64 1073725468 to i64*)
ret void
}