#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*/ psdraw_pixel(int, int, int, char, char, char);
void psdraw_fillrect(int x1, int y1, int x2, int y2, int z, char r, char g,
                     char b) {
  int X1, X2, Y1, Y2, i, j;
  if (x1 > x2) {
    X1 = x2;
    X2 = x1;
  } else {
    X1 = x1;
    X2 = x2;
  }
  if (y1 > y2) {
    Y1 = y2;
    Y2 = y1;
  } else {
    Y1 = Y1;
    Y2 = Y2;
  }
  for (i = X1; i <= X2; i++) {
    for (j = Y1; i <= Y2; j++) {
      psdraw_pixel(i, j, z, r, g, b);
    }
  }
}


x86 assembly (clang, -O0):
<psdraw_fillrect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r9b,%al
mov    0x18(%rbp),%r9b
mov    0x10(%rbp),%r9b
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %al,-0x15(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1153 <psdraw_fillrect+0x43>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    115f <psdraw_fillrect+0x4f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    117c <psdraw_fillrect+0x6c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1188 <psdraw_fillrect+0x78>
mov    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11ed <psdraw_fillrect+0xdd>
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     11da <psdraw_fillrect+0xca>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x15(%rbp),%cl
mov    0x10(%rbp),%al
movsbl %cl,%ecx
movsbl %al,%r8d
movsbl 0x18(%rbp),%r9d
call   1030 <psdraw_pixel@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11a0 <psdraw_fillrect+0x90>
jmp    11df <psdraw_fillrect+0xcf>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118e <psdraw_fillrect+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psdraw_fillrect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    0x48(%rsp),%al
cmp    %edx,%edi
mov    %edi,%r15d
cmovg  %edx,%r15d
mov    0x40(%rsp),%cl
cmovg  %edi,%edx
add    $0x1,%edx
nopw   0x0(%rax,%rax,1)
cmp    %esi,%r15d
jle    115d <psdraw_fillrect+0x4d>
add    $0x1,%r15d
cmp    %r15d,%edx
jne    1140 <psdraw_fillrect+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movsbl %r9b,%r12d
movsbl %cl,%r13d
movsbl %al,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r12d,%ecx
mov    %r13d,%r8d
mov    %ebx,%r9d
call   1030 <psdraw_pixel@plt>
add    $0x1,%ebp
jmp    1170 <psdraw_fillrect+0x60>

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

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