#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;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void LCDIDDDMAWrite(uint32_t ui32Base, uint32_t ui32CS,
                    const uint32_t *pui32Data, uint32_t ui32Count) {
  ASSERT(ui32Base == 0x44050000);
  ASSERT((ui32CS == 0) || (ui32CS == 1));
  ASSERT(!((uint32_t)pui32Data & 3));
  ASSERT(!(ui32Count & 1));
  (*((volatile uint32_t *)(ui32Base + 0x0000000C))) &= ~0x00000100;
  (*((volatile uint32_t *)(ui32Base + 0x00000044))) = (uint32_t)pui32Data;
  (*((volatile uint32_t *)(ui32Base + 0x00000048))) =
      ((uint32_t)pui32Data + (ui32Count * 2) - 4);
  if (!ui32CS) {
    (*((volatile uint32_t *)(ui32Base + 0x0000000C))) &= ~0x00000200;
  } else {
    (*((volatile uint32_t *)(ui32Base + 0x0000000C))) |= 0x00000200;
  }
  (*((volatile uint32_t *)(ui32Base + 0x0000000C))) |= 0x00000100;
}


x86 assembly (clang, -O0):
<LCDIDDDMAWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%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     1152 <LCDIDDDMAWrite+0x42>
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    -0x10(%rbp),%rax
and    $0x3,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    (%rax),%ecx
and    $0xfffffeff,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0x44,%eax
cltq
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    %eax,%ecx
sub    $0x4,%ecx
mov    -0x4(%rbp),%eax
add    $0x48,%eax
cltq
mov    %ecx,(%rax)
cmpl   $0x0,-0x8(%rbp)
jne    11ee <LCDIDDDMAWrite+0xde>
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    (%rax),%ecx
and    $0xfffffdff,%ecx
mov    %ecx,(%rax)
jmp    1200 <LCDIDDDMAWrite+0xf0>
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    (%rax),%ecx
or     $0x200,%ecx
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    (%rax),%ecx
or     $0x100,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCDIDDDMAWrite>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %esi,%r13d
mov    %edi,%r15d
xor    %ebx,%ebx
test   %esi,%esi
setne  %bl
mov    %ecx,%ebp
not    %ebp
xor    %edi,%edi
cmp    $0x44050000,%r15d
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x2,%r13d
setb   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
test   $0x3,%r12b
sete   %dil
call   1030 <ASSERT@plt>
and    $0x1,%ebp
mov    %ebp,%edi
call   1030 <ASSERT@plt>
movslq %r15d,%rax
andl   $0xfffffeff,0xc(%rax)
mov    %r12d,0x44(%rax)
lea    (%r12,%r14,2),%ecx
add    $0xfffffffc,%ecx
mov    %ecx,0x48(%rax)
mov    $0xfffffdff,%ecx
and    0xc(%rax),%ecx
shl    $0x9,%ebx
or     %ecx,%ebx
mov    %ebx,0xc(%rax)
orl    $0x100,0xc(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @LCDIDDDMAWrite(i32 %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1141178368
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %4
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 1
br label %18
18: ; preds = %15, %4
%19 = phi i1 [ true, %4 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
%21 = call i32 @ASSERT(i32 %20)
%22 = load i32*, i32** %7
%23 = ptrtoint i32* %22 to i32
%24 = and i32 %23, 3
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = call i32 @ASSERT(i32 %27)
%29 = load i32, i32* %8
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @ASSERT(i32 %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 12
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = load volatile i32, i32* %38
%40 = and i32 %39, -257
store volatile i32 %40, i32* %38
%41 = load i32*, i32** %7
%42 = ptrtoint i32* %41 to i32
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 68
%45 = sext i32 %44 to i64
%46 = inttoptr i64 %45 to i32*
store volatile i32 %42, i32* %46
%47 = load i32*, i32** %7
%48 = ptrtoint i32* %47 to i32
%49 = load i32, i32* %8
%50 = mul nsw i32 %49, 2
%51 = add nsw i32 %48, %50
%52 = sub nsw i32 %51, 4
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 72
%55 = sext i32 %54 to i64
%56 = inttoptr i64 %55 to i32*
store volatile i32 %52, i32* %56
%57 = load i32, i32* %6
%58 = icmp ne i32 %57, 0
br i1 %58, label %66, label %59
59: ; preds = %18
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 12
%62 = sext i32 %61 to i64
%63 = inttoptr i64 %62 to i32*
%64 = load volatile i32, i32* %63
%65 = and i32 %64, -513
store volatile i32 %65, i32* %63
br label %73
66: ; preds = %18
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 12
%69 = sext i32 %68 to i64
%70 = inttoptr i64 %69 to i32*
%71 = load volatile i32, i32* %70
%72 = or i32 %71, 512
store volatile i32 %72, i32* %70
br label %73
73: ; preds = %66, %59
%74 = load i32, i32* %5
%75 = add nsw i32 %74, 12
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i32*
%78 = load volatile i32, i32* %77
%79 = or i32 %78, 256
store volatile i32 %79, i32* %77
ret void
}

LLVM IR (-O2):
define void @LCDIDDDMAWrite(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 = ptrtoint i32* %2 to i64
%12 = trunc i64 %11 to i32
%13 = and i32 %12, 3
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @ASSERT(i32 %15)
%17 = and i32 %3, 1
%18 = xor i32 %17, 1
%19 = tail call i32 @ASSERT(i32 %18)
%20 = add nsw i32 %0, 12
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = load volatile i32, i32* %22
%24 = and i32 %23, -257
store volatile i32 %24, i32* %22
%25 = add nsw i32 %0, 68
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
store volatile i32 %12, i32* %27
%28 = shl nsw i32 %3, 1
%29 = add i32 %12, -4
%30 = add i32 %29, %28
%31 = add nsw i32 %0, 72
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
store volatile i32 %30, i32* %33
%34 = icmp eq i32 %1, 0
%35 = load volatile i32, i32* %22
%36 = and i32 %35, -513
%37 = select i1 %34, i32 0, i32 512
%38 = or i32 %36, %37
store volatile i32 %38, i32* %22
%39 = load volatile i32, i32* %22
%40 = or i32 %39, 256
store volatile i32 %40, i32* %22
ret void
}