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

/* Variables and functions */
int /*<<< orphan*/ VDP_setAutoInc(int);
void VDP_doVRamDMAFill(unsigned short to, unsigned short len,
                       unsigned char value) {
  volatile unsigned short *pw;
  volatile unsigned long *pl;
  VDP_setAutoInc(1);
  pw = (unsigned short *)0xC00004;
  *pw = 0x9300 + (len & 0xff);
  *pw = 0x9400 + ((len >> 8) & 0xff);
  *pw = 0x9780;
  pl = (unsigned long *)0xC00004;
  *pl = ((0x4000 + ((to)&0x3FFF)) << 16) + (((to) >> 14) | 0x80);
  pw = (unsigned short *)0xC00000;
  *pw = value | (value << 8);
}


x86 assembly (clang, -O0):
<VDP_doVRamDMAFill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %si,%cx
mov    %di,%dx
mov    %dx,-0x2(%rbp)
mov    %cx,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    $0x1,%edi
call   1030 <VDP_setAutoInc@plt>
mov    $0xc00004,%eax
mov    %rax,-0x10(%rbp)
movzwl -0x4(%rbp),%eax
and    $0xff,%eax
add    $0x9300,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movzwl -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
add    $0x9400,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
movw   $0x9780,(%rax)
mov    $0xc00004,%eax
mov    %rax,-0x18(%rbp)
movzwl -0x2(%rbp),%eax
and    $0x3fff,%eax
add    $0x4000,%eax
shl    $0x10,%eax
movzwl -0x2(%rbp),%ecx
sar    $0xe,%ecx
or     $0x80,%ecx
add    %ecx,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0xc00000,%eax
mov    %rax,-0x10(%rbp)
movzbl -0x5(%rbp),%eax
movzbl -0x5(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VDP_doVRamDMAFill>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0x1,%edi
call   1030 <VDP_setAutoInc@plt>
movzbl %bpl,%eax
or     $0x9300,%eax
mov    %ax,0xc00004
shr    $0x8,%ebp
or     $0x9400,%ebp
mov    %bp,0xc00004
movw   $0x9780,0xc00004
mov    %ebx,%eax
shl    $0x10,%eax
and    $0x3fff0000,%eax
shr    $0xe,%ebx
add    %ebx,%eax
add    $0x40000080,%eax
mov    %rax,0xc00004
mov    %r14d,%eax
shl    $0x8,%eax
or     %r14d,%eax
mov    %ax,0xc00000
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @VDP_doVRamDMAFill(i16 zeroext %0, i16 zeroext %1, i8 zeroext %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i8
%7 = alloca i16*
%8 = alloca i64*
store i16 %0, i16* %4
store i16 %1, i16* %5
store i8 %2, i8* %6
%9 = call i32 @VDP_setAutoInc(i32 1)
store i16* inttoptr (i64 12582916 to i16*), i16** %7
%10 = load i16, i16* %5
%11 = zext i16 %10 to i32
%12 = and i32 %11, 255
%13 = add nsw i32 37632, %12
%14 = trunc i32 %13 to i16
%15 = load i16*, i16** %7
store volatile i16 %14, i16* %15
%16 = load i16, i16* %5
%17 = zext i16 %16 to i32
%18 = ashr i32 %17, 8
%19 = and i32 %18, 255
%20 = add nsw i32 37888, %19
%21 = trunc i32 %20 to i16
%22 = load i16*, i16** %7
store volatile i16 %21, i16* %22
%23 = load i16*, i16** %7
store volatile i16 -26752, i16* %23
store i64* inttoptr (i64 12582916 to i64*), i64** %8
%24 = load i16, i16* %4
%25 = zext i16 %24 to i32
%26 = and i32 %25, 16383
%27 = add nsw i32 16384, %26
%28 = shl i32 %27, 16
%29 = load i16, i16* %4
%30 = zext i16 %29 to i32
%31 = ashr i32 %30, 14
%32 = or i32 %31, 128
%33 = add nsw i32 %28, %32
%34 = sext i32 %33 to i64
%35 = load i64*, i64** %8
store volatile i64 %34, i64* %35
store i16* inttoptr (i64 12582912 to i16*), i16** %7
%36 = load i8, i8* %6
%37 = zext i8 %36 to i32
%38 = load i8, i8* %6
%39 = zext i8 %38 to i32
%40 = shl i32 %39, 8
%41 = or i32 %37, %40
%42 = trunc i32 %41 to i16
%43 = load i16*, i16** %7
store volatile i16 %42, i16* %43
ret void
}

LLVM IR (-O2):
define void @VDP_doVRamDMAFill(i16 zeroext %0, i16 zeroext %1, i8 zeroext %2) {
%4 = tail call i32 @VDP_setAutoInc(i32 1)
%5 = and i16 %1, 255
%6 = or i16 %5, -27904
store volatile i16 %6, i16* inttoptr (i64 12582916 to i16*)
%7 = lshr i16 %1, 8
%8 = or i16 %7, -27648
store volatile i16 %8, i16* inttoptr (i64 12582916 to i16*)
store volatile i16 -26752, i16* inttoptr (i64 12582916 to i16*)
%9 = zext i16 %0 to i32
%10 = shl nuw i32 %9, 16
%11 = and i32 %10, 1073676288
%12 = lshr i32 %9, 14
%13 = or i32 %12, %11
%14 = or i32 %13, 1073741952
%15 = zext i32 %14 to i64
store volatile i64 %15, i64* inttoptr (i64 12582916 to i64*)
%16 = zext i8 %2 to i16
%17 = mul nuw i16 %16, 257
store volatile i16 %17, i16* inttoptr (i64 12582912 to i16*)
ret void
}