#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*/ m_Sprite16(short, short, int, unsigned short *, void *,
                              void *, short);
void m_Sprite32(short x1, short y, short h, unsigned long *sprite,
                void *this_light_buff, void *this_dark_buff, short mode) {
  unsigned short dark_data_1, dark_data_2, light_data_1, light_data_2,
      temph = h;
  unsigned short left_side[2], right_side[2];
  for (; h--;) {
    dark_data_1 = (unsigned short)(*(sprite + temph) >> 16);
    dark_data_2 = (unsigned short)(*(sprite + temph));
    light_data_1 = (unsigned short)(*(sprite) >> 16);
    light_data_2 = (unsigned short)(*sprite);
    left_side[0] = light_data_1;
    left_side[1] = dark_data_1;
    right_side[0] = light_data_2;
    right_side[1] = dark_data_2;
    m_Sprite16(x1, y, 1, left_side, this_light_buff, this_dark_buff, mode);
    m_Sprite16(x1 + 16, y, 1, right_side, this_light_buff, this_dark_buff,
               mode);
    *sprite++;
    y++;
  }
}


x86 assembly (clang, -O0):
<m_Sprite32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dx,%ax
mov    %si,%dx
mov    %di,%si
mov    0x10(%rbp),%di
mov    %si,-0x2(%rbp)
mov    %dx,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0x2a(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,%cx
add    $0xffff,%cx
mov    %cx,-0x6(%rbp)
cmp    $0x0,%ax
je     123b <m_Sprite32+0x12b>
mov    -0x10(%rbp),%rax
movzwl -0x2a(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
shr    $0x10,%rax
mov    %ax,-0x22(%rbp)
mov    -0x10(%rbp),%rax
movzwl -0x2a(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %ax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
shr    $0x10,%rax
mov    %ax,-0x26(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %ax,-0x28(%rbp)
mov    -0x26(%rbp),%ax
mov    %ax,-0x2e(%rbp)
mov    -0x22(%rbp),%ax
mov    %ax,-0x2c(%rbp)
mov    -0x28(%rbp),%ax
mov    %ax,-0x32(%rbp)
mov    -0x24(%rbp),%ax
mov    %ax,-0x30(%rbp)
mov    -0x2(%rbp),%si
mov    -0x4(%rbp),%ax
lea    -0x2e(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    $0x1,%edx
movswl %si,%edi
movswl %ax,%esi
movswl 0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <m_Sprite16@plt>
movswl -0x2(%rbp),%eax
add    $0x10,%eax
mov    %ax,%si
mov    -0x4(%rbp),%ax
lea    -0x32(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    $0x1,%edx
movswl %si,%edi
movswl %ax,%esi
movswl 0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <m_Sprite16@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x4(%rbp)
jmp    1145 <m_Sprite32+0x35>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_Sprite32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,0x18(%rsp)
test   %dx,%dx
je     11f8 <m_Sprite32+0xe8>
mov    %r9,%r14
mov    %r8,%rbx
movzwl %dx,%edx
lea    0x10(%rdi),%eax
movzwl %si,%ecx
mov    %rcx,0x28(%rsp)
mov    0x18(%rsp),%rcx
mov    %rdx,0x30(%rsp)
lea    (%rcx,%rdx,8),%rcx
mov    %rcx,0x20(%rsp)
xor    %r15d,%r15d
movswl 0x70(%rsp),%r13d
movswl %di,%ecx
mov    %ecx,0x14(%rsp)
movswl %ax,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    0x28(%rsp),%rax
add    %r15d,%eax
mov    0x20(%rsp),%rcx
mov    (%rcx,%r15,8),%rcx
mov    0x18(%rsp),%rdx
mov    (%rdx,%r15,8),%rdx
mov    %dx,0xc(%rsp)
mov    %cx,0xe(%rsp)
shr    $0x10,%rcx
shr    $0x10,%rdx
mov    %dx,0x10(%rsp)
mov    %cx,0x12(%rsp)
mov    %r13d,(%rsp)
movswl %ax,%r12d
mov    0x14(%rsp),%edi
mov    %r12d,%esi
mov    $0x1,%edx
lea    0x10(%rsp),%rcx
mov    %rbx,%r8
mov    %r14,%r9
call   1030 <m_Sprite16@plt>
mov    %r13d,(%rsp)
mov    %ebp,%edi
mov    %r12d,%esi
mov    $0x1,%edx
lea    0xc(%rsp),%rcx
mov    %rbx,%r8
mov    %r14,%r9
call   1030 <m_Sprite16@plt>
add    $0x1,%r15
cmp    %r15w,0x30(%rsp)
jne    1170 <m_Sprite32+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @m_Sprite32(i16 signext %0, i16 signext %1, i16 signext %2, i64* %3, i8* %4, i8* %5, i16 signext %6) {
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
%11 = alloca i64*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i16
%15 = alloca i16
%16 = alloca i16
%17 = alloca i16
%18 = alloca i16
%19 = alloca i16
%20 = alloca [2 x i16]
%21 = alloca [2 x i16]
store i16 %0, i16* %8
store i16 %1, i16* %9
store i16 %2, i16* %10
store i64* %3, i64** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i16 %6, i16* %14
%22 = load i16, i16* %10
store i16 %22, i16* %19
br label %23
23: ; preds = %27, %7
%24 = load i16, i16* %10
%25 = add i16 %24, -1
store i16 %25, i16* %10
%26 = icmp ne i16 %24, 0
br i1 %26, label %27, label %80
27: ; preds = %23
%28 = load i64*, i64** %11
%29 = load i16, i16* %19
%30 = zext i16 %29 to i32
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i64, i64* %28, i64 %31
%33 = load i64, i64* %32
%34 = lshr i64 %33, 16
%35 = trunc i64 %34 to i16
store i16 %35, i16* %15
%36 = load i64*, i64** %11
%37 = load i16, i16* %19
%38 = zext i16 %37 to i32
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i64, i64* %36, i64 %39
%41 = load i64, i64* %40
%42 = trunc i64 %41 to i16
store i16 %42, i16* %16
%43 = load i64*, i64** %11
%44 = load i64, i64* %43
%45 = lshr i64 %44, 16
%46 = trunc i64 %45 to i16
store i16 %46, i16* %17
%47 = load i64*, i64** %11
%48 = load i64, i64* %47
%49 = trunc i64 %48 to i16
store i16 %49, i16* %18
%50 = load i16, i16* %17
%51 = getelementptr inbounds [2 x i16], [2 x i16]* %20, i64 0, i64 0
store i16 %50, i16* %51
%52 = load i16, i16* %15
%53 = getelementptr inbounds [2 x i16], [2 x i16]* %20, i64 0, i64 1
store i16 %52, i16* %53
%54 = load i16, i16* %18
%55 = getelementptr inbounds [2 x i16], [2 x i16]* %21, i64 0, i64 0
store i16 %54, i16* %55
%56 = load i16, i16* %16
%57 = getelementptr inbounds [2 x i16], [2 x i16]* %21, i64 0, i64 1
store i16 %56, i16* %57
%58 = load i16, i16* %8
%59 = load i16, i16* %9
%60 = getelementptr inbounds [2 x i16], [2 x i16]* %20, i64 0, i64 0
%61 = load i8*, i8** %12
%62 = load i8*, i8** %13
%63 = load i16, i16* %14
%64 = call i32 @m_Sprite16(i16 signext %58, i16 signext %59, i32 1, i16* %60, i8* %61, i8* %62, i16 signext %63)
%65 = load i16, i16* %8
%66 = sext i16 %65 to i32
%67 = add nsw i32 %66, 16
%68 = trunc i32 %67 to i16
%69 = load i16, i16* %9
%70 = getelementptr inbounds [2 x i16], [2 x i16]* %21, i64 0, i64 0
%71 = load i8*, i8** %12
%72 = load i8*, i8** %13
%73 = load i16, i16* %14
%74 = call i32 @m_Sprite16(i16 signext %68, i16 signext %69, i32 1, i16* %70, i8* %71, i8* %72, i16 signext %73)
%75 = load i64*, i64** %11
%76 = getelementptr inbounds i64, i64* %75, i32 1
store i64* %76, i64** %11
%77 = load i64, i64* %75
%78 = load i16, i16* %9
%79 = add i16 %78, 1
store i16 %79, i16* %9
br label %23
80: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @m_Sprite32(i16 signext %0, i16 signext %1, i16 signext %2, i64* nocapture %3, i8* %4, i8* %5, i16 signext %6) {
%8 = alloca [2 x i16]
%9 = alloca [2 x i16]
%10 = bitcast [2 x i16]* %8 to i8*
%11 = bitcast [2 x i16]* %9 to i8*
%12 = icmp eq i16 %2, 0
br i1 %12, label %39, label %13
13: ; preds = %7
%14 = zext i16 %2 to i64
%15 = getelementptr inbounds [2 x i16], [2 x i16]* %8, i64 0, i64 0
%16 = getelementptr inbounds [2 x i16], [2 x i16]* %8, i64 0, i64 1
%17 = getelementptr inbounds [2 x i16], [2 x i16]* %9, i64 0, i64 0
%18 = getelementptr inbounds [2 x i16], [2 x i16]* %9, i64 0, i64 1
%19 = add i16 %0, 16
br label %20
20: ; preds = %13, %20
%21 = phi i16 [ %1, %13 ], [ %37, %20 ]
%22 = phi i16 [ %2, %13 ], [ %24, %20 ]
%23 = phi i64* [ %3, %13 ], [ %36, %20 ]
%24 = add i16 %22, -1
%25 = getelementptr inbounds i64, i64* %23, i64 %14
%26 = load i64, i64* %25
%27 = lshr i64 %26, 16
%28 = trunc i64 %27 to i16
%29 = trunc i64 %26 to i16
%30 = load i64, i64* %23
%31 = lshr i64 %30, 16
%32 = trunc i64 %31 to i16
%33 = trunc i64 %30 to i16
store i16 %32, i16* %15
store i16 %28, i16* %16
store i16 %33, i16* %17
store i16 %29, i16* %18
%34 = call i32 @m_Sprite16(i16 signext %0, i16 signext %21, i32 1, i16* %15, i8* %4, i8* %5, i16 signext %6)
%35 = call i32 @m_Sprite16(i16 signext %19, i16 signext %21, i32 1, i16* %17, i8* %4, i8* %5, i16 signext %6)
%36 = getelementptr inbounds i64, i64* %23, i64 1
%37 = add i16 %21, 1
%38 = icmp eq i16 %24, 0
br i1 %38, label %39, label %20
39: ; preds = %20, %7
ret void
}