#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*/ GL_LINES;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(double, double, int);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex2i(int, int);
int test02(int size, int num) {
  int x, y;
  glBegin(GL_LINES);
  for (y = 0; y < num; y++)
    for (x = 0; x < size; x++) {
      glColor3f(0.0, 1.0, y / (float)num);
      glVertex2i(0, size - 1);
      glColor3f(1.0, 0.0, x / (float)size);
      glVertex2i(x, x);
    }
  glEnd();
  return num * size;
}


x86 assembly (clang, -O0):
<test02>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ff <test02+0xbf>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ec <test02+0xac>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
xorps  %xmm0,%xmm0
movsd  0xe61(%rip),%xmm1
call   1050 <glColor3f@plt>
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1030 <glVertex2i@plt>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
movsd  0xe35(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1050 <glColor3f@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <glVertex2i@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <test02+0x36>
jmp    11f1 <test02+0xb1>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <test02+0x23>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test02>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
test   %r14d,%r14d
jle    1210 <test02+0xd0>
cvtsi2ss %r14d,%xmm0
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
movss  %xmm0,0x4(%rsp)
lea    -0x1(%r15),%r12d
xor    %r13d,%r13d
jmp    1199 <test02+0x59>
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    %r14d,%r13d
je     1210 <test02+0xd0>
test   %r15d,%r15d
jle    1190 <test02+0x50>
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
divss  (%rsp),%xmm0
cvttss2si %xmm0,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
movsd  0xe35(%rip),%xmm1
mov    %ebx,%edi
call   1050 <glColor3f@plt>
xor    %edi,%edi
mov    %r12d,%esi
call   1030 <glVertex2i@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
xorps  %xmm1,%xmm1
movsd  0xe08(%rip),%xmm0
call   1050 <glColor3f@plt>
mov    %ebp,%edi
mov    %ebp,%esi
call   1030 <glVertex2i@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    11c0 <test02+0x80>
jmp    1190 <test02+0x50>
xor    %eax,%eax
call   1040 <glEnd@plt>
imul   %r15d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_LINES = global i32 0
define i32 @test02(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* @GL_LINES
%8 = call i32 @glBegin(i32 %7)
store i32 0, i32* %6
br label %9
9: ; preds = %43, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %46
13: ; preds = %9
store i32 0, i32* %5
br label %14
14: ; preds = %39, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %42
18: ; preds = %14
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to float
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to float
%23 = fdiv float %20, %22
%24 = fptosi float %23 to i32
%25 = call i32 @glColor3f(double 0.000000e+00, double 1.000000e+00, i32 %24)
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, 1
%28 = call i32 @glVertex2i(i32 0, i32 %27)
%29 = load i32, i32* %5
%30 = sitofp i32 %29 to float
%31 = load i32, i32* %3
%32 = sitofp i32 %31 to float
%33 = fdiv float %30, %32
%34 = fptosi float %33 to i32
%35 = call i32 @glColor3f(double 1.000000e+00, double 0.000000e+00, i32 %34)
%36 = load i32, i32* %5
%37 = load i32, i32* %5
%38 = call i32 @glVertex2i(i32 %36, i32 %37)
br label %39
39: ; preds = %18
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %14
42: ; preds = %14
br label %43
43: ; preds = %42
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %9
46: ; preds = %9
%47 = call i32 (...) @glEnd()
%48 = load i32, i32* %4
%49 = load i32, i32* %3
%50 = mul nsw i32 %48, %49
ret i32 %50
}

LLVM IR (-O2):
@GL_LINES = global i32 0
define i32 @test02(i32 %0, i32 %1) {
%3 = load i32, i32* @GL_LINES
%4 = tail call i32 @glBegin(i32 %3)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %31
6: ; preds = %2
%7 = icmp sgt i32 %0, 0
%8 = sitofp i32 %1 to float
%9 = add nsw i32 %0, -1
%10 = sitofp i32 %0 to float
br label %11
11: ; preds = %6, %28
%12 = phi i32 [ 0, %6 ], [ %29, %28 ]
br i1 %7, label %13, label %28
13: ; preds = %11
%14 = sitofp i32 %12 to float
%15 = fdiv float %14, %8
%16 = fptosi float %15 to i32
br label %17
17: ; preds = %13, %17
%18 = phi i32 [ 0, %13 ], [ %26, %17 ]
%19 = tail call i32 @glColor3f(double 0.000000e+00, double 1.000000e+00, i32 %16)
%20 = tail call i32 @glVertex2i(i32 0, i32 %9)
%21 = sitofp i32 %18 to float
%22 = fdiv float %21, %10
%23 = fptosi float %22 to i32
%24 = tail call i32 @glColor3f(double 1.000000e+00, double 0.000000e+00, i32 %23)
%25 = tail call i32 @glVertex2i(i32 %18, i32 %18)
%26 = add nuw nsw i32 %18, 1
%27 = icmp eq i32 %26, %0
br i1 %27, label %28, label %17
28: ; preds = %17, %11
%29 = add nuw nsw i32 %12, 1
%30 = icmp eq i32 %29, %1
br i1 %30, label %31, label %11
31: ; preds = %28, %2
%32 = tail call i32 (...) @glEnd()
%33 = mul nsw i32 %1, %0
ret i32 %33
}