#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 */
struct fb {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fb_putPixel_8(struct fb *, int, int, unsigned char);
void fb_drawPixel_rgb332(struct fb *self, int x, int y, int r, int g, int b) {
  unsigned char t;
  if ((r == 0) && (g == 0) && (b == 255))
    t = 0;
  else if ((r == 255) && (g == 255) && (b == 255))
    t = 1;
  else
    t = (40 + (r / 43) * 36 + (g / 43) * 6 + (b / 43) * 1);
  fb_putPixel_8(self, x, y, t);
}


x86 assembly (clang, -O0):
<fb_drawPixel_rgb332>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1157 <fb_drawPixel_rgb332+0x47>
cmpl   $0x0,-0x18(%rbp)
jne    1157 <fb_drawPixel_rgb332+0x47>
cmpl   $0xff,-0x1c(%rbp)
jne    1157 <fb_drawPixel_rgb332+0x47>
movb   $0x0,-0x1d(%rbp)
jmp    11d0 <fb_drawPixel_rgb332+0xc0>
cmpl   $0xff,-0x14(%rbp)
jne    1187 <fb_drawPixel_rgb332+0x77>
cmpl   $0xff,-0x18(%rbp)
jne    1187 <fb_drawPixel_rgb332+0x77>
cmpl   $0xff,-0x1c(%rbp)
jne    1187 <fb_drawPixel_rgb332+0x77>
movb   $0x1,-0x1d(%rbp)
jmp    11cb <fb_drawPixel_rgb332+0xbb>
mov    -0x14(%rbp),%eax
mov    $0x2b,%ecx
cltd
idiv   %ecx
imul   $0x24,%eax,%eax
add    $0x28,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2b,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   $0x6,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2b,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
shl    $0x0,%ecx
add    %ecx,%eax
mov    %al,-0x1d(%rbp)
jmp    11d0 <fb_drawPixel_rgb332+0xc0>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movzbl -0x1d(%rbp),%ecx
call   1030 <fb_putPixel_8@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_drawPixel_rgb332>:
mov    %r8d,%eax
or     %ecx,%eax
jne    112a <fb_drawPixel_rgb332+0x1a>
cmp    $0xff,%r9d
jne    112a <fb_drawPixel_rgb332+0x1a>
xor    %eax,%eax
movzbl %al,%ecx
jmp    1030 <fb_putPixel_8@plt>
cmp    $0xff,%ecx
jne    114e <fb_drawPixel_rgb332+0x3e>
cmp    $0xff,%r8d
jne    114e <fb_drawPixel_rgb332+0x3e>
mov    $0x1,%al
cmp    $0xff,%r9d
jne    114e <fb_drawPixel_rgb332+0x3e>
movzbl %al,%ecx
jmp    1030 <fb_putPixel_8@plt>
movslq %ecx,%rax
imul   $0x2fa0be83,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%r10d
movslq %r8d,%rcx
imul   $0x2fa0be83,%rcx,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x23,%rcx
add    %eax,%ecx
lea    (%rcx,%rcx,2),%eax
add    %eax,%eax
lea    (%rax,%r10,4),%r8d
movslq %r9d,%rax
imul   $0x2fa0be83,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x23,%rax
add    %ecx,%eax
add    %r8d,%eax
add    $0x28,%al
movzbl %al,%ecx
jmp    1030 <fb_putPixel_8@plt>

LLVM IR (-O0):
%struct.fb = type { i32 }
define void @fb_drawPixel_rgb332(%struct.fb* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %struct.fb*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store %struct.fb* %0, %struct.fb** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %10
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %6
%17 = load i32, i32* %11
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %12
%21 = icmp eq i32 %20, 255
br i1 %21, label %22, label %23
22: ; preds = %19
store i8 0, i8* %13
br label %48
23: ; preds = %19, %16, %6
%24 = load i32, i32* %10
%25 = icmp eq i32 %24, 255
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* %11
%28 = icmp eq i32 %27, 255
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %12
%31 = icmp eq i32 %30, 255
br i1 %31, label %32, label %33
32: ; preds = %29
store i8 1, i8* %13
br label %47
33: ; preds = %29, %26, %23
%34 = load i32, i32* %10
%35 = sdiv i32 %34, 43
%36 = mul nsw i32 %35, 36
%37 = add nsw i32 40, %36
%38 = load i32, i32* %11
%39 = sdiv i32 %38, 43
%40 = mul nsw i32 %39, 6
%41 = add nsw i32 %37, %40
%42 = load i32, i32* %12
%43 = sdiv i32 %42, 43
%44 = mul nsw i32 %43, 1
%45 = add nsw i32 %41, %44
%46 = trunc i32 %45 to i8
store i8 %46, i8* %13
br label %47
47: ; preds = %33, %32
br label %48
48: ; preds = %47, %22
%49 = load %struct.fb*, %struct.fb** %7
%50 = load i32, i32* %8
%51 = load i32, i32* %9
%52 = load i8, i8* %13
%53 = call i32 @fb_putPixel_8(%struct.fb* %49, i32 %50, i32 %51, i8 zeroext %52)
ret void
}

LLVM IR (-O2):
%struct.fb = type { i32 }
define void @fb_drawPixel_rgb332(%struct.fb* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = or i32 %4, %3
%8 = icmp eq i32 %7, 0
%9 = icmp eq i32 %5, 255
%10 = and i1 %8, %9
br i1 %10, label %26, label %11
11: ; preds = %6
%12 = icmp eq i32 %3, 255
%13 = icmp eq i32 %4, 255
%14 = and i1 %12, %13
%15 = and i1 %14, %9
br i1 %15, label %26, label %16
16: ; preds = %11
%17 = sdiv i32 %3, 43
%18 = mul nsw i32 %17, 36
%19 = add nsw i32 %18, 40
%20 = sdiv i32 %4, 43
%21 = mul nsw i32 %20, 6
%22 = add nsw i32 %19, %21
%23 = sdiv i32 %5, 43
%24 = add nsw i32 %22, %23
%25 = trunc i32 %24 to i8
br label %26
26: ; preds = %11, %6, %16
%27 = phi i8 [ %25, %16 ], [ 0, %6 ], [ 1, %11 ]
%28 = tail call i32 @fb_putPixel_8(%struct.fb* %0, i32 %1, i32 %2, i8 zeroext %27)
ret void
}