#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 */
struct pixel {
  int dummy;
};
struct FramebufferFormat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ set_pixel(struct pixel *, struct FramebufferFormat *, int,
                             int, struct pixel *);
void fill_rect(struct pixel *framebuffer, struct FramebufferFormat *fbf,
               struct pixel *pixelptr, int rectx, int recty, int rectw,
               int recth) {
  int x, y;
  for (y = recty; y < recty + recth; y++) {
    for (x = rectx; x < rectx + rectw; x++) {
      set_pixel(framebuffer, fbf, x, y, pixelptr);
    }
  }
}


x86 assembly (clang, -O0):
<fill_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%ecx
add    0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1198 <fill_rect+0x88>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1185 <fill_rect+0x75>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%r8
call   1030 <set_pixel@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114f <fill_rect+0x3f>
jmp    118a <fill_rect+0x7a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1138 <fill_rect+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_rect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    0x50(%rsp),%eax
mov    %eax,0x4(%rsp)
test   %eax,%eax
jle    119e <fill_rect+0x8e>
mov    %r8d,%ebp
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
add    %r8d,0x4(%rsp)
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rax,%rcx,1),%r15d
jmp    1169 <fill_rect+0x59>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jge    119e <fill_rect+0x8e>
cmpl   $0x0,0x10(%rsp)
jle    1160 <fill_rect+0x50>
mov    0x8(%rsp),%rax
mov    %eax,%r14d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r12,%r8
call   1030 <set_pixel@plt>
add    $0x1,%r14d
cmp    %r15d,%r14d
jl     1180 <fill_rect+0x70>
jmp    1160 <fill_rect+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.FramebufferFormat = type { i32 }
%struct.pixel = type { i32 }
define void @fill_rect(%struct.pixel* %0, %struct.FramebufferFormat* %1, %struct.pixel* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca %struct.pixel*
%9 = alloca %struct.FramebufferFormat*
%10 = alloca %struct.pixel*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store %struct.pixel* %0, %struct.pixel** %8
store %struct.FramebufferFormat* %1, %struct.FramebufferFormat** %9
store %struct.pixel* %2, %struct.pixel** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = load i32, i32* %12
store i32 %17, i32* %16
br label %18
18: ; preds = %43, %7
%19 = load i32, i32* %16
%20 = load i32, i32* %12
%21 = load i32, i32* %14
%22 = add nsw i32 %20, %21
%23 = icmp slt i32 %19, %22
br i1 %23, label %24, label %46
24: ; preds = %18
%25 = load i32, i32* %11
store i32 %25, i32* %15
br label %26
26: ; preds = %39, %24
%27 = load i32, i32* %15
%28 = load i32, i32* %11
%29 = load i32, i32* %13
%30 = add nsw i32 %28, %29
%31 = icmp slt i32 %27, %30
br i1 %31, label %32, label %42
32: ; preds = %26
%33 = load %struct.pixel*, %struct.pixel** %8
%34 = load %struct.FramebufferFormat*, %struct.FramebufferFormat** %9
%35 = load i32, i32* %15
%36 = load i32, i32* %16
%37 = load %struct.pixel*, %struct.pixel** %10
%38 = call i32 @set_pixel(%struct.pixel* %33, %struct.FramebufferFormat* %34, i32 %35, i32 %36, %struct.pixel* %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %15
%41 = add nsw i32 %40, 1
store i32 %41, i32* %15
br label %26
42: ; preds = %26
br label %43
43: ; preds = %42
%44 = load i32, i32* %16
%45 = add nsw i32 %44, 1
store i32 %45, i32* %16
br label %18
46: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.FramebufferFormat = type { i32 }
%struct.pixel = type { i32 }
define void @fill_rect(%struct.pixel* %0, %struct.FramebufferFormat* %1, %struct.pixel* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = add nsw i32 %6, %4
%9 = icmp sgt i32 %6, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = add nsw i32 %5, %3
%12 = icmp sgt i32 %5, 0
br label %13
13: ; preds = %10, %20
%14 = phi i32 [ %4, %10 ], [ %21, %20 ]
br i1 %12, label %15, label %20
15: ; preds = %13, %15
%16 = phi i32 [ %18, %15 ], [ %3, %13 ]
%17 = tail call i32 @set_pixel(%struct.pixel* %0, %struct.FramebufferFormat* %1, i32 %16, i32 %14, %struct.pixel* %2)
%18 = add nsw i32 %16, 1
%19 = icmp slt i32 %18, %11
br i1 %19, label %15, label %20
20: ; preds = %15, %13
%21 = add nsw i32 %14, 1
%22 = icmp slt i32 %21, %8
br i1 %22, label %13, label %23
23: ; preds = %20, %7
ret void
}