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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr,
                        uint16_t ui16Data) {
  uint32_t ui32Addr;
  ASSERT(ui32Base == 0x44050000);
  ASSERT((ui32CS == 0) || (ui32CS == 1));
  ui32Addr = ui32CS ? 0x00000020 : 0x00000014;
  (*((volatile uint32_t *)(ui32Base + ui32Addr))) = ui16Addr;
  ui32Addr = ui32CS ? 0x00000024 : 0x00000018;
  (*((volatile uint32_t *)(ui32Base + ui32Addr))) = ui16Data;
}


x86 assembly (clang, -O0):
<LCDIDDIndexedWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x44050000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     1151 <LCDIDDIndexedWrite+0x41>
cmpl   $0x1,-0x8(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%edx
mov    $0x14,%eax
mov    $0x20,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
cltq
mov    %ecx,(%rax)
mov    -0x8(%rbp),%edx
mov    $0x18,%eax
mov    $0x24,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCDIDDIndexedWrite>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x44050000,%ebp
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x2,%ebx
setb   %dil
call   1030 <ASSERT@plt>
test   %ebx,%ebx
mov    $0x14,%eax
mov    $0x20,%ecx
cmove  %eax,%ecx
movslq %ebp,%rax
mov    %r15d,(%rcx,%rax,1)
mov    $0x18,%ecx
mov    $0x24,%edx
cmove  %ecx,%edx
mov    %r14d,(%rdx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @LCDIDDIndexedWrite(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 1141178368
%12 = zext i1 %11 to i32
%13 = call i32 @ASSERT(i32 %12)
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %4
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 1
br label %19
19: ; preds = %16, %4
%20 = phi i1 [ true, %4 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
%22 = call i32 @ASSERT(i32 %21)
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 32, i32 20
store i32 %26, i32* %9
%27 = load i32, i32* %7
%28 = load i32, i32* %5
%29 = load i32, i32* %9
%30 = add nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
store volatile i32 %27, i32* %32
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 36, i32 24
store i32 %36, i32* %9
%37 = load i32, i32* %8
%38 = load i32, i32* %5
%39 = load i32, i32* %9
%40 = add nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i32*
store volatile i32 %37, i32* %42
ret void
}

LLVM IR (-O2):
define void @LCDIDDIndexedWrite(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %0, 1141178368
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = icmp ult i32 %1, 2
%9 = zext i1 %8 to i32
%10 = tail call i32 @ASSERT(i32 %9)
%11 = icmp eq i32 %1, 0
%12 = select i1 %11, i32 20, i32 32
%13 = add nsw i32 %12, %0
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
store volatile i32 %2, i32* %15
%16 = select i1 %11, i32 24, i32 36
%17 = add nsw i32 %16, %0
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
store volatile i32 %3, i32* %19
ret void
}