#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*/ setPixel(int, int, char);
void drawRectangle(short x, short y, short width, short height, char c) {
  int i;
  int newX;
  int newY;
  newY = y;
  for (i = 0; i < 2; i++) {
    for (newX = 0; newX < width; newX++) {
      setPixel(newX + x, newY, c);
    }
    newY += height - 1;
  }
  newX = x;
  for (i = 0; i < 2; i++) {
    for (newY = 0; newY < height; newY++) {
      setPixel(newX, newY + y, c);
    }
    newX += width - 1;
  }
}


x86 assembly (clang, -O0):
<drawRectangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %di,-0x2(%rbp)
mov    %si,-0x4(%rbp)
mov    %dx,-0x6(%rbp)
mov    %cx,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movswl -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    119a <drawRectangle+0x8a>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movswl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jge    117f <drawRectangle+0x6f>
mov    -0x14(%rbp),%edi
movswl -0x2(%rbp),%eax
add    %eax,%edi
mov    -0x18(%rbp),%esi
movsbl -0x9(%rbp),%edx
call   1030 <setPixel@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <drawRectangle+0x3d>
movswl -0x8(%rbp),%eax
sub    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113c <drawRectangle+0x2c>
movswl -0x2(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    1206 <drawRectangle+0xf6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
movswl -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    11eb <drawRectangle+0xdb>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
movswl -0x4(%rbp),%eax
add    %eax,%esi
movsbl -0x9(%rbp),%edx
call   1030 <setPixel@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b9 <drawRectangle+0xa9>
movswl -0x6(%rbp),%eax
sub    $0x1,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a8 <drawRectangle+0x98>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawRectangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %esi,%r13d
mov    %edi,0xc(%rsp)
movsbl %r8b,%r15d
mov    %edx,0x10(%rsp)
test   %dx,%dx
jle    1195 <drawRectangle+0x85>
lea    -0x1(%r14),%eax
mov    %eax,0x14(%rsp)
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%r12d
mov    %ebx,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r13d,%esi
mov    %r15d,%edx
call   1030 <setPixel@plt>
add    $0x1,%r12d
add    $0xffffffff,%ebx
jne    1150 <drawRectangle+0x40>
test   %bp,%bp
mov    0x14(%rsp),%r12d
jle    1195 <drawRectangle+0x85>
add    %r13d,%r12d
mov    0xc(%rsp),%ebx
mov    0x10(%rsp),%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <setPixel@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    1180 <drawRectangle+0x70>
test   %r14w,%r14w
mov    0x10(%rsp),%r12d
jle    11f8 <drawRectangle+0xe8>
add    $0xffffffff,%r12d
mov    %r13d,%ebx
mov    %r14d,%ebp
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
mov    %ebx,%esi
mov    %r15d,%edx
call   1030 <setPixel@plt>
mov    0xc(%rsp),%eax
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    11b0 <drawRectangle+0xa0>
test   %r14w,%r14w
jle    11f8 <drawRectangle+0xe8>
add    %eax,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%edi
mov    %r13d,%esi
mov    %r15d,%edx
call   1030 <setPixel@plt>
add    $0x1,%r13d
add    $0xffffffff,%r14d
jne    11e0 <drawRectangle+0xd0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @drawRectangle(i16 signext %0, i16 signext %1, i16 signext %2, i16 signext %3, i8 signext %4) {
%6 = sext i16 %1 to i32
%7 = sext i16 %2 to i32
%8 = icmp sgt i16 %2, 0
%9 = sext i16 %0 to i32
%10 = sext i16 %3 to i32
%11 = add nsw i32 %10, -1
br i1 %8, label %12, label %26
12: ; preds = %5, %12
%13 = phi i32 [ %16, %12 ], [ 0, %5 ]
%14 = add nsw i32 %13, %9
%15 = tail call i32 @setPixel(i32 %14, i32 %6, i8 signext %4)
%16 = add nuw nsw i32 %13, 1
%17 = icmp eq i32 %16, %7
br i1 %17, label %18, label %12
18: ; preds = %12
%19 = add nsw i32 %11, %6
br i1 %8, label %20, label %26
20: ; preds = %18, %20
%21 = phi i32 [ %24, %20 ], [ 0, %18 ]
%22 = add nsw i32 %21, %9
%23 = tail call i32 @setPixel(i32 %22, i32 %19, i8 signext %4)
%24 = add nuw nsw i32 %21, 1
%25 = icmp eq i32 %24, %7
br i1 %25, label %26, label %20
26: ; preds = %20, %5, %18
%27 = icmp sgt i16 %3, 0
%28 = add nsw i32 %7, -1
br i1 %27, label %29, label %43
29: ; preds = %26, %29
%30 = phi i32 [ %33, %29 ], [ 0, %26 ]
%31 = add nsw i32 %30, %6
%32 = tail call i32 @setPixel(i32 %9, i32 %31, i8 signext %4)
%33 = add nuw nsw i32 %30, 1
%34 = icmp eq i32 %33, %10
br i1 %34, label %35, label %29
35: ; preds = %29
%36 = add nsw i32 %28, %9
br i1 %27, label %37, label %43
37: ; preds = %35, %37
%38 = phi i32 [ %41, %37 ], [ 0, %35 ]
%39 = add nsw i32 %38, %6
%40 = tail call i32 @setPixel(i32 %36, i32 %39, i8 signext %4)
%41 = add nuw nsw i32 %38, 1
%42 = icmp eq i32 %41, %10
br i1 %42, label %43, label %37
43: ; preds = %37, %26, %35
ret void
}