#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ system(char *);
void out_to_print(char *cyclenum, char *lines, char *author, char *pcl,
                  int PDF) {
  FILE *pFile;
  FILE *newpdfFile;
  char cp_pcl[128];
  char newpdf[128];
  char prntcmnd[128];
  if (PDF == 1) {
    sprintf(prntcmnd,
            "/var/www/apps/pcl_to_pdf /var/www/pdf/cycle_%s.pdf "
            "/var/www/active_log.txt %s %s\'%s\' cycle-to-pdf cycle_%s.pdf",
            cyclenum, lines, pcl, author, cyclenum);
    sprintf(newpdf, "/var/www/pdf/cycle_%s.pdf", cyclenum);
    newpdfFile = fopen(newpdf, "r");
    if (newpdfFile == NULL) {
      system(prntcmnd);
      newpdfFile = fopen(newpdf, "r");
      if (newpdfFile == NULL)
        printf("PRINT TO PDF FAILED\n");
      else
        printf("PRINT TO PDF SUCCESSFUL\n");
    } else
      printf("PDF FILE ALREADY CREATED\n");
    sprintf(cp_pcl, "cp /var/www/active_log.txt /var/www/pcl/cycle_%s.pcl",
            cyclenum);
    system(cp_pcl);
  } else
    printf("PDF NOT PRINTED\n");
  system("/var/www/apps/print.sh");
  pFile = fopen("/var/www/active_log.txt", "w");
  fclose(pFile);
}


x86 assembly (clang, -O0):
<out_to_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1267 <out_to_print+0x117>
lea    -0x1c0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x8(%rbp),%rax
lea    0xe65(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1231 <out_to_print+0xe1>
lea    -0x1c0(%rbp),%rdi
call   1040 <system@plt>
lea    -0x140(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1220 <out_to_print+0xd0>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
jmp    122c <out_to_print+0xdc>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
jmp    123d <out_to_print+0xed>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    -0xc0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0xc0(%rbp),%rdi
call   1040 <system@plt>
jmp    1273 <out_to_print+0x123>
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
call   1040 <system@plt>
lea    0xeaa(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<out_to_print>:
push   %r14
push   %rbx
sub    $0x198,%rsp
cmp    $0x1,%r8d
jne    11c2 <out_to_print+0x72>
mov    %rcx,%rax
mov    %rdx,%r9
mov    %rsi,%rcx
mov    %rdi,%rbx
mov    %rdi,(%rsp)
lea    0xe89(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rbx,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xedf(%rip),%rsi
lea    0x90(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xedd(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d0 <out_to_print+0x80>
lea    0xf41(%rip),%rdi
jmp    1203 <out_to_print+0xb3>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
jmp    122c <out_to_print+0xdc>
lea    0x10(%rsp),%rdi
call   1050 <system@plt>
lea    0xea8(%rip),%rsi
lea    0x90(%rsp),%rdi
call   1060 <fopen@plt>
test   %rax,%rax
lea    0xf3a(%rip),%rax
lea    0xf1b(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rsi
lea    0x110(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
lea    0xe8d(%rip),%rdi
call   1050 <system@plt>
lea    0xe98(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rdi
add    $0x198,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [111 x i8] c"/var/www/apps/pcl_to_pdf /var/www/pdf/cycle_%s.pdf /var/www/active_log.txt %s %s'%s' cycle-to-pdf cycle_%s.pdf\00"
@.str.1 = [26 x i8] c"/var/www/pdf/cycle_%s.pdf\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [21 x i8] c"PRINT TO PDF FAILED\0A\00"
@.str.4 = [25 x i8] c"PRINT TO PDF SUCCESSFUL\0A\00"
@.str.5 = [26 x i8] c"PDF FILE ALREADY CREATED\0A\00"
@.str.6 = [53 x i8] c"cp /var/www/active_log.txt /var/www/pcl/cycle_%s.pcl\00"
@.str.7 = [17 x i8] c"PDF NOT PRINTED\0A\00"
@.str.8 = [23 x i8] c"/var/www/apps/print.sh\00"
@.str.9 = [24 x i8] c"/var/www/active_log.txt\00"
@.str.10 = [2 x i8] c"w\00"
define void @out_to_print(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca [128 x i8]
%14 = alloca [128 x i8]
%15 = alloca [128 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%16 = load i32, i32* %10
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %53
18: ; preds = %5
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = load i8*, i8** %9
%23 = load i8*, i8** %8
%24 = load i8*, i8** %6
%25 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %21, i8* %22, i8* %23, i8* %24)
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%27 = load i8*, i8** %6
%28 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %12
%31 = load i32*, i32** %12
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %45
33: ; preds = %18
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%35 = call i32 @system(i8* %34)
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %37, i32** %12
%38 = load i32*, i32** %12
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %33
%41 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %44
42: ; preds = %33
%43 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
br label %47
45: ; preds = %18
%46 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %47
47: ; preds = %45, %44
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%49 = load i8*, i8** %6
%50 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%52 = call i32 @system(i8* %51)
br label %55
53: ; preds = %5
%54 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %55
55: ; preds = %53, %47
%56 = call i32 @system(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%57 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %57, i32** %11
%58 = load i32*, i32** %11
%59 = call i32 @fclose(i32* %58)
ret void
}

LLVM IR (-O2):
@.str = [111 x i8] c"/var/www/apps/pcl_to_pdf /var/www/pdf/cycle_%s.pdf /var/www/active_log.txt %s %s'%s' cycle-to-pdf cycle_%s.pdf\00"
@.str.1 = [26 x i8] c"/var/www/pdf/cycle_%s.pdf\00"
@.str.2 = [2 x i8] c"r\00"
@.str.6 = [53 x i8] c"cp /var/www/active_log.txt /var/www/pcl/cycle_%s.pcl\00"
@.str.8 = [23 x i8] c"/var/www/apps/print.sh\00"
@.str.9 = [24 x i8] c"/var/www/active_log.txt\00"
@.str.10 = [2 x i8] c"w\00"
@str = [16 x i8] c"PDF NOT PRINTED\00"
@str.11 = [25 x i8] c"PDF FILE ALREADY CREATED\00"
@str.12 = [24 x i8] c"PRINT TO PDF SUCCESSFUL\00"
@str.13 = [20 x i8] c"PRINT TO PDF FAILED\00"
define void @out_to_print(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [128 x i8]
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%12 = icmp eq i32 %4, 1
br i1 %12, label %13, label %28
13: ; preds = %5
%14 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %3, i8* %2, i8* %0)
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%16 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = call i32 @system(i8* %11)
%20 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
%22 = select i1 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.12, i64 0, i64 0)
br label %23
23: ; preds = %13, %18
%24 = phi i8* [ %22, %18 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0), %13 ]
%25 = tail call i32 @puts(i8* dereferenceable(1) %24)
%26 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%27 = call i32 @system(i8* %9)
br label %30
28: ; preds = %5
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %28, %23
%31 = tail call i32 @system(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%32 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%33 = tail call i32 @fclose(i32* %32)
ret void
}