#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*/ WRITE_FB32(unsigned long, unsigned long);
void gfx_set_icon_shape64(unsigned long memoffset, unsigned long *andmask,
                          unsigned long *xormask, unsigned int lines) {
  unsigned short i, height;
  height = lines << 1;
  for (i = 0; i < height; i += 2) {
    WRITE_FB32(memoffset, andmask[i + 1]);
    WRITE_FB32(memoffset + 4, andmask[i]);
    WRITE_FB32(memoffset + 8, xormask[i + 1]);
    WRITE_FB32(memoffset + 12, xormask[i]);
    memoffset += 16;
  }
}


x86 assembly (clang, -O0):
<gfx_set_icon_shape64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %ax,-0x20(%rbp)
movw   $0x0,-0x1e(%rbp)
movzwl -0x1e(%rbp),%eax
movzwl -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    11cf <gfx_set_icon_shape64+0xbf>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movzwl -0x1e(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <WRITE_FB32@plt>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
mov    -0x10(%rbp),%rax
movzwl -0x1e(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
call   1030 <WRITE_FB32@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0x18(%rbp),%rax
movzwl -0x1e(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <WRITE_FB32@plt>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
mov    -0x18(%rbp),%rax
movzwl -0x1e(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
call   1030 <WRITE_FB32@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x8(%rbp)
movzwl -0x1e(%rbp),%eax
add    $0x2,%eax
mov    %ax,-0x1e(%rbp)
jmp    1137 <gfx_set_icon_shape64+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfx_set_icon_shape64>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
add    %ecx,%r14d
and    $0xffff,%r14d
je     1182 <gfx_set_icon_shape64+0x72>
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%r12,%rbp,8),%rsi
mov    %rbx,%rdi
call   1030 <WRITE_FB32@plt>
lea    0x4(%rbx),%rdi
mov    (%r12,%rbp,8),%rsi
call   1030 <WRITE_FB32@plt>
mov    0x8(%r15,%rbp,8),%rsi
lea    0x8(%rbx),%rdi
call   1030 <WRITE_FB32@plt>
mov    (%r15,%rbp,8),%rsi
lea    0xc(%rbx),%rdi
call   1030 <WRITE_FB32@plt>
add    $0x2,%rbp
add    $0x10,%rbx
cmp    %ebp,%r14d
ja     1140 <gfx_set_icon_shape64+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gfx_set_icon_shape64(i64 %0, i64* %1, i64* %2, i32 %3) {
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i16
%10 = alloca i16
store i64 %0, i64* %5
store i64* %1, i64** %6
store i64* %2, i64** %7
store i32 %3, i32* %8
%11 = load i32, i32* %8
%12 = shl i32 %11, 1
%13 = trunc i32 %12 to i16
store i16 %13, i16* %10
store i16 0, i16* %9
br label %14
14: ; preds = %58, %4
%15 = load i16, i16* %9
%16 = zext i16 %15 to i32
%17 = load i16, i16* %10
%18 = zext i16 %17 to i32
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %63
20: ; preds = %14
%21 = load i64, i64* %5
%22 = load i64*, i64** %6
%23 = load i16, i16* %9
%24 = zext i16 %23 to i32
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i64, i64* %22, i64 %26
%28 = load i64, i64* %27
%29 = call i32 @WRITE_FB32(i64 %21, i64 %28)
%30 = load i64, i64* %5
%31 = add i64 %30, 4
%32 = load i64*, i64** %6
%33 = load i16, i16* %9
%34 = zext i16 %33 to i64
%35 = getelementptr inbounds i64, i64* %32, i64 %34
%36 = load i64, i64* %35
%37 = call i32 @WRITE_FB32(i64 %31, i64 %36)
%38 = load i64, i64* %5
%39 = add i64 %38, 8
%40 = load i64*, i64** %7
%41 = load i16, i16* %9
%42 = zext i16 %41 to i32
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i64, i64* %40, i64 %44
%46 = load i64, i64* %45
%47 = call i32 @WRITE_FB32(i64 %39, i64 %46)
%48 = load i64, i64* %5
%49 = add i64 %48, 12
%50 = load i64*, i64** %7
%51 = load i16, i16* %9
%52 = zext i16 %51 to i64
%53 = getelementptr inbounds i64, i64* %50, i64 %52
%54 = load i64, i64* %53
%55 = call i32 @WRITE_FB32(i64 %49, i64 %54)
%56 = load i64, i64* %5
%57 = add i64 %56, 16
store i64 %57, i64* %5
br label %58
58: ; preds = %20
%59 = load i16, i16* %9
%60 = zext i16 %59 to i32
%61 = add nsw i32 %60, 2
%62 = trunc i32 %61 to i16
store i16 %62, i16* %9
br label %14
63: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @gfx_set_icon_shape64(i64 %0, i64* nocapture %1, i64* nocapture %2, i32 %3) {
%5 = shl i32 %3, 1
%6 = and i32 %5, 65534
%7 = icmp eq i32 %6, 0
br i1 %7, label %31, label %8
8: ; preds = %4, %8
%9 = phi i64 [ %28, %8 ], [ 0, %4 ]
%10 = phi i64 [ %27, %8 ], [ %0, %4 ]
%11 = or i64 %9, 1
%12 = getelementptr inbounds i64, i64* %1, i64 %11
%13 = load i64, i64* %12
%14 = tail call i32 @WRITE_FB32(i64 %10, i64 %13)
%15 = add i64 %10, 4
%16 = getelementptr inbounds i64, i64* %1, i64 %9
%17 = load i64, i64* %16
%18 = tail call i32 @WRITE_FB32(i64 %15, i64 %17)
%19 = add i64 %10, 8
%20 = getelementptr inbounds i64, i64* %2, i64 %11
%21 = load i64, i64* %20
%22 = tail call i32 @WRITE_FB32(i64 %19, i64 %21)
%23 = add i64 %10, 12
%24 = getelementptr inbounds i64, i64* %2, i64 %9
%25 = load i64, i64* %24
%26 = tail call i32 @WRITE_FB32(i64 %23, i64 %25)
%27 = add i64 %10, 16
%28 = add nuw nsw i64 %9, 2
%29 = trunc i64 %28 to i32
%30 = icmp ugt i32 %6, %29
br i1 %30, label %8, label %31
31: ; preds = %8, %4
ret void
}