#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*/ DrawBox(double, double, double, double);
void DrawGrid(double x, double y, double width, double height, int columns,
              int rows) {
  int i, j;
  for (i = 0; i < columns; i++) {
    for (j = 0; j < rows; j++) {
      DrawBox(x + i * width, y + j * height, width, height);
    }
  }
}


x86 assembly (clang, -O0):
<DrawGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b6 <DrawGrid+0xa6>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11a3 <DrawGrid+0x93>
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm2
cvtsi2sdl -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
call   1030 <DrawBox@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    114c <DrawGrid+0x3c>
jmp    11a8 <DrawGrid+0x98>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1139 <DrawGrid+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawGrid>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,0x18(%rsp)
test   %edi,%edi
jle    11f7 <DrawGrid+0xe7>
mov    %esi,%r15d
mov    %edi,%r14d
movapd %xmm1,%xmm4
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xebb(%rip),%xmm1
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm4,0x20(%rsp)
jmp    117a <DrawGrid+0x6a>
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
add    $0x1,%ebp
cmp    %r14d,%ebp
je     11f7 <DrawGrid+0xe7>
test   %r15d,%r15d
jle    1160 <DrawGrid+0x50>
movsd  (%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
xorpd  %xmm0,%xmm0
mov    %r15d,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x30(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
movsd  0x28(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
call   1030 <DrawBox@plt>
movsd  0x30(%rsp),%xmm0
movsd  0xe29(%rip),%xmm1
movsd  0x20(%rsp),%xmm4
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
addsd  %xmm1,%xmm0
add    $0xffffffff,%ebx
jne    11a0 <DrawGrid+0x90>
jmp    1160 <DrawGrid+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @DrawGrid(double %0, double %1, double %2, double %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %25
8: ; preds = %6
%9 = icmp sgt i32 %5, 0
br label %10
10: ; preds = %8, %22
%11 = phi i32 [ 0, %8 ], [ %23, %22 ]
br i1 %9, label %12, label %22
12: ; preds = %10
%13 = sitofp i32 %11 to double
%14 = tail call double @llvm.fmuladd.f64(double %13, double %2, double %0)
br label %15
15: ; preds = %12, %15
%16 = phi i32 [ 0, %12 ], [ %20, %15 ]
%17 = sitofp i32 %16 to double
%18 = tail call double @llvm.fmuladd.f64(double %17, double %3, double %1)
%19 = tail call i32 @DrawBox(double %14, double %18, double %2, double %3)
%20 = add nuw nsw i32 %16, 1
%21 = icmp eq i32 %20, %5
br i1 %21, label %22, label %15
22: ; preds = %15, %10
%23 = add nuw nsw i32 %11, 1
%24 = icmp eq i32 %23, %4
br i1 %24, label %25, label %10
25: ; preds = %22, %6
ret void
}