#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, double, double);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glTexCoord2f(double, double);
int /*<<< orphan*/ glVertex3i(int, int, int);
int test04(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);
      glTexCoord2f(1.0, 1.0);
      glColor3f(1.0, 0.0, 0.0);
      glVertex3i(0, x, z);
      glTexCoord2f(0.0, 1.0);
      glColor3f(0.0, 1.0, 0.0);
      glVertex3i(size - 1 - x, 0, z);
      glTexCoord2f(1.0, 0.0);
      glColor3f(0.0, 0.0, 1.0);
      glVertex3i(x, size - 1 - x, z);
    }
  glEnd();
  return num * size / 5;
}


x86 assembly (clang, -O0):
<test04>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1266 <test04+0x116>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1253 <test04+0x103>
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)
movsd  0xe50(%rip),%xmm1
movaps %xmm1,%xmm0
call   1050 <glTexCoord2f@plt>
movsd  0xe40(%rip),%xmm0
xorps  %xmm2,%xmm2
movaps %xmm2,%xmm1
call   1040 <glColor3f@plt>
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
xor    %edi,%edi
call   1060 <glVertex3i@plt>
xorps  %xmm0,%xmm0
movsd  0xe1d(%rip),%xmm1
call   1050 <glTexCoord2f@plt>
xorps  %xmm2,%xmm2
movsd  0xe0d(%rip),%xmm1
movaps %xmm2,%xmm0
call   1040 <glColor3f@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
sub    -0xc(%rbp),%edi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1060 <glVertex3i@plt>
movsd  0xdea(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1050 <glTexCoord2f@plt>
xorps  %xmm1,%xmm1
movsd  0xdd7(%rip),%xmm2
movaps %xmm1,%xmm0
call   1040 <glColor3f@plt>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
sub    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <glVertex3i@plt>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    1186 <test04+0x36>
jmp    1258 <test04+0x108>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1173 <test04+0x23>
mov    $0x0,%al
call   1030 <glEnd@plt>
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test04>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r15d
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
mov    %ebx,(%rsp)
test   %ebx,%ebx
jle    1259 <test04+0x109>
mov    (%rsp),%r13d
imul   %r15d,%r13d
lea    -0x1(%r15),%eax
mov    %eax,0x4(%rsp)
xor    %r14d,%r14d
jmp    11a1 <test04+0x51>
xchg   %ax,%ax
add    $0x1,%r14d
sub    %r15d,%r13d
cmp    (%rsp),%r14d
je     1259 <test04+0x109>
test   %r15d,%r15d
jle    1190 <test04+0x40>
xor    %ebp,%ebp
mov    0x4(%rsp),%r12d
mov    %r13d,%ebx
movsd  0xe48(%rip),%xmm0
movsd  0xe40(%rip),%xmm1
call   1050 <glTexCoord2f@plt>
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
movsd  0xe2d(%rip),%xmm0
call   1040 <glColor3f@plt>
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1060 <glVertex3i@plt>
xorps  %xmm0,%xmm0
movsd  0xe12(%rip),%xmm1
call   1050 <glTexCoord2f@plt>
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
movsd  0xdff(%rip),%xmm1
call   1040 <glColor3f@plt>
mov    %r12d,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1060 <glVertex3i@plt>
xorps  %xmm1,%xmm1
movsd  0xde3(%rip),%xmm0
call   1050 <glTexCoord2f@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movsd  0xdd0(%rip),%xmm2
call   1040 <glColor3f@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1060 <glVertex3i@plt>
add    $0x5,%ebp
add    $0xfffffffb,%ebx
add    $0xfffffffb,%r12d
cmp    %r15d,%ebp
jl     11b0 <test04+0x60>
jmp    1190 <test04+0x40>
xor    %eax,%eax
call   1030 <glEnd@plt>
mov    (%rsp),%eax
imul   %r15d,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_TRIANGLES = global i32 0
define i32 @test04(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 = %55, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %58
14: ; preds = %10
store i32 0, i32* %5
br label %15
15: ; preds = %51, %14
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %54
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 @glTexCoord2f(double 1.000000e+00, double 1.000000e+00)
%30 = call i32 @glColor3f(double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%31 = load i32, i32* %5
%32 = load i32, i32* %7
%33 = call i32 @glVertex3i(i32 0, i32 %31, i32 %32)
%34 = call i32 @glTexCoord2f(double 0.000000e+00, double 1.000000e+00)
%35 = call i32 @glColor3f(double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%36 = load i32, i32* %3
%37 = sub nsw i32 %36, 1
%38 = load i32, i32* %5
%39 = sub nsw i32 %37, %38
%40 = load i32, i32* %7
%41 = call i32 @glVertex3i(i32 %39, i32 0, i32 %40)
%42 = call i32 @glTexCoord2f(double 1.000000e+00, double 0.000000e+00)
%43 = call i32 @glColor3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%44 = load i32, i32* %5
%45 = load i32, i32* %3
%46 = sub nsw i32 %45, 1
%47 = load i32, i32* %5
%48 = sub nsw i32 %46, %47
%49 = load i32, i32* %7
%50 = call i32 @glVertex3i(i32 %44, i32 %48, i32 %49)
br label %51
51: ; preds = %19
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 5
store i32 %53, i32* %5
br label %15
54: ; preds = %15
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %10
58: ; preds = %10
%59 = call i32 (...) @glEnd()
%60 = load i32, i32* %4
%61 = load i32, i32* %3
%62 = mul nsw i32 %60, %61
%63 = sdiv i32 %62, 5
ret i32 %63
}

LLVM IR (-O2):
@GL_TRIANGLES = global i32 0
define i32 @test04(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 %32
6: ; preds = %2
%7 = icmp sgt i32 %0, 0
br label %8
8: ; preds = %6, %29
%9 = phi i32 [ 0, %6 ], [ %30, %29 ]
br i1 %7, label %10, label %29
10: ; preds = %8
%11 = sub i32 %1, %9
%12 = mul i32 %11, %0
br label %13
13: ; preds = %10, %13
%14 = phi i32 [ 0, %10 ], [ %27, %13 ]
%15 = sub i32 %12, %14
%16 = tail call i32 @glTexCoord2f(double 1.000000e+00, double 1.000000e+00)
%17 = tail call i32 @glColor3f(double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%18 = tail call i32 @glVertex3i(i32 0, i32 %14, i32 %15)
%19 = tail call i32 @glTexCoord2f(double 0.000000e+00, double 1.000000e+00)
%20 = tail call i32 @glColor3f(double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%21 = xor i32 %14, -1
%22 = add i32 %21, %0
%23 = tail call i32 @glVertex3i(i32 %22, i32 0, i32 %15)
%24 = tail call i32 @glTexCoord2f(double 1.000000e+00, double 0.000000e+00)
%25 = tail call i32 @glColor3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%26 = tail call i32 @glVertex3i(i32 %14, i32 %22, i32 %15)
%27 = add nuw nsw i32 %14, 5
%28 = icmp slt i32 %27, %0
br i1 %28, label %13, label %29
29: ; preds = %13, %8
%30 = add nuw nsw i32 %9, 1
%31 = icmp eq i32 %30, %1
br i1 %31, label %32, label %8
32: ; preds = %29, %2
%33 = tail call i32 (...) @glEnd()
%34 = mul nsw i32 %1, %0
%35 = sdiv i32 %34, 5
ret i32 %35
}