#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*/ boundedPixel(int, int);
unsigned char *getVideoPix();
void paintPixel(int x, int y, char B, char G, char R) {
  if (!boundedPixel(x, y))
    return;
  unsigned char *pixel_address;
  pixel_address = getVideoPix() + 3 * (x + y * 1024);
  *pixel_address = B;
  *(pixel_address + 1) = G;
  *(pixel_address + 2) = R;
}


x86 assembly (clang, -O0):
<paintPixel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <boundedPixel@plt>
cmp    $0x0,%eax
jne    1153 <paintPixel+0x33>
jmp    118f <paintPixel+0x6f>
mov    $0x0,%al
call   1040 <getVideoPix@plt>
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%edx
shl    $0xa,%edx
add    %edx,%ecx
imul   $0x3,%ecx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0xa(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xb(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paintPixel>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <boundedPixel@plt>
test   %eax,%eax
je     115f <paintPixel+0x3f>
xor    %eax,%eax
call   1040 <getVideoPix@plt>
shl    $0xa,%ebp
add    %ebx,%ebp
movslq %ebp,%rcx
lea    (%rcx,%rcx,2),%rcx
mov    %r12b,(%rax,%rcx,1)
mov    %r15b,0x1(%rax,%rcx,1)
mov    %r14b,0x2(%rax,%rcx,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @paintPixel(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
%11 = 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
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 @boundedPixel(i32 %12, i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %5
br label %34
17: ; preds = %5
%18 = call i8* (...) @getVideoPix()
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = mul nsw i32 %20, 1024
%22 = add nsw i32 %19, %21
%23 = mul nsw i32 3, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %18, i64 %24
store i8* %25, i8** %11
%26 = load i8, i8* %8
%27 = load i8*, i8** %11
store i8 %26, i8* %27
%28 = load i8, i8* %9
%29 = load i8*, i8** %11
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %28, i8* %30
%31 = load i8, i8* %10
%32 = load i8*, i8** %11
%33 = getelementptr inbounds i8, i8* %32, i64 2
store i8 %31, i8* %33
br label %34
34: ; preds = %17, %16
ret void
}

LLVM IR (-O2):
define void @paintPixel(i32 %0, i32 %1, i8 signext %2, i8 signext %3, i8 signext %4) {
%6 = tail call i32 @boundedPixel(i32 %0, i32 %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = tail call i8* (...) @getVideoPix()
%10 = shl nsw i32 %1, 10
%11 = add nsw i32 %10, %0
%12 = mul nsw i32 %11, 3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
store i8 %2, i8* %14
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %3, i8* %15
%16 = getelementptr inbounds i8, i8* %14, i64 2
store i8 %4, i8* %16
br label %17
17: ; preds = %5, %8
ret void
}