#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 */
typedef int GLint;
typedef float GLfloat;

/* Variables and functions */
int /*<<< orphan*/ GL_POLYGON;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glNormal3f(double, double, double);
int /*<<< orphan*/ glVertex3fv(float *);
void subDivide(float u1[3], float u2[3], float u3[3], int depth) {
  GLfloat u12[3];
  GLfloat u23[3];
  GLfloat u31[3];
  GLint i;
  if (depth == 0) {
    glBegin(GL_POLYGON);
    glNormal3f(0.0, 0.0, 1.0);
    glVertex3fv(u1);
    glNormal3f(0.0, 0.0, 1.0);
    glVertex3fv(u2);
    glNormal3f(0.0, 0.0, 1.0);
    glVertex3fv(u3);
    glEnd();
    return;
  }
  for (i = 0; i < 3; i++) {
    u12[i] = (u1[i] + u2[i]) / 2.0;
    u23[i] = (u2[i] + u3[i]) / 2.0;
    u31[i] = (u3[i] + u1[i]) / 2.0;
  }
  subDivide(u1, u12, u31, depth - 1);
  subDivide(u2, u23, u12, depth - 1);
  subDivide(u3, u31, u23, depth - 1);
  subDivide(u12, u23, u31, depth - 1);
}


x86 assembly (clang, -O0):
<subDivide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11df <subDivide+0x8f>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
xorps  %xmm1,%xmm1
movsd  0xe7e(%rip),%xmm2
movaps %xmm1,%xmm0
call   1070 <glNormal3f@plt>
mov    -0x8(%rbp),%rdi
call   1050 <glVertex3fv@plt>
xorps  %xmm1,%xmm1
movsd  0xe62(%rip),%xmm2
movaps %xmm1,%xmm0
call   1070 <glNormal3f@plt>
mov    -0x10(%rbp),%rdi
call   1050 <glVertex3fv@plt>
xorps  %xmm1,%xmm1
movsd  0xe46(%rip),%xmm2
movaps %xmm1,%xmm0
call   1070 <glNormal3f@plt>
mov    -0x18(%rbp),%rdi
call   1050 <glVertex3fv@plt>
mov    $0x0,%al
call   1030 <glEnd@plt>
jmp    1302 <subDivide+0x1b2>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    12a6 <subDivide+0x156>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdea(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x44(%rbp),%rax
movss  %xmm0,-0x28(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdb2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x44(%rbp),%rax
movss  %xmm0,-0x34(%rbp,%rax,4)
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd7a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x44(%rbp),%rax
movss  %xmm0,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11e6 <subDivide+0x96>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <subDivide@plt>
mov    -0x10(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <subDivide@plt>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x34(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <subDivide@plt>
lea    -0x28(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <subDivide@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subDivide>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
test   %ecx,%ecx
je     1291 <subDivide+0x141>
mov    %ecx,%ebp
movss  (%rbx),%xmm1
movss  (%r15),%xmm2
movaps %xmm1,%xmm3
addss  %xmm2,%xmm3
movss  0xe77(%rip),%xmm0
mulss  %xmm0,%xmm3
movss  %xmm3,0x1c(%rsp)
movss  (%r14),%xmm3
addss  %xmm3,%xmm2
mulss  %xmm0,%xmm2
movss  %xmm2,0x10(%rsp)
addss  %xmm3,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rbx),%xmm1
movss  0x4(%r15),%xmm2
movaps %xmm1,%xmm3
addss  %xmm2,%xmm3
mulss  %xmm0,%xmm3
movss  %xmm3,0x20(%rsp)
movss  0x4(%r14),%xmm3
addss  %xmm3,%xmm2
mulss  %xmm0,%xmm2
movss  %xmm2,0x14(%rsp)
addss  %xmm3,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0x8(%rbx),%xmm1
movss  0x8(%r15),%xmm2
movaps %xmm1,%xmm3
addss  %xmm2,%xmm3
mulss  %xmm0,%xmm3
movss  %xmm3,0x24(%rsp)
movss  0x8(%r14),%xmm3
addss  %xmm3,%xmm2
mulss  %xmm0,%xmm2
movss  %xmm2,0x18(%rsp)
addss  %xmm3,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
add    $0xffffffff,%ebp
lea    0x1c(%rsp),%r12
lea    0x4(%rsp),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %ebp,%ecx
call   1040 <subDivide@plt>
lea    0x10(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1040 <subDivide@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1040 <subDivide@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %ebp,%ecx
call   1040 <subDivide@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
movsd  0xd61(%rip),%xmm2
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
call   1070 <glNormal3f@plt>
mov    %rbx,%rdi
call   1050 <glVertex3fv@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movsd  0xd40(%rip),%xmm2
call   1070 <glNormal3f@plt>
mov    %r15,%rdi
call   1050 <glVertex3fv@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movsd  0xd25(%rip),%xmm2
call   1070 <glNormal3f@plt>
mov    %r14,%rdi
call   1050 <glVertex3fv@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <glEnd@plt>

LLVM IR (-O0):
@GL_POLYGON = global i32 0
define void @subDivide(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = alloca [3 x float]
%12 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store i32 %3, i32* %8
%13 = load i32, i32* %8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %4
%16 = load i32, i32* @GL_POLYGON
%17 = call i32 @glBegin(i32 %16)
%18 = call i32 @glNormal3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%19 = load float*, float** %5
%20 = call i32 @glVertex3fv(float* %19)
%21 = call i32 @glNormal3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%22 = load float*, float** %6
%23 = call i32 @glVertex3fv(float* %22)
%24 = call i32 @glNormal3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%25 = load float*, float** %7
%26 = call i32 @glVertex3fv(float* %25)
%27 = call i32 (...) @glEnd()
br label %108
28: ; preds = %4
store i32 0, i32* %12
br label %29
29: ; preds = %84, %28
%30 = load i32, i32* %12
%31 = icmp slt i32 %30, 3
br i1 %31, label %32, label %87
32: ; preds = %29
%33 = load float*, float** %5
%34 = load i32, i32* %12
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = load float*, float** %6
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = load float, float* %41
%43 = fadd float %37, %42
%44 = fpext float %43 to double
%45 = fdiv double %44, 2.000000e+00
%46 = fptrunc double %45 to float
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 %48
store float %46, float* %49
%50 = load float*, float** %6
%51 = load i32, i32* %12
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %50, i64 %52
%54 = load float, float* %53
%55 = load float*, float** %7
%56 = load i32, i32* %12
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %55, i64 %57
%59 = load float, float* %58
%60 = fadd float %54, %59
%61 = fpext float %60 to double
%62 = fdiv double %61, 2.000000e+00
%63 = fptrunc double %62 to float
%64 = load i32, i32* %12
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 %65
store float %63, float* %66
%67 = load float*, float** %7
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds float, float* %67, i64 %69
%71 = load float, float* %70
%72 = load float*, float** %5
%73 = load i32, i32* %12
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds float, float* %72, i64 %74
%76 = load float, float* %75
%77 = fadd float %71, %76
%78 = fpext float %77 to double
%79 = fdiv double %78, 2.000000e+00
%80 = fptrunc double %79 to float
%81 = load i32, i32* %12
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 %82
store float %80, float* %83
br label %84
84: ; preds = %32
%85 = load i32, i32* %12
%86 = add nsw i32 %85, 1
store i32 %86, i32* %12
br label %29
87: ; preds = %29
%88 = load float*, float** %5
%89 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%90 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%91 = load i32, i32* %8
%92 = sub nsw i32 %91, 1
%93 = load float*, float** %6
%94 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%95 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%96 = load i32, i32* %8
%97 = sub nsw i32 %96, 1
%98 = load float*, float** %7
%99 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%100 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%101 = load i32, i32* %8
%102 = sub nsw i32 %101, 1
%103 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%104 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%105 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%106 = load i32, i32* %8
%107 = sub nsw i32 %106, 1
br label %108
108: ; preds = %87, %15
ret void
}

LLVM IR (-O2):
@GL_POLYGON = global i32 0
define void @subDivide(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = bitcast [3 x float]* %5 to i8*
%9 = bitcast [3 x float]* %6 to i8*
%10 = bitcast [3 x float]* %7 to i8*
%11 = icmp eq i32 %3, 0
br i1 %11, label %56, label %12
12: ; preds = %4
%13 = load float, float* %0
%14 = load float, float* %1
%15 = fadd float %13, %14
%16 = fmul float %15, 5.000000e-01
%17 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %16, float* %17
%18 = load float, float* %2
%19 = fadd float %14, %18
%20 = fmul float %19, 5.000000e-01
%21 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
store float %20, float* %21
%22 = fadd float %13, %18
%23 = fmul float %22, 5.000000e-01
%24 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
store float %23, float* %24
%25 = getelementptr inbounds float, float* %0, i64 1
%26 = load float, float* %25
%27 = getelementptr inbounds float, float* %1, i64 1
%28 = load float, float* %27
%29 = fadd float %26, %28
%30 = fmul float %29, 5.000000e-01
%31 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %30, float* %31
%32 = getelementptr inbounds float, float* %2, i64 1
%33 = load float, float* %32
%34 = fadd float %28, %33
%35 = fmul float %34, 5.000000e-01
%36 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
store float %35, float* %36
%37 = fadd float %26, %33
%38 = fmul float %37, 5.000000e-01
%39 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
store float %38, float* %39
%40 = getelementptr inbounds float, float* %0, i64 2
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %1, i64 2
%43 = load float, float* %42
%44 = fadd float %41, %43
%45 = fmul float %44, 5.000000e-01
%46 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %45, float* %46
%47 = getelementptr inbounds float, float* %2, i64 2
%48 = load float, float* %47
%49 = fadd float %43, %48
%50 = fmul float %49, 5.000000e-01
%51 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
store float %50, float* %51
%52 = fadd float %41, %48
%53 = fmul float %52, 5.000000e-01
%54 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
store float %53, float* %54
%55 = add nsw i32 %3, -1
br label %66
56: ; preds = %4
%57 = load i32, i32* @GL_POLYGON
%58 = tail call i32 @glBegin(i32 %57)
%59 = tail call i32 @glNormal3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%60 = tail call i32 @glVertex3fv(float* %0)
%61 = tail call i32 @glNormal3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%62 = tail call i32 @glVertex3fv(float* %1)
%63 = tail call i32 @glNormal3f(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%64 = tail call i32 @glVertex3fv(float* %2)
%65 = tail call i32 (...) @glEnd()
br label %66
66: ; preds = %12, %56
ret void
}