#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 print_to_pdf(char *cyclenum, char *lines, char *author, char *pcl) {
  FILE *pFile;
  FILE *newpdfFile;
  char cp_pcl[128];
  char newpdf[128];
  char prntcmnd[128];
  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\n\n");
    else
      printf("6: PRINT TO PDF SUCCESSFUL\n\n\n");
  } else
    printf("6: PDF FILE ALREADY CREATED\n\n\n");
  sprintf(cp_pcl, "cp /var/www/active_log.txt /var/www/pcl/cycle_%s.pcl",
          cyclenum);
  system(cp_pcl);
  pFile = fopen("/var/www/active_log.txt", "w");
  fclose(pFile);
}


x86 assembly (clang, -O0):
<print_to_pdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x1b0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x8(%rbp),%rax
lea    0xe73(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdi
lea    0xeca(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1223 <print_to_pdf+0xd3>
lea    -0x1b0(%rbp),%rdi
call   1040 <system@plt>
lea    -0x130(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1212 <print_to_pdf+0xc2>
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
jmp    121e <print_to_pdf+0xce>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
jmp    122f <print_to_pdf+0xdf>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <system@plt>
lea    0xeb9(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_to_pdf>:
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    %rcx,%r8
mov    %rdx,%r9
mov    %rsi,%rcx
mov    %rdi,%rbx
mov    %rdi,(%rsp)
lea    0xe8f(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xee8(%rip),%rsi
lea    0x90(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xee6(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b9 <print_to_pdf+0x69>
lea    0xf23(%rip),%rdi
jmp    11ec <print_to_pdf+0x9c>
lea    0x10(%rsp),%rdi
call   1050 <system@plt>
lea    0xebf(%rip),%rsi
lea    0x90(%rsp),%rdi
call   1060 <fopen@plt>
test   %rax,%rax
lea    0xf34(%rip),%rax
lea    0xf10(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xe93(%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    0xea4(%rip),%rdi
lea    0xeb5(%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 = [23 x i8] c"PRINT TO PDF FAILED\0A\0A\0A\00"
@.str.4 = [30 x i8] c"6: PRINT TO PDF SUCCESSFUL\0A\0A\0A\00"
@.str.5 = [31 x i8] c"6: PDF FILE ALREADY CREATED\0A\0A\0A\00"
@.str.6 = [53 x i8] c"cp /var/www/active_log.txt /var/www/pcl/cycle_%s.pcl\00"
@.str.7 = [24 x i8] c"/var/www/active_log.txt\00"
@.str.8 = [2 x i8] c"w\00"
define void @print_to_pdf(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [128 x i8]
%12 = alloca [128 x i8]
%13 = alloca [128 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = load i8*, i8** %8
%18 = load i8*, i8** %7
%19 = load i8*, i8** %5
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16, i8* %17, i8* %18, i8* %19)
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %25, i32** %10
%26 = load i32*, i32** %10
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %40
28: ; preds = %4
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%30 = call i32 @system(i8* %29)
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %10
%33 = load i32*, i32** %10
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %39
37: ; preds = %28
%38 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
br label %42
40: ; preds = %4
%41 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %39
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%44 = load i8*, i8** %5
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %43, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%47 = call i32 @system(i8* %46)
%48 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %48, i32** %9
%49 = load i32*, i32** %9
%50 = call i32 @fclose(i32* %49)
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.7 = [24 x i8] c"/var/www/active_log.txt\00"
@.str.8 = [2 x i8] c"w\00"
@str = [30 x i8] c"6: PDF FILE ALREADY CREATED\0A\0A\00"
@str.9 = [29 x i8] c"6: PRINT TO PDF SUCCESSFUL\0A\0A\00"
@str.10 = [22 x i8] c"PRINT TO PDF FAILED\0A\0A\00"
define void @print_to_pdf(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca [128 x i8]
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%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 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %10, 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)
%12 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %4
%16 = call i32 @system(i8* %10)
%17 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32* %17, null
%19 = select i1 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0)
br label %20
20: ; preds = %4, %15
%21 = phi i8* [ %19, %15 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0), %4 ]
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
%23 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%24 = call i32 @system(i8* %8)
%25 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%26 = tail call i32 @fclose(i32* %25)
ret void
}