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

/* Variables and functions */
int execlp(char *, char *, char *, char *, void *);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ usages();
int /*<<< orphan*/ waitpid(int /*<<< orphan*/);
int PdfMain(int argc, char *argv[]) {
  pid_t childs;
  if (argc < 3) {
    usages();
    return 0;
  }
  char command[2048] = {0};
  char filePath[1024] = {0};
  strcpy(filePath, "../temps/");
  strcat(filePath, argv[1]);
  strcat(filePath, ".txt");
  if ((childs = fork()) == 0) {
    if (execlp("pdftotext", "pdftotext", argv[1], filePath, (void *)0) == -1) {
      printf("error in  pharse  pdf\n");
      return 0;
    }
  }
  waitpid(childs);
  sprintf(command, "pdfinfo %s >> ../temps/pdf.txt", argv[1]);
  system(command);
  return 0;
}


x86 assembly (clang, -O0):
<PdfMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11cf <PdfMain+0x2f>
mov    $0x0,%al
call   1080 <usages@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c1 <PdfMain+0x121>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
lea    -0xc20(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0xc20(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xc20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1090 <strcat@plt>
lea    -0xc20(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1090 <strcat@plt>
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    128b <PdfMain+0xeb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0xc20(%rbp),%rcx
lea    0xdb2(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   10b0 <execlp@plt>
cmp    $0xffffffff,%eax
jne    1286 <PdfMain+0xe6>
lea    0xd9f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c1 <PdfMain+0x121>
jmp    128b <PdfMain+0xeb>
mov    -0x14(%rbp),%edi
call   1070 <waitpid@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd82(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PdfMain>:
push   %rbp
push   %rbx
sub    $0xc08,%rsp
cmp    $0x2,%edi
jg     11ba <PdfMain+0x1a>
xor    %eax,%eax
call   1080 <usages@plt>
jmp    1262 <PdfMain+0xc2>
mov    %rsi,%rbx
lea    0x400(%rsp),%rdi
mov    $0x800,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe16(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    0x8(%rbx),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
lea    0xe29(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1238 <PdfMain+0x98>
mov    0x8(%rbx),%rdx
lea    0xde5(%rip),%rdi
mov    %rsp,%rcx
mov    %rdi,%rsi
xor    %r8d,%r8d
call   10b0 <execlp@plt>
cmp    $0xffffffff,%eax
je     126e <PdfMain+0xce>
mov    %ebp,%edi
call   1070 <waitpid@plt>
mov    0x8(%rbx),%rdx
lea    0xdca(%rip),%rsi
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0xc08,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdbe(%rip),%rdi
call   1040 <puts@plt>
jmp    1262 <PdfMain+0xc2>

LLVM IR (-O0):
@.str = [10 x i8] c"../temps/\00"
@.str.1 = [5 x i8] c".txt\00"
@.str.2 = [10 x i8] c"pdftotext\00"
@.str.3 = [23 x i8] c"error in pharse pdf\0A\00"
@.str.4 = [31 x i8] c"pdfinfo %s >> ../temps/pdf.txt\00"
define i32 @PdfMain(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2048 x i8]
%8 = alloca [1024 x i8]
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @usages()
store i32 0, i32* %3
br label %47
13: ; preds = %2
%14 = bitcast [2048 x i8]* %7 to i8*
%15 = bitcast [1024 x i8]* %8 to i8*
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcat(i8* %18, i8* %21)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (...) @fork()
store i32 %25, i32* %6
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %13
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%32 = call i32 @execlp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %31, i8* null)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %27
%35 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %47
36: ; preds = %27
br label %37
37: ; preds = %36, %13
%38 = load i32, i32* %6
%39 = call i32 @waitpid(i32 %38)
%40 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%46 = call i32 @system(i8* %45)
store i32 0, i32* %3
br label %47
47: ; preds = %37, %34, %11
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [10 x i8] c"../temps/\00"
@.str.1 = [5 x i8] c".txt\00"
@.str.2 = [10 x i8] c"pdftotext\00"
@.str.4 = [31 x i8] c"pdfinfo %s >> ../temps/pdf.txt\00"
@str = [22 x i8] c"error in pharse pdf\00"
define i32 @PdfMain(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = alloca [1024 x i8]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @usages()
br label %30
8: ; preds = %2
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcat(i8* %10, i8* %13)
%15 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (...) @fork()
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %8
%19 = load i8*, i8** %12
%20 = call i32 @execlp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %10, i8* null)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %29
24: ; preds = %18, %8
%25 = call i32 @waitpid(i32 %16)
%26 = load i8*, i8** %12
%27 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %26)
%28 = call i32 @system(i8* %9)
br label %29
29: ; preds = %24, %22
br label %30
30: ; preds = %29, %6
ret i32 0
}