#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_doVRamDMACopy(unsigned short from, unsigned short to,
                       unsigned short len) {
  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 = 0x9500 + (from & 0xff);
  *pw = 0x9600 + ((from >> 8) & 0xff);
  *pw = 0x97C0;
  pl = (unsigned long *)0xC00004;
  *pl = ((0x4000 + ((to)&0x3FFF)) << 16) + (((to) >> 14) | 0x80);
}


x86 assembly (clang, -O0):
<VDP_doVRamDMACopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %di,%dx
mov    %dx,-0x2(%rbp)
mov    %cx,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    $0x1,%edi
call   1030 <VDP_setAutoInc@plt>
mov    $0xc00004,%eax
mov    %rax,-0x10(%rbp)
movzwl -0x6(%rbp),%eax
and    $0xff,%eax
add    $0x9300,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movzwl -0x6(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
add    $0x9400,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movzwl -0x2(%rbp),%eax
and    $0xff,%eax
add    $0x9500,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
add    $0x9600,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
movw   $0x97c0,(%rax)
mov    $0xc00004,%eax
mov    %rax,-0x18(%rbp)
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)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VDP_doVRamDMACopy>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
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
movzbl %bl,%eax
or     $0x9500,%eax
mov    %ax,0xc00004
shr    $0x8,%ebx
or     $0x9600,%ebx
mov    %bx,0xc00004
movw   $0x97c0,0xc00004
mov    %r14d,%eax
shl    $0x10,%eax
and    $0x3fff0000,%eax
shr    $0xe,%r14d
add    %r14d,%eax
add    $0x40000080,%eax
mov    %rax,0xc00004
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @VDP_doVRamDMACopy(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16*
%8 = alloca i64*
store i16 %0, i16* %4
store i16 %1, i16* %5
store i16 %2, i16* %6
%9 = call i32 @VDP_setAutoInc(i32 1)
store i16* inttoptr (i64 12582916 to i16*), i16** %7
%10 = load i16, i16* %6
%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* %6
%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* %4
%24 = zext i16 %23 to i32
%25 = and i32 %24, 255
%26 = add nsw i32 38144, %25
%27 = trunc i32 %26 to i16
%28 = load i16*, i16** %7
store volatile i16 %27, i16* %28
%29 = load i16, i16* %4
%30 = zext i16 %29 to i32
%31 = ashr i32 %30, 8
%32 = and i32 %31, 255
%33 = add nsw i32 38400, %32
%34 = trunc i32 %33 to i16
%35 = load i16*, i16** %7
store volatile i16 %34, i16* %35
%36 = load i16*, i16** %7
store volatile i16 -26688, i16* %36
store i64* inttoptr (i64 12582916 to i64*), i64** %8
%37 = load i16, i16* %5
%38 = zext i16 %37 to i32
%39 = and i32 %38, 16383
%40 = add nsw i32 16384, %39
%41 = shl i32 %40, 16
%42 = load i16, i16* %5
%43 = zext i16 %42 to i32
%44 = ashr i32 %43, 14
%45 = or i32 %44, 128
%46 = add nsw i32 %41, %45
%47 = sext i32 %46 to i64
%48 = load i64*, i64** %8
store volatile i64 %47, i64* %48
ret void
}

LLVM IR (-O2):
define void @VDP_doVRamDMACopy(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = tail call i32 @VDP_setAutoInc(i32 1)
%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*)
%9 = and i16 %0, 255
%10 = or i16 %9, -27392
store volatile i16 %10, i16* inttoptr (i64 12582916 to i16*)
%11 = lshr i16 %0, 8
%12 = or i16 %11, -27136
store volatile i16 %12, i16* inttoptr (i64 12582916 to i16*)
store volatile i16 -26688, i16* inttoptr (i64 12582916 to i16*)
%13 = zext i16 %1 to i32
%14 = shl nuw i32 %13, 16
%15 = and i32 %14, 1073676288
%16 = lshr i32 %13, 14
%17 = or i32 %16, %15
%18 = or i32 %17, 1073741952
%19 = zext i32 %18 to i64
store volatile i64 %19, i64* inttoptr (i64 12582916 to i64*)
ret void
}