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


x86 assembly (clang, -O0):
<test03>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1240 <test03+0x100>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122d <test03+0xed>
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0xc(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
xorps  %xmm1,%xmm1
mov    $0x1,%edi
movaps %xmm1,%xmm0
call   1040 <glColor3f@plt>
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
xor    %edi,%edi
call   1050 <glVertex3i@plt>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe31(%rip),%xmm0
xor    %edi,%edi
call   1040 <glColor3f@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
sub    -0xc(%rbp),%edi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1050 <glVertex3i@plt>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
movsd  0xdfd(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1040 <glColor3f@plt>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
sub    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <glVertex3i@plt>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <test03+0x36>
jmp    1232 <test03+0xf2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <test03+0x23>
mov    $0x0,%al
call   1030 <glEnd@plt>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test03>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %edi,%r15d
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
mov    %ebx,0x8(%rsp)
test   %ebx,%ebx
jle    124a <test03+0x10a>
cvtsi2ss %r15d,%xmm0
movss  %xmm0,0x10(%rsp)
mov    0x8(%rsp),%r13d
imul   %r15d,%r13d
lea    -0x1(%r15),%eax
mov    %eax,0xc(%rsp)
xor    %r14d,%r14d
jmp    11a2 <test03+0x62>
xchg   %ax,%ax
add    $0x1,%r14d
sub    %r15d,%r13d
cmp    0x8(%rsp),%r14d
je     124a <test03+0x10a>
test   %r15d,%r15d
jle    1190 <test03+0x50>
xor    %ebp,%ebp
mov    0xc(%rsp),%r12d
mov    %r13d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
mov    $0x1,%edi
call   1040 <glColor3f@plt>
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <glVertex3i@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  0x10(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe03(%rip),%xmm0
xor    %edi,%edi
call   1040 <glColor3f@plt>
mov    %r12d,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <glVertex3i@plt>
cvttss2si 0x14(%rsp),%edi
xorps  %xmm1,%xmm1
movsd  0xddf(%rip),%xmm0
call   1040 <glColor3f@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1050 <glVertex3i@plt>
add    $0x5,%ebp
add    $0xfffffffb,%ebx
add    $0xfffffffb,%r12d
cmp    %r15d,%ebp
jl     11c0 <test03+0x80>
jmp    1190 <test03+0x50>
xor    %eax,%eax
call   1030 <glEnd@plt>
mov    0x8(%rsp),%eax
imul   %r15d,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_TRIANGLES = global i32 0
define i32 @test03(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* @GL_TRIANGLES
%9 = call i32 @glBegin(i32 %8)
store i32 0, i32* %6
br label %10
10: ; preds = %64, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %67
14: ; preds = %10
store i32 0, i32* %5
br label %15
15: ; preds = %60, %14
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %63
19: ; preds = %15
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %6
%24 = load i32, i32* %3
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %5
%27 = add nsw i32 %25, %26
%28 = sub nsw i32 %22, %27
store i32 %28, i32* %7
%29 = call i32 @glColor3f(double 0.000000e+00, i32 1, double 0.000000e+00)
%30 = load i32, i32* %5
%31 = load i32, i32* %7
%32 = call i32 @glVertex3i(i32 0, i32 %30, i32 %31)
%33 = load i32, i32* %5
%34 = sitofp i32 %33 to float
%35 = load i32, i32* %3
%36 = sitofp i32 %35 to float
%37 = fdiv float %34, %36
%38 = fpext float %37 to double
%39 = call i32 @glColor3f(double 1.000000e+00, i32 0, double %38)
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, 1
%42 = load i32, i32* %5
%43 = sub nsw i32 %41, %42
%44 = load i32, i32* %7
%45 = call i32 @glVertex3i(i32 %43, i32 0, i32 %44)
%46 = load i32, i32* %5
%47 = sitofp i32 %46 to float
%48 = load i32, i32* %3
%49 = sitofp i32 %48 to float
%50 = fdiv float %47, %49
%51 = fptosi float %50 to i32
%52 = call i32 @glColor3f(double 1.000000e+00, i32 %51, double 0.000000e+00)
%53 = load i32, i32* %5
%54 = load i32, i32* %3
%55 = sub nsw i32 %54, 1
%56 = load i32, i32* %5
%57 = sub nsw i32 %55, %56
%58 = load i32, i32* %7
%59 = call i32 @glVertex3i(i32 %53, i32 %57, i32 %58)
br label %60
60: ; preds = %19
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 5
store i32 %62, i32* %5
br label %15
63: ; preds = %15
br label %64
64: ; preds = %63
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %10
67: ; preds = %10
%68 = call i32 (...) @glEnd()
%69 = load i32, i32* %3
%70 = load i32, i32* %4
%71 = mul nsw i32 %69, %70
%72 = sdiv i32 %71, 5
ret i32 %72
}

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