#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*/ paint_fill_aux(size_t, size_t, char **, size_t, size_t, char,
                                  char);
void paint_fill(size_t x, size_t y, char screen[x][y], size_t px, size_t py,
                char new_color) {
  if (screen[px][py] != new_color) {
    paint_fill_aux(x, y, screen, px, py, screen[px][py], new_color);
  }
}


x86 assembly (clang, -O0):
<paint_fill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r9b,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %al,-0x29(%rbp)
mov    -0x10(%rbp),%rcx
mov    %rcx,-0x38(%rbp)
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x29(%rbp),%ecx
cmp    %ecx,%eax
je     1196 <paint_fill+0x86>
mov    -0x38(%rbp),%r9
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%r9
add    %r9,%rax
mov    -0x28(%rbp),%r9
mov    (%rax,%r9,1),%al
movsbl %al,%r9d
movsbl -0x29(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <paint_fill_aux@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paint_fill>:
push   %rax
mov    %rcx,%rax
imul   %rsi,%rax
add    %rdx,%rax
mov    (%r8,%rax,1),%r10b
cmp    %r9b,%r10b
je     1134 <paint_fill+0x24>
movsbl %r9b,%eax
mov    %eax,(%rsp)
movsbl %r10b,%r9d
call   1030 <paint_fill_aux@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @paint_fill(i64 %0, i64 %1, i8* %2, i64 %3, i64 %4, i8 signext %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8
store i64 %0, i64* %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i8 %5, i8* %12
%13 = load i64, i64* %7
%14 = load i64, i64* %8
%15 = load i8*, i8** %9
%16 = load i64, i64* %10
%17 = mul nsw i64 %16, %14
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i64, i64* %11
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i8, i8* %12
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %42
26: ; preds = %6
%27 = load i64, i64* %7
%28 = load i64, i64* %8
%29 = load i8*, i8** %9
%30 = bitcast i8* %29 to i8**
%31 = load i64, i64* %10
%32 = load i64, i64* %11
%33 = load i8*, i8** %9
%34 = load i64, i64* %10
%35 = mul nsw i64 %34, %14
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i64, i64* %11
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = load i8, i8* %38
%40 = load i8, i8* %12
%41 = call i32 @paint_fill_aux(i64 %27, i64 %28, i8** %30, i64 %31, i64 %32, i8 signext %39, i8 signext %40)
br label %42
42: ; preds = %26, %6
ret void
}

LLVM IR (-O2):
define void @paint_fill(i64 %0, i64 %1, i8* %2, i64 %3, i64 %4, i8 signext %5) {
%7 = mul nsw i64 %3, %1
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 %4
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, %5
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = bitcast i8* %2 to i8**
%14 = tail call i32 @paint_fill_aux(i64 %0, i64 %1, i8** %13, i64 %3, i64 %4, i8 signext %10, i8 signext %5)
br label %15
15: ; preds = %12, %6
ret void
}