#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*/ ks0108_putpixel(unsigned char, unsigned char, int);
void ks0108_putxbitmap(unsigned char posx, unsigned char posy,
                       unsigned char copy_options, unsigned char width,
                       unsigned char height, const unsigned char *xbm) {
  unsigned char x, y;
  unsigned char bit_data;
  for (x = 0; x < width; x++) {
    for (y = 0; y < height; y++) {
      bit_data = (*(xbm + (x / 8) + ((width / 8 + 1) * y))) & (1 << (x % 8));
      if (bit_data == 0)
        ks0108_putpixel(posx + x, posy + y, 1);
      else
        ks0108_putpixel(posx + x, posy + y, 0);
    }
  }
}


x86 assembly (clang, -O0):
<ks0108_putxbitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8b,%al
mov    %dil,-0x1(%rbp)
mov    %sil,-0x2(%rbp)
mov    %dl,-0x3(%rbp)
mov    %cl,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %r9,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
movzbl -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    1240 <ks0108_putxbitmap+0x130>
movb   $0x0,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
movzbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jge    122e <ks0108_putxbitmap+0x11e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movzbl -0x11(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movzbl -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
add    $0x1,%ecx
movzbl -0x12(%rbp),%edx
imul   %edx,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
movzbl -0x11(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
mov    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    %al,-0x13(%rbp)
movzbl -0x13(%rbp),%eax
cmp    $0x0,%eax
jne    11f9 <ks0108_putxbitmap+0xe9>
movzbl -0x1(%rbp),%eax
movzbl -0x11(%rbp),%ecx
add    %ecx,%eax
mov    %al,%cl
movzbl -0x2(%rbp),%eax
movzbl -0x12(%rbp),%edx
add    %edx,%eax
mov    $0x1,%edx
movzbl %cl,%edi
movzbl %al,%esi
call   1030 <ks0108_putpixel@plt>
jmp    121c <ks0108_putxbitmap+0x10c>
movzbl -0x1(%rbp),%eax
movzbl -0x11(%rbp),%ecx
add    %ecx,%eax
mov    %al,%cl
movzbl -0x2(%rbp),%eax
movzbl -0x12(%rbp),%edx
add    %edx,%eax
xor    %edx,%edx
movzbl %cl,%edi
movzbl %al,%esi
call   1030 <ks0108_putpixel@plt>
jmp    1221 <ks0108_putxbitmap+0x111>
mov    -0x12(%rbp),%al
add    $0x1,%al
mov    %al,-0x12(%rbp)
jmp    1148 <ks0108_putxbitmap+0x38>
jmp    1233 <ks0108_putxbitmap+0x123>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1134 <ks0108_putxbitmap+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ks0108_putxbitmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %r8d,0xc(%rsp)
mov    %esi,0x1c(%rsp)
mov    %rdi,0x28(%rsp)
mov    %ecx,0x8(%rsp)
test   %ecx,%ecx
je     11da <ks0108_putxbitmap+0xca>
mov    0x8(%rsp),%eax
shr    $0x3,%al
add    $0x1,%al
movzbl %al,%r14d
movzbl 0xc(%rsp),%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
jmp    1174 <ks0108_putxbitmap+0x64>
nopl   (%rax)
mov    0x10(%rsp),%rax
add    $0x1,%rax
mov    %rax,0x10(%rsp)
cmp    0x8(%rsp),%al
je     11da <ks0108_putxbitmap+0xca>
cmpb   $0x0,0xc(%rsp)
je     1160 <ks0108_putxbitmap+0x50>
mov    0x10(%rsp),%rdx
mov    %rdx,%r12
shr    $0x3,%r12
add    0x30(%rsp),%r12
mov    %edx,%ecx
and    $0x7,%cl
mov    $0x1,%r13b
shl    %cl,%r13b
mov    0x28(%rsp),%rax
lea    (%rdx,%rax,1),%ebx
mov    0x20(%rsp),%r15
mov    0x1c(%rsp),%ebp
nopl   0x0(%rax,%rax,1)
xor    %edx,%edx
movzbl (%r12),%eax
and    %r13b,%al
sete   %dl
movzbl %bl,%edi
movzbl %bpl,%ebp
mov    %ebp,%esi
call   1030 <ks0108_putpixel@plt>
add    $0x1,%bpl
add    %r14,%r12
add    $0xffffffffffffffff,%r15
jne    11b0 <ks0108_putxbitmap+0xa0>
jmp    1160 <ks0108_putxbitmap+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ks0108_putxbitmap(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4, i8* %5) {
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8*
%13 = alloca i8
%14 = alloca i8
%15 = alloca i8
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8 %3, i8* %10
store i8 %4, i8* %11
store i8* %5, i8** %12
store i8 0, i8* %13
br label %16
16: ; preds = %89, %6
%17 = load i8, i8* %13
%18 = zext i8 %17 to i32
%19 = load i8, i8* %10
%20 = zext i8 %19 to i32
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %92
22: ; preds = %16
store i8 0, i8* %14
br label %23
23: ; preds = %85, %22
%24 = load i8, i8* %14
%25 = zext i8 %24 to i32
%26 = load i8, i8* %11
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %88
29: ; preds = %23
%30 = load i8*, i8** %12
%31 = load i8, i8* %13
%32 = zext i8 %31 to i32
%33 = sdiv i32 %32, 8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
%36 = load i8, i8* %10
%37 = zext i8 %36 to i32
%38 = sdiv i32 %37, 8
%39 = add nsw i32 %38, 1
%40 = load i8, i8* %14
%41 = zext i8 %40 to i32
%42 = mul nsw i32 %39, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %35, i64 %43
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = load i8, i8* %13
%48 = zext i8 %47 to i32
%49 = srem i32 %48, 8
%50 = shl i32 1, %49
%51 = and i32 %46, %50
%52 = trunc i32 %51 to i8
store i8 %52, i8* %15
%53 = load i8, i8* %15
%54 = zext i8 %53 to i32
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %70
56: ; preds = %29
%57 = load i8, i8* %7
%58 = zext i8 %57 to i32
%59 = load i8, i8* %13
%60 = zext i8 %59 to i32
%61 = add nsw i32 %58, %60
%62 = trunc i32 %61 to i8
%63 = load i8, i8* %8
%64 = zext i8 %63 to i32
%65 = load i8, i8* %14
%66 = zext i8 %65 to i32
%67 = add nsw i32 %64, %66
%68 = trunc i32 %67 to i8
%69 = call i32 @ks0108_putpixel(i8 zeroext %62, i8 zeroext %68, i32 1)
br label %84
70: ; preds = %29
%71 = load i8, i8* %7
%72 = zext i8 %71 to i32
%73 = load i8, i8* %13
%74 = zext i8 %73 to i32
%75 = add nsw i32 %72, %74
%76 = trunc i32 %75 to i8
%77 = load i8, i8* %8
%78 = zext i8 %77 to i32
%79 = load i8, i8* %14
%80 = zext i8 %79 to i32
%81 = add nsw i32 %78, %80
%82 = trunc i32 %81 to i8
%83 = call i32 @ks0108_putpixel(i8 zeroext %76, i8 zeroext %82, i32 0)
br label %84
84: ; preds = %70, %56
br label %85
85: ; preds = %84
%86 = load i8, i8* %14
%87 = add i8 %86, 1
store i8 %87, i8* %14
br label %23
88: ; preds = %23
br label %89
89: ; preds = %88
%90 = load i8, i8* %13
%91 = add i8 %90, 1
store i8 %91, i8* %13
br label %16
92: ; preds = %16
ret void
}

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