#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 */
char *basename(char *);
int /*<<< orphan*/ copyFile(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ processFile(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
int main(int argc, char **argv) {
  int j, unit, t;
  char **mem;
  char *ptfDirName;
  char *externalFileName;
  char *ptfFileName;
  if (argc < 3) {
    fprintf(stderr, "Usage %s <ptf-dir> <external-file>\n", argv[0]);
    exit(1);
  }
  ptfDirName = strdup(argv[1]);
  externalFileName = strdup(argv[2]);
  sprintf(ptfFileName, "%s/%s", ptfDirName, basename(externalFileName));
  printf("PTF Dir:         %s\n", ptfDirName);
  printf("External File:   %s\n", externalFileName);
  printf("Ptf File:        %s\n", ptfFileName);
  copyFile(externalFileName, ptfFileName);
  for (unit = 0; unit < 20; unit++) {
    int fd;
    for (t = 0, j = 0; j < 1000000 * 200; j++) {
      t = j + unit * 2;
    }
    processFile(ptfFileName);
    printf("Unit %d done\n", unit);
  }
  copyFile(ptfFileName, externalFileName);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c6 <main+0x46>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <basename@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    %rax,%rcx
lea    0xe11(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <copyFile@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jge    12cb <main+0x14b>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xbebc200,-0x14(%rbp)
jge    12a3 <main+0x123>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    127a <main+0xfa>
mov    -0x40(%rbp),%rdi
call   1040 <processFile@plt>
mov    -0x18(%rbp),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1262 <main+0xe2>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <copyFile@plt>
mov    $0x1,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    13a2 <main+0x222>
mov    0x8(%rbx),%rdi
call   10a0 <strdup@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
call   10a0 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <basename@plt>
lea    0xe6c(%rip),%rsi
mov    %r15,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
lea    0xe60(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
call   1070 <copyFile@plt>
call   1040 <processFile@plt>
lea    0xe62(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <processFile@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rsi
call   1070 <copyFile@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc4b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Usage %s <ptf-dir> <external-file>\0A\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [21 x i8] c"PTF Dir: %s\0A\00"
@.str.3 = [21 x i8] c"External File: %s\0A\00"
@.str.4 = [21 x i8] c"Ptf File: %s\0A\00"
@.str.5 = [14 x i8] c"Unit %d done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i8* @strdup(i8* %26)
store i8* %27, i8** %10
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %11
%32 = load i8*, i8** %12
%33 = load i8*, i8** %10
%34 = load i8*, i8** %11
%35 = call i8* @basename(i8* %34)
%36 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %35)
%37 = load i8*, i8** %10
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %11
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %12
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %11
%44 = load i8*, i8** %12
%45 = call i32 @copyFile(i8* %43, i8* %44)
store i32 0, i32* %7
br label %46
46: ; preds = %66, %23
%47 = load i32, i32* %7
%48 = icmp slt i32 %47, 20
br i1 %48, label %49, label %69
49: ; preds = %46
store i32 0, i32* %8
store i32 0, i32* %6
br label %50
50: ; preds = %58, %49
%51 = load i32, i32* %6
%52 = icmp slt i32 %51, 200000000
br i1 %52, label %53, label %61
53: ; preds = %50
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = mul nsw i32 %55, 2
%57 = add nsw i32 %54, %56
store i32 %57, i32* %8
br label %58
58: ; preds = %53
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %50
61: ; preds = %50
%62 = load i8*, i8** %12
%63 = call i32 @processFile(i8* %62)
%64 = load i32, i32* %7
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %61
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %46
69: ; preds = %46
%70 = load i8*, i8** %12
%71 = load i8*, i8** %11
%72 = call i32 @copyFile(i8* %70, i8* %71)
ret i32 1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Usage %s <ptf-dir> <external-file>\0A\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [21 x i8] c"PTF Dir: %s\0A\00"
@.str.3 = [21 x i8] c"External File: %s\0A\00"
@.str.4 = [21 x i8] c"Ptf File: %s\0A\00"
@.str.5 = [14 x i8] c"Unit %d done\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i8* @strdup(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i8* @strdup(i8* %14)
%16 = tail call i8* @basename(i8* %15)
%17 = tail call i32 @sprintf(i8* dereferenceable(1) undef, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* undef)
%21 = tail call i32 @copyFile(i8* %15, i8* undef)
%22 = tail call i32 @processFile(i8* undef)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0)
%24 = tail call i32 @processFile(i8* undef)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1)
%26 = tail call i32 @processFile(i8* undef)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2)
%28 = tail call i32 @processFile(i8* undef)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 3)
%30 = tail call i32 @processFile(i8* undef)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 4)
%32 = tail call i32 @processFile(i8* undef)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 5)
%34 = tail call i32 @processFile(i8* undef)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 6)
%36 = tail call i32 @processFile(i8* undef)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 7)
%38 = tail call i32 @processFile(i8* undef)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 8)
%40 = tail call i32 @processFile(i8* undef)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 9)
%42 = tail call i32 @processFile(i8* undef)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 10)
%44 = tail call i32 @processFile(i8* undef)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 11)
%46 = tail call i32 @processFile(i8* undef)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 12)
%48 = tail call i32 @processFile(i8* undef)
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 13)
%50 = tail call i32 @processFile(i8* undef)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 14)
%52 = tail call i32 @processFile(i8* undef)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 15)
%54 = tail call i32 @processFile(i8* undef)
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 16)
%56 = tail call i32 @processFile(i8* undef)
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 17)
%58 = tail call i32 @processFile(i8* undef)
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 18)
%60 = tail call i32 @processFile(i8* undef)
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 19)
%62 = tail call i32 @copyFile(i8* undef, i8* %15)
ret i32 1
}