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

/* Variables and functions */
int /*<<< orphan*/ VDP_setAutoInc(int);
void VDP_setSpriteDirect(unsigned short index, unsigned short x,
                         unsigned short y, unsigned char size,
                         unsigned short tile_attr, unsigned char link) {
  volatile unsigned long *plctrl;
  volatile unsigned short *pwdata;
  unsigned long addr;
  if (index >= 80)
    return;
  VDP_setAutoInc(2);
  addr = 0xBC00 + (index * 8);
  plctrl = (unsigned long *)0xC00004;
  pwdata = (unsigned short *)0xC00000;
  *plctrl = ((0x4000 + ((addr)&0x3FFF)) << 16) + (((addr) >> 14) | 0x00);
  *pwdata = 0x80 + y;
  *pwdata = (size << 8) | link;
  *pwdata = tile_attr;
  *pwdata = 0X80 + x;
}


x86 assembly (clang, -O0):
<VDP_setSpriteDirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r8d,-0x38(%rbp)
mov    %ecx,%eax
mov    -0x38(%rbp),%ecx
mov    %eax,-0x34(%rbp)
mov    %edx,%eax
mov    -0x34(%rbp),%edx
mov    %eax,-0x30(%rbp)
mov    %esi,%eax
mov    -0x30(%rbp),%esi
mov    %eax,-0x2c(%rbp)
mov    %edi,%r8d
mov    -0x2c(%rbp),%edi
mov    %r9b,%al
mov    %r8w,-0x2(%rbp)
mov    %di,-0x4(%rbp)
mov    %si,-0x6(%rbp)
mov    %dl,-0x7(%rbp)
mov    %cx,-0xa(%rbp)
mov    %al,-0xb(%rbp)
movzwl -0x2(%rbp),%eax
cmp    $0x50,%eax
jl     1166 <VDP_setSpriteDirect+0x56>
jmp    1208 <VDP_setSpriteDirect+0xf8>
mov    $0x2,%edi
call   1030 <VDP_setAutoInc@plt>
movzwl -0x2(%rbp),%eax
shl    $0x3,%eax
add    $0xbc00,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    $0xc00004,%eax
mov    %rax,-0x18(%rbp)
mov    $0xc00000,%eax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rcx
and    $0x3fff,%rcx
add    $0x4000,%rcx
shl    $0x10,%rcx
mov    -0x28(%rbp),%rax
shr    $0xe,%rax
or     $0x0,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movzwl -0x6(%rbp),%eax
add    $0x80,%eax
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
movzbl -0x7(%rbp),%eax
shl    $0x8,%eax
movzbl -0xb(%rbp),%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
mov    -0xa(%rbp),%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
movzwl -0x4(%rbp),%eax
add    $0x80,%eax
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VDP_setSpriteDirect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x4f,%bx
ja     118f <VDP_setSpriteDirect+0x7f>
mov    %r9d,%r15d
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %esi,%r13d
mov    $0x2,%edi
call   1030 <VDP_setAutoInc@plt>
shl    $0x13,%ebx
add    $0x3c000000,%ebx
and    $0x3ff80000,%ebx
or     $0x40000002,%rbx
mov    %rbx,0xc00004
sub    $0xffffff80,%ebp
mov    %bp,0xc00000
movzbl %r12b,%eax
shl    $0x8,%eax
movzbl %r15b,%ecx
or     %eax,%ecx
mov    %cx,0xc00000
mov    %r14w,0xc00000
sub    $0xffffff80,%r13d
mov    %r13w,0xc00000
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @VDP_setSpriteDirect(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3, i16 zeroext %4, i8 zeroext %5) {
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i8
%11 = alloca i16
%12 = alloca i8
%13 = alloca i64*
%14 = alloca i16*
%15 = alloca i64
store i16 %0, i16* %7
store i16 %1, i16* %8
store i16 %2, i16* %9
store i8 %3, i8* %10
store i16 %4, i16* %11
store i8 %5, i8* %12
%16 = load i16, i16* %7
%17 = zext i16 %16 to i32
%18 = icmp sge i32 %17, 80
br i1 %18, label %19, label %20
19: ; preds = %6
br label %56
20: ; preds = %6
%21 = call i32 @VDP_setAutoInc(i32 2)
%22 = load i16, i16* %7
%23 = zext i16 %22 to i32
%24 = mul nsw i32 %23, 8
%25 = add nsw i32 48128, %24
%26 = sext i32 %25 to i64
store i64 %26, i64* %15
store i64* inttoptr (i64 12582916 to i64*), i64** %13
store i16* inttoptr (i64 12582912 to i16*), i16** %14
%27 = load i64, i64* %15
%28 = and i64 %27, 16383
%29 = add i64 16384, %28
%30 = shl i64 %29, 16
%31 = load i64, i64* %15
%32 = lshr i64 %31, 14
%33 = or i64 %32, 0
%34 = add i64 %30, %33
%35 = load i64*, i64** %13
store volatile i64 %34, i64* %35
%36 = load i16, i16* %9
%37 = zext i16 %36 to i32
%38 = add nsw i32 128, %37
%39 = trunc i32 %38 to i16
%40 = load i16*, i16** %14
store volatile i16 %39, i16* %40
%41 = load i8, i8* %10
%42 = zext i8 %41 to i32
%43 = shl i32 %42, 8
%44 = load i8, i8* %12
%45 = zext i8 %44 to i32
%46 = or i32 %43, %45
%47 = trunc i32 %46 to i16
%48 = load i16*, i16** %14
store volatile i16 %47, i16* %48
%49 = load i16, i16* %11
%50 = load i16*, i16** %14
store volatile i16 %49, i16* %50
%51 = load i16, i16* %8
%52 = zext i16 %51 to i32
%53 = add nsw i32 128, %52
%54 = trunc i32 %53 to i16
%55 = load i16*, i16** %14
store volatile i16 %54, i16* %55
br label %56
56: ; preds = %20, %19
ret void
}

LLVM IR (-O2):
define void @VDP_setSpriteDirect(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3, i16 zeroext %4, i8 zeroext %5) {
%7 = icmp ugt i16 %0, 79
br i1 %7, label %21, label %8
8: ; preds = %6
%9 = zext i16 %0 to i64
%10 = tail call i32 @VDP_setAutoInc(i32 2)
%11 = shl nuw nsw i64 %9, 19
%12 = add nuw nsw i64 %11, 1006632960
%13 = and i64 %12, 1073217536
%14 = or i64 %13, 1073741826
store volatile i64 %14, i64* inttoptr (i64 12582916 to i64*)
%15 = add i16 %2, 128
store volatile i16 %15, i16* inttoptr (i64 12582912 to i16*)
%16 = zext i8 %3 to i16
%17 = shl nuw i16 %16, 8
%18 = zext i8 %5 to i16
%19 = or i16 %17, %18
store volatile i16 %19, i16* inttoptr (i64 12582912 to i16*)
store volatile i16 %4, i16* inttoptr (i64 12582912 to i16*)
%20 = add i16 %1, 128
store volatile i16 %20, i16* inttoptr (i64 12582912 to i16*)
br label %21
21: ; preds = %6, %8
ret void
}