#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 /*<<< orphan*/ to;

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


x86 assembly (clang, -O0):
<VDP_doDMAFill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dx,%cx
mov    %si,%dx
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dx,-0x4(%rbp)
mov    %cx,-0x6(%rbp)
mov    %al,-0x7(%rbp)
movq   $0xc00004,-0x10(%rbp)
movzbl -0x6(%rbp),%eax
or     $0x9300,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movzbl -0x5(%rbp),%eax
mov    %ax,-0x6(%rbp)
movzbl -0x6(%rbp),%eax
or     $0x9400,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
movw   $0x9780,(%rax)
movq   $0xc00004,-0x18(%rbp)
movzbl -0x1(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     11af <VDP_doDMAFill+0x9f>
jmp    118d <VDP_doDMAFill+0x7d>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     11e8 <VDP_doDMAFill+0xd8>
jmp    119e <VDP_doDMAFill+0x8e>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1221 <VDP_doDMAFill+0x111>
jmp    1255 <VDP_doDMAFill+0x145>
mov    $0x1,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl -0x4(%rbp),%eax
and    $0x3fff,%eax
add    $0x4000,%eax
shl    $0x10,%eax
movzwl -0x4(%rbp),%ecx
sar    $0xe,%ecx
or     $0x80,%ecx
add    %ecx,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1255 <VDP_doDMAFill+0x145>
mov    $0x2,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl -0x4(%rbp),%eax
and    $0x3fff,%eax
add    $0xc000,%eax
shl    $0x10,%eax
movzwl -0x4(%rbp),%ecx
sar    $0xe,%ecx
or     $0x80,%ecx
add    %ecx,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1255 <VDP_doDMAFill+0x145>
mov    $0x2,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl -0x4(%rbp),%eax
and    $0x3fff,%eax
add    $0x4000,%eax
shl    $0x10,%eax
movzwl -0x4(%rbp),%ecx
sar    $0xe,%ecx
or     $0x90,%ecx
add    %ecx,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0xc00000,%eax
mov    %rax,-0x10(%rbp)
movzbl -0x7(%rbp),%eax
movzbl -0x7(%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_doDMAFill>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %esi,%ebp
movzbl %dl,%eax
or     $0x9300,%eax
mov    %ax,0xc00004
shr    $0x8,%edx
or     $0x9400,%edx
mov    %dx,0xc00004
movw   $0x9780,0xc00004
cmp    $0x2,%dil
je     1177 <VDP_doDMAFill+0x67>
cmp    $0x1,%dil
je     119b <VDP_doDMAFill+0x8b>
test   %dil,%dil
jne    11c1 <VDP_doDMAFill+0xb1>
mov    $0x1,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl %bp,%eax
mov    %eax,%ecx
shl    $0x10,%ecx
and    $0x3fff0000,%ecx
shr    $0xe,%eax
add    %ecx,%eax
add    $0x40000080,%eax
jmp    11b9 <VDP_doDMAFill+0xa9>
mov    $0x2,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl %bp,%eax
mov    %eax,%ecx
shl    $0x10,%ecx
and    $0x3fff0000,%ecx
shr    $0xe,%eax
add    %ecx,%eax
add    $0x40000090,%eax
jmp    11b9 <VDP_doDMAFill+0xa9>
mov    $0x2,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl %bp,%eax
mov    %eax,%ecx
shl    $0x10,%ecx
shr    $0xe,%eax
or     %ecx,%eax
or     $0xc0000080,%eax
cltq
mov    %rax,0xc00004
movzbl %bl,%eax
mov    %eax,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    %cx,0xc00000
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @VDP_doDMAFill(i8 zeroext %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3) {
%5 = alloca i8
%6 = alloca i16
%7 = alloca i16
%8 = alloca i8
%9 = alloca i16*
%10 = alloca i64*
store i8 %0, i8* %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i8 %3, i8* %8
store i16* inttoptr (i64 12582916 to i16*), i16** %9
%11 = load i16, i16* %7
%12 = zext i16 %11 to i32
%13 = and i32 %12, 255
%14 = add nsw i32 37632, %13
%15 = trunc i32 %14 to i16
%16 = load i16*, i16** %9
store volatile i16 %15, i16* %16
%17 = load i16, i16* %7
%18 = zext i16 %17 to i32
%19 = ashr i32 %18, 8
%20 = trunc i32 %19 to i16
store i16 %20, i16* %7
%21 = load i16, i16* %7
%22 = zext i16 %21 to i32
%23 = and i32 %22, 255
%24 = add nsw i32 37888, %23
%25 = trunc i32 %24 to i16
%26 = load i16*, i16** %9
store volatile i16 %25, i16* %26
%27 = load i16*, i16** %9
store volatile i16 -26752, i16* %27
store i64* inttoptr (i64 12582916 to i64*), i64** %10
%28 = load i8, i8* %5
%29 = zext i8 %28 to i32
switch i32 %29, label %72 [
i32 0, label %30
i32 1, label %44
i32 2, label %58
]
30: ; preds = %4
%31 = call i32 @VDP_setAutoInc(i32 1)
%32 = load i16, i16* %6
%33 = zext i16 %32 to i32
%34 = and i32 %33, 16383
%35 = add nsw i32 16384, %34
%36 = shl i32 %35, 16
%37 = load i16, i16* %6
%38 = zext i16 %37 to i32
%39 = ashr i32 %38, 14
%40 = or i32 %39, 128
%41 = add nsw i32 %36, %40
%42 = sext i32 %41 to i64
%43 = load i64*, i64** %10
store volatile i64 %42, i64* %43
br label %72
44: ; preds = %4
%45 = call i32 @VDP_setAutoInc(i32 2)
%46 = load i16, i16* %6
%47 = zext i16 %46 to i32
%48 = and i32 %47, 16383
%49 = add nsw i32 49152, %48
%50 = shl i32 %49, 16
%51 = load i16, i16* %6
%52 = zext i16 %51 to i32
%53 = ashr i32 %52, 14
%54 = or i32 %53, 128
%55 = add nsw i32 %50, %54
%56 = sext i32 %55 to i64
%57 = load i64*, i64** %10
store volatile i64 %56, i64* %57
br label %72
58: ; preds = %4
%59 = call i32 @VDP_setAutoInc(i32 2)
%60 = load i16, i16* %6
%61 = zext i16 %60 to i32
%62 = and i32 %61, 16383
%63 = add nsw i32 16384, %62
%64 = shl i32 %63, 16
%65 = load i16, i16* %6
%66 = zext i16 %65 to i32
%67 = ashr i32 %66, 14
%68 = or i32 %67, 144
%69 = add nsw i32 %64, %68
%70 = sext i32 %69 to i64
%71 = load i64*, i64** %10
store volatile i64 %70, i64* %71
br label %72
72: ; preds = %4, %58, %44, %30
store i16* inttoptr (i64 12582912 to i16*), i16** %9
%73 = load i8, i8* %8
%74 = zext i8 %73 to i32
%75 = load i8, i8* %8
%76 = zext i8 %75 to i32
%77 = shl i32 %76, 8
%78 = or i32 %74, %77
%79 = trunc i32 %78 to i16
%80 = load i16*, i16** %9
store volatile i16 %79, i16* %80
ret void
}

LLVM IR (-O2):
define void @VDP_doDMAFill(i8 zeroext %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3) {
%5 = and i16 %2, 255
%6 = or i16 %5, -27904
store volatile i16 %6, i16* inttoptr (i64 12582916 to i16*)
%7 = lshr i16 %2, 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*)
switch i8 %0, label %37 [
i8 0, label %9
i8 1, label %18
i8 2, label %26
]
9: ; preds = %4
%10 = tail call i32 @VDP_setAutoInc(i32 1)
%11 = zext i16 %1 to i32
%12 = shl nuw i32 %11, 16
%13 = and i32 %12, 1073676288
%14 = lshr i32 %11, 14
%15 = or i32 %14, %13
%16 = or i32 %15, 1073741952
%17 = zext i32 %16 to i64
br label %35
18: ; preds = %4
%19 = tail call i32 @VDP_setAutoInc(i32 2)
%20 = zext i16 %1 to i32
%21 = shl nuw i32 %20, 16
%22 = lshr i32 %20, 14
%23 = or i32 %21, %22
%24 = or i32 %23, -1073741696
%25 = sext i32 %24 to i64
br label %35
26: ; preds = %4
%27 = tail call i32 @VDP_setAutoInc(i32 2)
%28 = zext i16 %1 to i32
%29 = shl nuw i32 %28, 16
%30 = and i32 %29, 1073676288
%31 = lshr i32 %28, 14
%32 = or i32 %31, %30
%33 = or i32 %32, 1073741968
%34 = zext i32 %33 to i64
br label %35
35: ; preds = %9, %18, %26
%36 = phi i64 [ %34, %26 ], [ %25, %18 ], [ %17, %9 ]
store volatile i64 %36, i64* inttoptr (i64 12582916 to i64*)
br label %37
37: ; preds = %35, %4
%38 = zext i8 %3 to i16
%39 = mul nuw i16 %38, 257
store volatile i16 %39, i16* inttoptr (i64 12582912 to i16*)
ret void
}