#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 */

/* Variables and functions */
int /*<<< orphan*/ VDP_fade(unsigned short, unsigned short, unsigned short *,
                            unsigned short const *, unsigned short,
                            unsigned char);
int /*<<< orphan*/ VDP_getPalette(unsigned short, unsigned short *);
void VDP_fadeTo(unsigned short fromcol, unsigned short tocol,
                const unsigned short *pal, unsigned short numframe,
                unsigned char async) {
  unsigned short tmp_pal[64];
  unsigned short i;
  for (i = 0; i < 4; i++)
    VDP_getPalette(i, &tmp_pal[i << 4]);
  VDP_fade(fromcol, tocol, tmp_pal, pal, numframe, async);
}


x86 assembly (clang, -O0):
<VDP_fadeTo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %r8b,%al
mov    %di,-0x2(%rbp)
mov    %si,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %cx,-0x12(%rbp)
mov    %al,-0x13(%rbp)
movw   $0x0,-0xa2(%rbp)
movzwl -0xa2(%rbp),%eax
cmp    $0x4,%eax
jge    119b <VDP_fadeTo+0x7b>
mov    -0xa2(%rbp),%ax
movzwl -0xa2(%rbp),%ecx
shl    $0x4,%ecx
movslq %ecx,%rcx
lea    -0xa0(%rbp),%rsi
shl    $0x1,%rcx
add    %rcx,%rsi
movzwl %ax,%edi
call   1040 <VDP_getPalette@plt>
mov    -0xa2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa2(%rbp)
jmp    114a <VDP_fadeTo+0x2a>
mov    -0x2(%rbp),%di
mov    -0x4(%rbp),%si
lea    -0xa0(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x12(%rbp),%ax
movzwl %di,%edi
movzwl %si,%esi
movzwl %ax,%r8d
movzbl -0x13(%rbp),%r9d
call   1030 <VDP_fade@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VDP_fadeTo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%r13
xor    %edi,%edi
mov    %r13,%rsi
call   1040 <VDP_getPalette@plt>
lea    0x20(%rsp),%rsi
mov    $0x1,%edi
call   1040 <VDP_getPalette@plt>
lea    0x40(%rsp),%rsi
mov    $0x2,%edi
call   1040 <VDP_getPalette@plt>
lea    0x60(%rsp),%rsi
mov    $0x3,%edi
call   1040 <VDP_getPalette@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1030 <VDP_fade@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @VDP_fadeTo(i16 zeroext %0, i16 zeroext %1, i16* %2, i16 zeroext %3, i8 zeroext %4) {
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16*
%9 = alloca i16
%10 = alloca i8
%11 = alloca [64 x i16]
%12 = alloca i16
store i16 %0, i16* %6
store i16 %1, i16* %7
store i16* %2, i16** %8
store i16 %3, i16* %9
store i8 %4, i8* %10
store i16 0, i16* %12
br label %13
13: ; preds = %25, %5
%14 = load i16, i16* %12
%15 = zext i16 %14 to i32
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i16, i16* %12
%19 = load i16, i16* %12
%20 = zext i16 %19 to i32
%21 = shl i32 %20, 4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [64 x i16], [64 x i16]* %11, i64 0, i64 %22
%24 = call i32 @VDP_getPalette(i16 zeroext %18, i16* %23)
br label %25
25: ; preds = %17
%26 = load i16, i16* %12
%27 = add i16 %26, 1
store i16 %27, i16* %12
br label %13
28: ; preds = %13
%29 = load i16, i16* %6
%30 = load i16, i16* %7
%31 = getelementptr inbounds [64 x i16], [64 x i16]* %11, i64 0, i64 0
%32 = load i16*, i16** %8
%33 = load i16, i16* %9
%34 = load i8, i8* %10
%35 = call i32 @VDP_fade(i16 zeroext %29, i16 zeroext %30, i16* %31, i16* %32, i16 zeroext %33, i8 zeroext %34)
ret void
}

LLVM IR (-O2):
define void @VDP_fadeTo(i16 zeroext %0, i16 zeroext %1, i16* %2, i16 zeroext %3, i8 zeroext %4) {
%6 = alloca [64 x i16]
%7 = bitcast [64 x i16]* %6 to i8*
%8 = getelementptr inbounds [64 x i16], [64 x i16]* %6, i64 0, i64 0
%9 = call i32 @VDP_getPalette(i16 zeroext 0, i16* %8)
%10 = getelementptr inbounds [64 x i16], [64 x i16]* %6, i64 0, i64 16
%11 = call i32 @VDP_getPalette(i16 zeroext 1, i16* %10)
%12 = getelementptr inbounds [64 x i16], [64 x i16]* %6, i64 0, i64 32
%13 = call i32 @VDP_getPalette(i16 zeroext 2, i16* %12)
%14 = getelementptr inbounds [64 x i16], [64 x i16]* %6, i64 0, i64 48
%15 = call i32 @VDP_getPalette(i16 zeroext 3, i16* %14)
%16 = call i32 @VDP_fade(i16 zeroext %0, i16 zeroext %1, i16* %8, i16* %2, i16 zeroext %3, i8 zeroext %4)
ret void
}