#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*/ draw_line(char *, int, int, int, int);
int /*<<< orphan*/ draw_rect(char *, int, int, int, int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, int);
int rect_test(char *fbp, int size, int fbfd, int xres, int yres) {
  memset(fbp, 0x00, size);
  draw_rect(fbp, 40, 40, 50, 50);
  draw_line(fbp, 0, 0, 0, yres - 1);
  draw_line(fbp, 0, 0, xres - 1, 0);
  printf("--> yres = %d\n", yres);
  draw_line(fbp, 0, yres - 1, xres - 1, yres - 1);
  draw_line(fbp, xres - 1, 0, xres - 1, yres - 1);
  return 0;
}


x86 assembly (clang, -O0):
<rect_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    $0x28,%edx
mov    $0x32,%r8d
mov    %edx,%esi
mov    %r8d,%ecx
call   1050 <draw_rect@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%r8d
sub    $0x1,%r8d
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1060 <draw_line@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
xor    %r8d,%r8d
mov    %r8d,%esi
mov    %r8d,%edx
call   1060 <draw_line@plt>
mov    -0x18(%rbp),%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%r8d
sub    $0x1,%r8d
xor    %esi,%esi
call   1060 <draw_line@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%r8d
sub    $0x1,%r8d
xor    %edx,%edx
call   1060 <draw_line@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rect_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %esi,%edx
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
mov    $0x28,%edx
mov    $0x32,%ecx
mov    $0x32,%r8d
call   1050 <draw_rect@plt>
lea    -0x1(%r14),%r15d
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
call   1060 <draw_line@plt>
add    $0xffffffff,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %ebp,%ecx
xor    %r8d,%r8d
call   1060 <draw_line@plt>
lea    0xe5b(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   1060 <draw_line@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   1060 <draw_line@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"--> yres = %d\0A\00"
define i32 @rect_test(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i32 @memset(i8* %11, i32 0, i32 %12)
%14 = load i8*, i8** %6
%15 = call i32 @draw_rect(i8* %14, i32 40, i32 40, i32 50, i32 50)
%16 = load i8*, i8** %6
%17 = load i32, i32* %10
%18 = sub nsw i32 %17, 1
%19 = call i32 @draw_line(i8* %16, i32 0, i32 0, i32 0, i32 %18)
%20 = load i8*, i8** %6
%21 = load i32, i32* %9
%22 = sub nsw i32 %21, 1
%23 = call i32 @draw_line(i8* %20, i32 0, i32 0, i32 %22, i32 0)
%24 = load i32, i32* %10
%25 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %6
%27 = load i32, i32* %10
%28 = sub nsw i32 %27, 1
%29 = load i32, i32* %9
%30 = sub nsw i32 %29, 1
%31 = load i32, i32* %10
%32 = sub nsw i32 %31, 1
%33 = call i32 @draw_line(i8* %26, i32 0, i32 %28, i32 %30, i32 %32)
%34 = load i8*, i8** %6
%35 = load i32, i32* %9
%36 = sub nsw i32 %35, 1
%37 = load i32, i32* %9
%38 = sub nsw i32 %37, 1
%39 = load i32, i32* %10
%40 = sub nsw i32 %39, 1
%41 = call i32 @draw_line(i8* %34, i32 %36, i32 0, i32 %38, i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"--> yres = %d\0A\00"
define i32 @rect_test(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @memset(i8* %0, i32 0, i32 %1)
%7 = tail call i32 @draw_rect(i8* %0, i32 40, i32 40, i32 50, i32 50)
%8 = add nsw i32 %4, -1
%9 = tail call i32 @draw_line(i8* %0, i32 0, i32 0, i32 0, i32 %8)
%10 = add nsw i32 %3, -1
%11 = tail call i32 @draw_line(i8* %0, i32 0, i32 0, i32 %10, i32 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %4)
%13 = tail call i32 @draw_line(i8* %0, i32 0, i32 %8, i32 %10, i32 %8)
%14 = tail call i32 @draw_line(i8* %0, i32 %10, i32 0, i32 %10, i32 %8)
ret i32 0
}