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

/* Variables and functions */
int /*<<< orphan*/ GL_3D_COLOR;
int /*<<< orphan*/ GL_FEEDBACK;
int /*<<< orphan*/ GL_RENDER;
int /*<<< orphan*/ *calloc(int, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ glFeedbackBuffer(int, int /*<<< orphan*/,
                                    int /*<<< orphan*/ *);
int /*<<< orphan*/ glRenderMode(int /*<<< orphan*/);
int /*<<< orphan*/ printBuffer(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ render();
int /*<<< orphan*/ spewWireFrameEPS(int /*<<< orphan*/ *, int,
                                    int /*<<< orphan*/, int /*<<< orphan*/ *,
                                    char *);
void outputEPS(int size, int doSort, char *filename) {
  GLfloat *feedbackBuffer;
  GLint returned;
  FILE *file;
  feedbackBuffer = calloc(size, sizeof(GLfloat));
  glFeedbackBuffer(size, GL_3D_COLOR, feedbackBuffer);
  (void)glRenderMode(GL_FEEDBACK);
  render();
  returned = glRenderMode(GL_RENDER);
  if (filename) {
    file = fopen(filename, "w");
    if (file) {
      spewWireFrameEPS(file, doSort, returned, feedbackBuffer, "rendereps");
    } else {
      printf("Could not open %s\n", filename);
    }
  } else {
    printBuffer(returned, feedbackBuffer);
  }
  free(feedbackBuffer);
}


x86 assembly (clang, -O0):
<outputEPS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   10a0 <glFeedbackBuffer@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1080 <glRenderMode@plt>
mov    $0x0,%al
call   1050 <render@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1080 <glRenderMode@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     124c <outputEPS+0xbc>
mov    -0x10(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1237 <outputEPS+0xa7>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xdd5(%rip),%r8
call   1060 <spewWireFrameEPS@plt>
jmp    1247 <outputEPS+0xb7>
mov    -0x10(%rbp),%rsi
lea    0xdca(%rip),%rdi
call   1040 <printf@plt>
jmp    1258 <outputEPS+0xc8>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1090 <printBuffer@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outputEPS>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %rbx,%rdx
call   10a0 <glFeedbackBuffer@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1080 <glRenderMode@plt>
xor    %eax,%eax
call   1050 <render@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1080 <glRenderMode@plt>
mov    %eax,%ebp
test   %r15,%r15
je     1216 <outputEPS+0x86>
lea    0xe10(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1222 <outputEPS+0x92>
lea    0xdfe(%rip),%r8
mov    %rax,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1060 <spewWireFrameEPS@plt>
jmp    1231 <outputEPS+0xa1>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1090 <printBuffer@plt>
jmp    1231 <outputEPS+0xa1>
lea    0xde3(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@GL_3D_COLOR = global i32 0
@GL_FEEDBACK = global i32 0
@GL_RENDER = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [10 x i8] c"rendereps\00"
@.str.2 = [19 x i8] c"Could not open %s\0A\00"
define void @outputEPS(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i32, i32* %4
%11 = call i32* @calloc(i32 %10, i32 4)
store i32* %11, i32** %7
%12 = load i32, i32* %4
%13 = load i32, i32* @GL_3D_COLOR
%14 = load i32*, i32** %7
%15 = call i32 @glFeedbackBuffer(i32 %12, i32 %13, i32* %14)
%16 = load i32, i32* @GL_FEEDBACK
%17 = call i32 @glRenderMode(i32 %16)
%18 = call i32 (...) @render()
%19 = load i32, i32* @GL_RENDER
%20 = call i32 @glRenderMode(i32 %19)
store i32 %20, i32* %8
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %38
23: ; preds = %3
%24 = load i8*, i8** %6
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %9
%26 = load i32*, i32** %9
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load i32*, i32** %9
%30 = load i32, i32* %5
%31 = load i32, i32* %8
%32 = load i32*, i32** %7
%33 = call i32 @spewWireFrameEPS(i32* %29, i32 %30, i32 %31, i32* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %37
34: ; preds = %23
%35 = load i8*, i8** %6
%36 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %28
br label %42
38: ; preds = %3
%39 = load i32, i32* %8
%40 = load i32*, i32** %7
%41 = call i32 @printBuffer(i32 %39, i32* %40)
br label %42
42: ; preds = %38, %37
%43 = load i32*, i32** %7
%44 = call i32 @free(i32* %43)
ret void
}

LLVM IR (-O2):
@GL_3D_COLOR = global i32 0
@GL_FEEDBACK = global i32 0
@GL_RENDER = global i32 0
@.str = [2 x i8] c"w\00"
@.str.1 = [10 x i8] c"rendereps\00"
@.str.2 = [19 x i8] c"Could not open %s\0A\00"
define void @outputEPS(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32* @calloc(i32 %0, i32 4)
%5 = load i32, i32* @GL_3D_COLOR
%6 = tail call i32 @glFeedbackBuffer(i32 %0, i32 %5, i32* %4)
%7 = load i32, i32* @GL_FEEDBACK
%8 = tail call i32 @glRenderMode(i32 %7)
%9 = tail call i32 (...) @render()
%10 = load i32, i32* @GL_RENDER
%11 = tail call i32 @glRenderMode(i32 %10)
%12 = icmp eq i8* %2, null
br i1 %12, label %20, label %13
13: ; preds = %3
%14 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @spewWireFrameEPS(i32* %14, i32 %1, i32 %11, i32* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %22
18: ; preds = %13
%19 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %22
20: ; preds = %3
%21 = tail call i32 @printBuffer(i32 %11, i32* %4)
br label %22
22: ; preds = %16, %18, %20
%23 = tail call i32 @free(i32* %4)
ret void
}