#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 */
scalar_t__ ComparePixel(unsigned long, unsigned long, char);
int /*<<< orphan*/ SetPixel(unsigned long, unsigned long, char);
void FillWorker(unsigned long x, unsigned long y, char color, char oldColor) {
  SetPixel(x, y, color);
  if (ComparePixel(x, y - 1, oldColor)) {
    FillWorker(x, y - 1, color, oldColor);
  }
  if (ComparePixel(x, y + 1, oldColor)) {
    FillWorker(x, y + 1, color, oldColor);
  }
  if (ComparePixel(x - 1, y, oldColor)) {
    FillWorker(x - 1, y, color, oldColor);
  }
  if (ComparePixel(x + 1, y, oldColor)) {
    FillWorker(x + 1, y, color, oldColor);
  }
}


x86 assembly (clang, -O0):
<FillWorker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsbl -0x11(%rbp),%edx
call   1030 <SetPixel@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
movsbl -0x12(%rbp),%edx
call   1050 <ComparePixel@plt>
cmp    $0x0,%rax
je     1195 <FillWorker+0x65>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x11(%rbp),%al
movsbl %al,%edx
movsbl -0x12(%rbp),%ecx
call   1040 <FillWorker@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
movsbl -0x12(%rbp),%edx
call   1050 <ComparePixel@plt>
cmp    $0x0,%rax
je     11cf <FillWorker+0x9f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x11(%rbp),%al
movsbl %al,%edx
movsbl -0x12(%rbp),%ecx
call   1040 <FillWorker@plt>
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    -0x10(%rbp),%rsi
movsbl -0x12(%rbp),%edx
call   1050 <ComparePixel@plt>
cmp    $0x0,%rax
je     1209 <FillWorker+0xd9>
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x11(%rbp),%al
movsbl %al,%edx
movsbl -0x12(%rbp),%ecx
call   1040 <FillWorker@plt>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
movsbl -0x12(%rbp),%edx
call   1050 <ComparePixel@plt>
cmp    $0x0,%rax
je     1243 <FillWorker+0x113>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x11(%rbp),%al
movsbl %al,%edx
movsbl -0x12(%rbp),%ecx
call   1040 <FillWorker@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FillWorker>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    -0x1(%rsi),%rbp
lea    0x1(%rsi),%r15
movsbl %dl,%r13d
movsbl %cl,%r12d
mov    %r15,(%rsp)
jmp    1182 <FillWorker+0x52>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <ComparePixel@plt>
test   %rax,%rax
mov    (%rsp),%r15
mov    %r14,%rsi
je     1209 <FillWorker+0xd9>
mov    %rbx,%rdi
mov    %rsi,%r14
mov    %r13d,%edx
call   1030 <SetPixel@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <ComparePixel@plt>
test   %rax,%rax
je     11b4 <FillWorker+0x84>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1040 <FillWorker@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1050 <ComparePixel@plt>
test   %rax,%rax
je     11d8 <FillWorker+0xa8>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1040 <FillWorker@plt>
lea    -0x1(%rbx),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <ComparePixel@plt>
test   %rax,%rax
je     1160 <FillWorker+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1040 <FillWorker@plt>
jmp    1160 <FillWorker+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @FillWorker(i64 %0, i64 %1, i8 signext %2, i8 signext %3) {
%5 = add i64 %1, -1
%6 = add i64 %1, 1
br label %7
7: ; preds = %22, %4
%8 = phi i64 [ %0, %4 ], [ %23, %22 ]
%9 = tail call i32 @SetPixel(i64 %8, i64 %1, i8 signext %2)
%10 = tail call i64 @ComparePixel(i64 %8, i64 %5, i8 signext %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %7
tail call void @FillWorker(i64 %8, i64 %5, i8 signext %2, i8 signext %3)
br label %13
13: ; preds = %12, %7
%14 = tail call i64 @ComparePixel(i64 %8, i64 %6, i8 signext %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %13
tail call void @FillWorker(i64 %8, i64 %6, i8 signext %2, i8 signext %3)
br label %17
17: ; preds = %16, %13
%18 = add i64 %8, -1
%19 = tail call i64 @ComparePixel(i64 %18, i64 %1, i8 signext %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
tail call void @FillWorker(i64 %18, i64 %1, i8 signext %2, i8 signext %3)
br label %22
22: ; preds = %21, %17
%23 = add i64 %8, 1
%24 = tail call i64 @ComparePixel(i64 %23, i64 %1, i8 signext %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %7
26: ; preds = %22
ret void
}