#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 */
scalar_t__ fabsf(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, float, int, float, int);
int /*<<< orphan*/ frustum(float *, double, double, int, int, double, double);
int /*<<< orphan*/ stderr;
bool test_frustum() {
  bool result = true;
  float f[16];
  frustum(f, -1.0, 1.0, 300, -300, 5.0, 200.0);
  float e[] = {5.0f, 0.0f, 0.0f,        0.0f,  0.0f,       -0.01667f,
               0.0f, 0.0f, 0.0f,        -0.0f, -1.051282f, -1.0f,
               0.0f, 0.0f, -10.256411f, 0.0f};
  for (int i = 0; i < 16; i++) {
    while (fabsf((e)[i] - (f)[i]) > fabsf(0.01 * (e)[i])) {
      fprintf(stderr,
              "compare failed: value:    "
              "%f ("
              "f"
              "[%d])\n"
              "                expected: "
              "%f ("
              "e"
              "[%d])\n",
              (f)[i], i, (e)[i], i);
      result = false;
      break;
    };
  }
  return result;
}


x86 assembly (clang, -O0):
<test_frustum>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x1,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
movsd  0xeba(%rip),%xmm0
movsd  0xeba(%rip),%xmm1
mov    $0x12c,%esi
mov    $0xfffffed4,%edx
movsd  0xeb0(%rip),%xmm2
movsd  0xeb0(%rip),%xmm3
call   1060 <frustum@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movss  0xe74(%rip),%xmm0
movss  %xmm0,-0x90(%rbp)
ff
movss  0xe60(%rip),%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  0xe4f(%rip),%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  0xe3e(%rip),%xmm0
movss  %xmm0,-0x68(%rbp)
movss  0xe2d(%rip),%xmm0
movss  %xmm0,-0x64(%rbp)
movss  0xe1c(%rip),%xmm0
movss  %xmm0,-0x58(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x10,-0x94(%rbp)
jge    12c8 <test_frustum+0x188>
jmp    1205 <test_frustum+0xc5>
movslq -0x94(%rbp),%rax
movss  -0x90(%rbp,%rax,4),%xmm0
ff ff
movslq -0x94(%rbp),%rax
subss  -0x50(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <fabsf@plt>
mov    %rax,-0xa0(%rbp)
movslq -0x94(%rbp),%rax
movss  -0x90(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm1
movsd  0xdea(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <fabsf@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
cmp    %rcx,%rax
jle    12af <test_frustum+0x16f>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
movslq -0x94(%rbp),%rax
movss  -0x50(%rbp,%rax,4),%xmm0
mov    -0x94(%rbp),%edx
movslq -0x94(%rbp),%rax
movss  -0x90(%rbp,%rax,4),%xmm1
ff ff
mov    -0x94(%rbp),%ecx
lea    0xd9d(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <test_frustum+0x174>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11f3 <test_frustum+0xb3>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_frustum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
lea    0x50(%rsp),%rdi
movsd  0xeb4(%rip),%xmm0
movsd  0xeb4(%rip),%xmm1
movsd  0xeb4(%rip),%xmm2
movsd  0xeb4(%rip),%xmm3
mov    $0x12c,%esi
mov    $0xfffffed4,%edx
call   1050 <frustum@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movl   $0x40a00000,0x10(%rsp)
40
movl   $0xbc888f86,0x24(%rsp)
bc
movabs $0xbf86906980000000,%rax
90 86 bf
mov    %rax,0x34(%rsp)
movl   $0xbf800000,0x3c(%rsp)
bf
movl   $0xc1241a42,0x48(%rsp)
c1
mov    $0x1,%r15d
movss  0xe61(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
xor    %ebx,%ebx
mov    0x2e0a(%rip),%r12
lea    0xe4f(%rip),%r14
nopl   (%rax)
movss  0xc(%rsp),%xmm0
subss  0x50(%rsp,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <fabsf@plt>
mov    %rax,%rbp
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe16(%rip),%xmm0
call   1030 <fabsf@plt>
cmp    %rax,%rbp
jle    1233 <test_frustum+0x103>
mov    (%r12),%edi
movss  0x50(%rsp,%rbx,4),%xmm0
mov    %r14,%rsi
mov    %ebx,%edx
movss  0xc(%rsp),%xmm1
mov    %ebx,%ecx
call   1040 <fprintf@plt>
xor    %r15d,%r15d
cmp    $0xf,%rbx
je     124b <test_frustum+0x11b>
movss  0x14(%rsp,%rbx,4),%xmm0
movss  %xmm0,0xc(%rsp)
add    $0x1,%rbx
jmp    11e0 <test_frustum+0xb0>
mov    %r15d,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [75 x i8] c"compare failed: value: %f (f[%d])\0A expected: %f (e[%d])\0A\00"
define i32 @test_frustum() {
%1 = alloca i32
%2 = alloca [16 x float]
%3 = alloca [16 x float]
%4 = alloca i32
store i32 1, i32* %1
%5 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 0
%6 = call i32 @frustum(float* %5, double -1.000000e+00, double 1.000000e+00, i32 300, i32 -300, double 5.000000e+00, double 2.000000e+02)
%7 = bitcast [16 x float]* %3 to i8*
%8 = bitcast i8* %7 to [16 x float]*
%9 = getelementptr inbounds [16 x float], [16 x float]* %8, i32 0, i32 0
store float 5.000000e+00, float* %9
%10 = getelementptr inbounds [16 x float], [16 x float]* %8, i32 0, i32 5
store float 0xBF9111F0C0000000, float* %10
%11 = getelementptr inbounds [16 x float], [16 x float]* %8, i32 0, i32 9
store float -0.000000e+00, float* %11
%12 = getelementptr inbounds [16 x float], [16 x float]* %8, i32 0, i32 10
store float 0xBFF0D20D20000000, float* %12
%13 = getelementptr inbounds [16 x float], [16 x float]* %8, i32 0, i32 11
store float -1.000000e+00, float* %13
%14 = getelementptr inbounds [16 x float], [16 x float]* %8, i32 0, i32 14
store float 0xC024834840000000, float* %14
store i32 0, i32* %4
br label %15
15: ; preds = %53, %0
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %56
18: ; preds = %15
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [16 x float], [16 x float]* %3, i64 0, i64 %21
%23 = load float, float* %22
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 %25
%27 = load float, float* %26
%28 = fsub float %23, %27
%29 = fpext float %28 to double
%30 = call i64 @fabsf(double %29)
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [16 x float], [16 x float]* %3, i64 0, i64 %32
%34 = load float, float* %33
%35 = fpext float %34 to double
%36 = fmul double 1.000000e-02, %35
%37 = call i64 @fabsf(double %36)
%38 = icmp sgt i64 %30, %37
br i1 %38, label %39, label %52
39: ; preds = %19
%40 = load i32, i32* @stderr
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 %42
%44 = load float, float* %43
%45 = load i32, i32* %4
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [16 x float], [16 x float]* %3, i64 0, i64 %47
%49 = load float, float* %48
%50 = load i32, i32* %4
%51 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), float %44, i32 %45, float %49, i32 %50)
store i32 0, i32* %1
br label %52
52: ; preds = %39, %19
br label %53
53: ; preds = %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %15
56: ; preds = %15
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [75 x i8] c"compare failed: value: %f (f[%d])\0A expected: %f (e[%d])\0A\00"
define i32 @test_frustum() {
%1 = alloca [16 x float]
%2 = alloca [16 x float]
%3 = bitcast [16 x float]* %1 to i8*
%4 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 0
%5 = call i32 @frustum(float* %4, double -1.000000e+00, double 1.000000e+00, i32 300, i32 -300, double 5.000000e+00, double 2.000000e+02)
%6 = bitcast [16 x float]* %2 to i8*
%7 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 0
store float 5.000000e+00, float* %7
%8 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 5
store float 0xBF9111F0C0000000, float* %8
%9 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 9
store float -0.000000e+00, float* %9
%10 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 10
store float 0xBFF0D20D20000000, float* %10
%11 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 11
store float -1.000000e+00, float* %11
%12 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 14
store float 0xC024834840000000, float* %12
br label %14
13: ; preds = %32
ret i32 %33
14: ; preds = %36, %0
%15 = phi float [ 5.000000e+00, %0 ], [ %38, %36 ]
%16 = phi i64 [ 0, %0 ], [ %34, %36 ]
%17 = phi i32 [ 1, %0 ], [ %33, %36 ]
%18 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 %16
%19 = load float, float* %18
%20 = fsub float %15, %19
%21 = fpext float %20 to double
%22 = call i64 @fabsf(double %21)
%23 = fpext float %15 to double
%24 = fmul double %23, 1.000000e-02
%25 = call i64 @fabsf(double %24)
%26 = icmp sgt i64 %22, %25
br i1 %26, label %27, label %32
27: ; preds = %14
%28 = load i32, i32* @stderr
%29 = load float, float* %18
%30 = trunc i64 %16 to i32
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), float %29, i32 %30, float %15, i32 %30)
br label %32
32: ; preds = %14, %27
%33 = phi i32 [ 0, %27 ], [ %17, %14 ]
%34 = add nuw nsw i64 %16, 1
%35 = icmp eq i64 %34, 16
br i1 %35, label %13, label %36
36: ; preds = %32
%37 = getelementptr inbounds [16 x float], [16 x float]* %2, i64 0, i64 %34
%38 = load float, float* %37
br label %14
}