#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*/ printf(char *, int, int, int, int, char);
void draw_rect(int x, int y, int row, int col, int fcolor, int bcolor,
               char ch) {
  int i, j;
  for (i = 0; i < row; i++)
    for (j = 0; j < col; j++) {
      printf("\033[%d;%dH\033[%d;%dm%c\033[0m\n", i + x, j + y, fcolor, bcolor,
             ch);
    }
}


x86 assembly (clang, -O0):
<draw_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x10(%rbp),%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119a <draw_rect+0x8a>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1187 <draw_rect+0x77>
mov    -0x1c(%rbp),%esi
add    -0x4(%rbp),%esi
mov    -0x20(%rbp),%edx
add    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe91(%rip),%rdi
movsbl 0x10(%rbp),%r9d
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1149 <draw_rect+0x39>
jmp    118c <draw_rect+0x7c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1136 <draw_rect+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_rect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,0x4(%rsp)
mov    %esi,0x14(%rsp)
mov    %rdi,0x20(%rsp)
mov    %edx,0x18(%rsp)
test   %edx,%edx
jle    11c4 <draw_rect+0xb4>
mov    %r9d,%ebp
mov    %r8d,%r12d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
movsbl 0x60(%rsp),%r15d
lea    0xeaf(%rip),%rbx
jmp    1173 <draw_rect+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
cmp    0x18(%rsp),%eax
je     11c4 <draw_rect+0xb4>
cmpl   $0x0,0x4(%rsp)
jle    1160 <draw_rect+0x50>
mov    0x20(%rsp),%rax
mov    0x8(%rsp),%rcx
add    %ecx,%eax
mov    %eax,0x1c(%rsp)
mov    0x14(%rsp),%r14d
mov    0x4(%rsp),%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    0x1c(%rsp),%esi
mov    %r14d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %r15d,%r9d
call   1030 <printf@plt>
add    $0x1,%r14d
add    $0xffffffff,%r13d
jne    11a0 <draw_rect+0x90>
jmp    1160 <draw_rect+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\1B[%d;%dH\1B[%d;%dm%c\1B[0m\0A\00"
define void @draw_rect(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8 signext %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i8 %6, i8* %14
store i32 0, i32* %15
br label %17
17: ; preds = %41, %7
%18 = load i32, i32* %15
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %44
21: ; preds = %17
store i32 0, i32* %16
br label %22
22: ; preds = %37, %21
%23 = load i32, i32* %16
%24 = load i32, i32* %11
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %40
26: ; preds = %22
%27 = load i32, i32* %15
%28 = load i32, i32* %8
%29 = add nsw i32 %27, %28
%30 = load i32, i32* %16
%31 = load i32, i32* %9
%32 = add nsw i32 %30, %31
%33 = load i32, i32* %12
%34 = load i32, i32* %13
%35 = load i8, i8* %14
%36 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %32, i32 %33, i32 %34, i8 signext %35)
br label %37
37: ; preds = %26
%38 = load i32, i32* %16
%39 = add nsw i32 %38, 1
store i32 %39, i32* %16
br label %22
40: ; preds = %22
br label %41
41: ; preds = %40
%42 = load i32, i32* %15
%43 = add nsw i32 %42, 1
store i32 %43, i32* %15
br label %17
44: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"\1B[%d;%dH\1B[%d;%dm%c\1B[0m\0A\00"
define void @draw_rect(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8 signext %6) {
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %24
9: ; preds = %7
%10 = icmp sgt i32 %3, 0
br label %11
11: ; preds = %9, %21
%12 = phi i32 [ 0, %9 ], [ %22, %21 ]
br i1 %10, label %13, label %21
13: ; preds = %11
%14 = add nsw i32 %12, %0
br label %15
15: ; preds = %13, %15
%16 = phi i32 [ 0, %13 ], [ %19, %15 ]
%17 = add nsw i32 %16, %1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %17, i32 %4, i32 %5, i8 signext %6)
%19 = add nuw nsw i32 %16, 1
%20 = icmp eq i32 %19, %3
br i1 %20, label %21, label %15
21: ; preds = %15, %11
%22 = add nuw nsw i32 %12, 1
%23 = icmp eq i32 %22, %2
br i1 %23, label %24, label %11
24: ; preds = %21, %7
ret void
}