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


x86 assembly (clang, -O0):
<draw_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <draw_rect+0x7a>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1177 <draw_rect+0x67>
mov    -0x18(%rbp),%esi
add    -0x4(%rbp),%esi
mov    -0x1c(%rbp),%edx
add    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <draw_rect+0x32>
jmp    117c <draw_rect+0x6c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112f <draw_rect+0x1f>
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    $0x18,%rsp
mov    %ecx,0x4(%rsp)
mov    %esi,0x8(%rsp)
mov    %rdi,0x10(%rsp)
mov    %edx,0xc(%rsp)
test   %edx,%edx
jle    119c <draw_rect+0x8c>
mov    %r8d,%ebx
xor    %r14d,%r14d
lea    0xec0(%rip),%rbp
jmp    115b <draw_rect+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
je     119c <draw_rect+0x8c>
cmpl   $0x0,0x4(%rsp)
jle    1150 <draw_rect+0x40>
mov    0x10(%rsp),%rax
lea    (%r14,%rax,1),%r15d
mov    0x8(%rsp),%r12d
mov    0x4(%rsp),%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
add    $0x1,%r12d
add    $0xffffffff,%r13d
jne    1180 <draw_rect+0x70>
jmp    1150 <draw_rect+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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