#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_getPaletteColors(unsigned short, 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];
  VDP_getPaletteColors(fromcol, tmp_pal, (tocol - fromcol) + 1);
  VDP_fade(fromcol, tocol, tmp_pal, pal, numframe, async);
}


x86 assembly (clang, -O0):
<VDP_fadeTo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %r8b,%al
mov    %di,-0x2(%rbp)
mov    %si,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %cx,-0x12(%rbp)
mov    %al,-0x13(%rbp)
mov    -0x2(%rbp),%cx
lea    -0xa0(%rbp),%rsi
movzwl -0x4(%rbp),%eax
movzwl -0x2(%rbp),%edx
sub    %edx,%eax
add    $0x1,%eax
movzwl %cx,%edi
movzwl %ax,%edx
call   1040 <VDP_getPaletteColors@plt>
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    $0xa0,%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    %esi,%eax
sub    %edi,%eax
add    $0x1,%eax
movzwl %ax,%edx
mov    %rsp,%r13
mov    %r13,%rsi
call   1040 <VDP_getPaletteColors@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]
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
%12 = load i16, i16* %6
%13 = getelementptr inbounds [64 x i16], [64 x i16]* %11, i64 0, i64 0
%14 = load i16, i16* %7
%15 = zext i16 %14 to i32
%16 = load i16, i16* %6
%17 = zext i16 %16 to i32
%18 = sub nsw i32 %15, %17
%19 = add nsw i32 %18, 1
%20 = trunc i32 %19 to i16
%21 = call i32 @VDP_getPaletteColors(i16 zeroext %12, i16* %13, i16 zeroext %20)
%22 = load i16, i16* %6
%23 = load i16, i16* %7
%24 = getelementptr inbounds [64 x i16], [64 x i16]* %11, i64 0, i64 0
%25 = load i16*, i16** %8
%26 = load i16, i16* %9
%27 = load i8, i8* %10
%28 = call i32 @VDP_fade(i16 zeroext %22, i16 zeroext %23, i16* %24, i16* %25, i16 zeroext %26, i8 zeroext %27)
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 = sub i16 1, %0
%10 = add i16 %9, %1
%11 = call i32 @VDP_getPaletteColors(i16 zeroext %0, i16* %8, i16 zeroext %10)
%12 = call i32 @VDP_fade(i16 zeroext %0, i16 zeroext %1, i16* %8, i16* %2, i16 zeroext %3, i8 zeroext %4)
ret void
}