#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_byte(int, char);
void draw_color(int offset, int screen, char r, char g, char b) {
  if (screen & 1) {
    write_byte(offset + 0x20184E60, b);
    write_byte(offset + 0x20184E60 + 1, g);
    write_byte(offset + 0x20184E60 + 2, r);
    write_byte(offset + 0x201CB370, b);
    write_byte(offset + 0x201CB370 + 1, g);
    write_byte(offset + 0x201CB370 + 2, r);
    write_byte(offset + 0x20282160, b);
    write_byte(offset + 0x20282160 + 1, g);
    write_byte(offset + 0x20282160 + 2, r);
    write_byte(offset + 0x202C8670, b);
    write_byte(offset + 0x202C8670 + 1, g);
    write_byte(offset + 0x202C8670 + 2, r);
  }
  if (screen & 2) {
    write_byte(offset + 0x202118E0, b);
    write_byte(offset + 0x202118E0 + 1, g);
    write_byte(offset + 0x202118E0 + 2, r);
    write_byte(offset + 0X20249CF0, b);
    write_byte(offset + 0X20249CF0 + 1, g);
    write_byte(offset + 0X20249CF0 + 2, r);
  }
}


x86 assembly (clang, -O0):
<draw_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %r8b,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %cl,-0xa(%rbp)
mov    %al,-0xb(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1229 <draw_color+0x119>
mov    -0x4(%rbp),%edi
add    $0x20184e60,%edi
movsbl -0xb(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20184e60,%edi
add    $0x1,%edi
movsbl -0xa(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20184e60,%edi
add    $0x2,%edi
movsbl -0x9(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x201cb370,%edi
movsbl -0xb(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x201cb370,%edi
add    $0x1,%edi
movsbl -0xa(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x201cb370,%edi
add    $0x2,%edi
movsbl -0x9(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20282160,%edi
movsbl -0xb(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20282160,%edi
add    $0x1,%edi
movsbl -0xa(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20282160,%edi
add    $0x2,%edi
movsbl -0x9(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x202c8670,%edi
movsbl -0xb(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x202c8670,%edi
add    $0x1,%edi
movsbl -0xa(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x202c8670,%edi
add    $0x2,%edi
movsbl -0x9(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     12b0 <draw_color+0x1a0>
mov    -0x4(%rbp),%edi
add    $0x202118e0,%edi
movsbl -0xb(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x202118e0,%edi
add    $0x1,%edi
movsbl -0xa(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x202118e0,%edi
add    $0x2,%edi
movsbl -0x9(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20249cf0,%edi
movsbl -0xb(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20249cf0,%edi
add    $0x1,%edi
movsbl -0xa(%rbp),%esi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
add    $0x20249cf0,%edi
add    $0x2,%edi
movsbl -0x9(%rbp),%esi
call   1030 <write_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_color>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %edi,%ebx
movsbl %r8b,%ebp
movsbl %cl,%r15d
movsbl %dl,%r14d
test   $0x1,%r12b
je     11d7 <draw_color+0xc7>
lea    0x20184e60(%rbx),%edi
mov    %ebp,%esi
call   1030 <write_byte@plt>
lea    0x20184e61(%rbx),%edi
mov    %r15d,%esi
call   1030 <write_byte@plt>
lea    0x20184e62(%rbx),%edi
mov    %r14d,%esi
call   1030 <write_byte@plt>
lea    0x201cb370(%rbx),%edi
mov    %ebp,%esi
call   1030 <write_byte@plt>
lea    0x201cb371(%rbx),%edi
mov    %r15d,%esi
call   1030 <write_byte@plt>
lea    0x201cb372(%rbx),%edi
mov    %r14d,%esi
call   1030 <write_byte@plt>
lea    0x20282160(%rbx),%edi
mov    %ebp,%esi
call   1030 <write_byte@plt>
lea    0x20282161(%rbx),%edi
mov    %r15d,%esi
call   1030 <write_byte@plt>
lea    0x20282162(%rbx),%edi
mov    %r14d,%esi
call   1030 <write_byte@plt>
lea    0x202c8670(%rbx),%edi
mov    %ebp,%esi
call   1030 <write_byte@plt>
lea    0x202c8671(%rbx),%edi
mov    %r15d,%esi
call   1030 <write_byte@plt>
lea    0x202c8672(%rbx),%edi
mov    %r14d,%esi
call   1030 <write_byte@plt>
test   $0x2,%r12b
jne    11e6 <draw_color+0xd6>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x202118e0(%rbx),%edi
mov    %ebp,%esi
call   1030 <write_byte@plt>
lea    0x202118e1(%rbx),%edi
mov    %r15d,%esi
call   1030 <write_byte@plt>
lea    0x202118e2(%rbx),%edi
mov    %r14d,%esi
call   1030 <write_byte@plt>
lea    0x20249cf0(%rbx),%edi
mov    %ebp,%esi
call   1030 <write_byte@plt>
lea    0x20249cf1(%rbx),%edi
mov    %r15d,%esi
call   1030 <write_byte@plt>
add    $0x20249cf2,%ebx
mov    %ebx,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write_byte@plt>

LLVM IR (-O0):
define void @draw_color(i32 %0, i32 %1, i8 signext %2, i8 signext %3, i8 signext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8 %2, i8* %8
store i8 %3, i8* %9
store i8 %4, i8* %10
%11 = load i32, i32* %7
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %71
14: ; preds = %5
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 538463840
%17 = load i8, i8* %10
%18 = call i32 @write_byte(i32 %16, i8 signext %17)
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 538463840
%21 = add nsw i32 %20, 1
%22 = load i8, i8* %9
%23 = call i32 @write_byte(i32 %21, i8 signext %22)
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 538463840
%26 = add nsw i32 %25, 2
%27 = load i8, i8* %8
%28 = call i32 @write_byte(i32 %26, i8 signext %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 538751856
%31 = load i8, i8* %10
%32 = call i32 @write_byte(i32 %30, i8 signext %31)
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 538751856
%35 = add nsw i32 %34, 1
%36 = load i8, i8* %9
%37 = call i32 @write_byte(i32 %35, i8 signext %36)
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 538751856
%40 = add nsw i32 %39, 2
%41 = load i8, i8* %8
%42 = call i32 @write_byte(i32 %40, i8 signext %41)
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 539500896
%45 = load i8, i8* %10
%46 = call i32 @write_byte(i32 %44, i8 signext %45)
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 539500896
%49 = add nsw i32 %48, 1
%50 = load i8, i8* %9
%51 = call i32 @write_byte(i32 %49, i8 signext %50)
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 539500896
%54 = add nsw i32 %53, 2
%55 = load i8, i8* %8
%56 = call i32 @write_byte(i32 %54, i8 signext %55)
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 539788912
%59 = load i8, i8* %10
%60 = call i32 @write_byte(i32 %58, i8 signext %59)
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 539788912
%63 = add nsw i32 %62, 1
%64 = load i8, i8* %9
%65 = call i32 @write_byte(i32 %63, i8 signext %64)
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 539788912
%68 = add nsw i32 %67, 2
%69 = load i8, i8* %8
%70 = call i32 @write_byte(i32 %68, i8 signext %69)
br label %71
71: ; preds = %14, %5
%72 = load i32, i32* %7
%73 = and i32 %72, 2
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %104
75: ; preds = %71
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 539039968
%78 = load i8, i8* %10
%79 = call i32 @write_byte(i32 %77, i8 signext %78)
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 539039968
%82 = add nsw i32 %81, 1
%83 = load i8, i8* %9
%84 = call i32 @write_byte(i32 %82, i8 signext %83)
%85 = load i32, i32* %6
%86 = add nsw i32 %85, 539039968
%87 = add nsw i32 %86, 2
%88 = load i8, i8* %8
%89 = call i32 @write_byte(i32 %87, i8 signext %88)
%90 = load i32, i32* %6
%91 = add nsw i32 %90, 539270384
%92 = load i8, i8* %10
%93 = call i32 @write_byte(i32 %91, i8 signext %92)
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 539270384
%96 = add nsw i32 %95, 1
%97 = load i8, i8* %9
%98 = call i32 @write_byte(i32 %96, i8 signext %97)
%99 = load i32, i32* %6
%100 = add nsw i32 %99, 539270384
%101 = add nsw i32 %100, 2
%102 = load i8, i8* %8
%103 = call i32 @write_byte(i32 %101, i8 signext %102)
br label %104
104: ; preds = %75, %71
ret void
}

LLVM IR (-O2):
define void @draw_color(i32 %0, i32 %1, i8 signext %2, i8 signext %3, i8 signext %4) {
%6 = and i32 %1, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %5
%9 = add nsw i32 %0, 538463840
%10 = tail call i32 @write_byte(i32 %9, i8 signext %4)
%11 = add nsw i32 %0, 538463841
%12 = tail call i32 @write_byte(i32 %11, i8 signext %3)
%13 = add nsw i32 %0, 538463842
%14 = tail call i32 @write_byte(i32 %13, i8 signext %2)
%15 = add nsw i32 %0, 538751856
%16 = tail call i32 @write_byte(i32 %15, i8 signext %4)
%17 = add nsw i32 %0, 538751857
%18 = tail call i32 @write_byte(i32 %17, i8 signext %3)
%19 = add nsw i32 %0, 538751858
%20 = tail call i32 @write_byte(i32 %19, i8 signext %2)
%21 = add nsw i32 %0, 539500896
%22 = tail call i32 @write_byte(i32 %21, i8 signext %4)
%23 = add nsw i32 %0, 539500897
%24 = tail call i32 @write_byte(i32 %23, i8 signext %3)
%25 = add nsw i32 %0, 539500898
%26 = tail call i32 @write_byte(i32 %25, i8 signext %2)
%27 = add nsw i32 %0, 539788912
%28 = tail call i32 @write_byte(i32 %27, i8 signext %4)
%29 = add nsw i32 %0, 539788913
%30 = tail call i32 @write_byte(i32 %29, i8 signext %3)
%31 = add nsw i32 %0, 539788914
%32 = tail call i32 @write_byte(i32 %31, i8 signext %2)
br label %33
33: ; preds = %8, %5
%34 = and i32 %1, 2
%35 = icmp eq i32 %34, 0
br i1 %35, label %49, label %36
36: ; preds = %33
%37 = add nsw i32 %0, 539039968
%38 = tail call i32 @write_byte(i32 %37, i8 signext %4)
%39 = add nsw i32 %0, 539039969
%40 = tail call i32 @write_byte(i32 %39, i8 signext %3)
%41 = add nsw i32 %0, 539039970
%42 = tail call i32 @write_byte(i32 %41, i8 signext %2)
%43 = add nsw i32 %0, 539270384
%44 = tail call i32 @write_byte(i32 %43, i8 signext %4)
%45 = add nsw i32 %0, 539270385
%46 = tail call i32 @write_byte(i32 %45, i8 signext %3)
%47 = add nsw i32 %0, 539270386
%48 = tail call i32 @write_byte(i32 %47, i8 signext %2)
br label %49
49: ; preds = %36, %33
ret void
}