#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*/ close_postscript();
int init_postscript(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void postscript(void (*drawscreen)(void)) {
  static int piccount = 1;
  int success;
  char fname[20];
  sprintf(fname, "pic%d.ps", piccount);
  success = init_postscript(fname);
  if (success == 0)
    return;
  drawscreen();
  close_postscript();
  piccount++;
}


x86 assembly (clang, -O0):
<postscript>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2ef2(%rip),%edx
lea    0xeb3(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <init_postscript@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    116d <postscript+0x3d>
jmp    1186 <postscript+0x56>
call   *-0x8(%rbp)
mov    $0x0,%al
call   1030 <close_postscript@plt>
mov    0x2ebb(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb2(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<postscript>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    0x2ef8(%rip),%edx
lea    0xeb9(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <init_postscript@plt>
test   %eax,%eax
je     116f <postscript+0x3f>
call   *%r14
xor    %eax,%eax
call   1030 <close_postscript@plt>
addl   $0x1,0x2ec9(%rip)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@postscript.piccount = internal global i32 1
@.str = [9 x i8] c"pic%d.ps\00"
define void @postscript(void ()* %0) {
%2 = alloca void ()*
%3 = alloca i32
%4 = alloca [20 x i8]
store void ()* %0, void ()** %2
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @postscript.piccount
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = call i32 @init_postscript(i8* %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
br label %18
13: ; preds = %1
%14 = load void ()*, void ()** %2
%15 = call i32 (...) @close_postscript()
%16 = load i32, i32* @postscript.piccount
%17 = add nsw i32 %16, 1
store i32 %17, i32* @postscript.piccount
br label %18
18: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
@postscript.piccount = internal unnamed_addr global i32 1
@.str = [9 x i8] c"pic%d.ps\00"
define void @postscript(void ()* nocapture %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @postscript.piccount
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @init_postscript(i8* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = call i32 (...) @close_postscript()
%10 = load i32, i32* @postscript.piccount
%11 = add nsw i32 %10, 1
store i32 %11, i32* @postscript.piccount
br label %12
12: ; preds = %1, %8
ret void
}