#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*/ CreateCopyProductsBat(int /*<<< orphan*/ *);
int /*<<< orphan*/ CreateIOCTLSampleHeader(int /*<<< orphan*/ *);
int /*<<< orphan*/ CreateSignDriversBat(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void main(int argc, char **argv) {
  char FullPath[1024];
  char *Filename;
  FILE *File;
  if (argc > 2) {
    printf("Usage: %s [<BAT output directory>]\n");
    return;
  }
  Filename = FullPath;
  if (argc == 2) {
    strcpy(FullPath, argv[1]);
    Filename = FullPath + strlen(FullPath);
    if (*(Filename - 1) != '\\')
      *(Filename++) = '\\';
  }
  strcpy(Filename, "CopyProducts.bat");
  File = fopen(FullPath, "w");
  if (!File) {
    printf("Error creating file %s\n", FullPath);
    return;
  }
  CreateCopyProductsBat(File);
  fclose(File);
  strcpy(Filename, "ppjioctl_devname.h");
  File = fopen(FullPath, "w");
  if (!File) {
    printf("Error creating file %s\n", FullPath);
    return;
  }
  CreateIOCTLSampleHeader(File);
  fclose(File);
  strcpy(Filename, "SignDriverFiles.bat");
  File = fopen(FullPath, "w");
  if (!File) {
    printf("Error creating file %s\n", FullPath);
    return;
  }
  CreateSignDriversBat(File);
  fclose(File);
  printf("--- done ---\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    11af <main+0x2f>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1391 <main+0x211>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    123c <main+0xbc>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x428(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
je     1237 <main+0xb7>
mov    -0x418(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x418(%rbp)
movb   $0x5c,(%rax)
jmp    123c <main+0xbc>
mov    -0x418(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    1291 <main+0x111>
lea    -0x410(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1391 <main+0x211>
mov    -0x420(%rbp),%rdi
call   1080 <CreateCopyProductsBat@plt>
mov    -0x420(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x418(%rbp),%rdi
lea    0xd98(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    12fe <main+0x17e>
lea    -0x410(%rbp),%rsi
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1391 <main+0x211>
mov    -0x420(%rbp),%rdi
call   10a0 <CreateIOCTLSampleHeader@plt>
mov    -0x420(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x418(%rbp),%rdi
lea    0xd3e(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xcfe(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    136b <main+0x1eb>
lea    -0x410(%rbp),%rsi
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1391 <main+0x211>
mov    -0x420(%rbp),%rdi
call   1070 <CreateSignDriversBat@plt>
mov    -0x420(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x3,%edi
jl     11a3 <main+0x13>
lea    0xe64(%rip),%rdi
xor    %eax,%eax
jmp    1070 <printf@plt>
push   %r14
push   %rbx
sub    $0x408,%rsp
cmp    $0x2,%edi
jne    11e0 <main+0x50>
mov    0x8(%rsi),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%r14
cmpb   $0x5c,-0x1(%rsp,%rax,1)
je     11e3 <main+0x53>
movb   $0x5c,(%r14)
add    $0x1,%r14
jmp    11e3 <main+0x53>
mov    %rsp,%r14
lea    0xe3a(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe3c(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1297 <main+0x107>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <CreateCopyProductsBat@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xe2b(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe02(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1297 <main+0x107>
mov    %rax,%rbx
mov    %rax,%rdi
call   10b0 <CreateIOCTLSampleHeader@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xe08(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xdcc(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1297 <main+0x107>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <CreateSignDriversBat@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xde6(%rip),%rdi
call   1040 <puts@plt>
jmp    12a8 <main+0x118>
lea    0xd99(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Usage: %s [<BAT output directory>]\0A\00"
@.str.1 = [17 x i8] c"CopyProducts.bat\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [24 x i8] c"Error creating file %s\0A\00"
@.str.4 = [19 x i8] c"ppjioctl_devname.h\00"
@.str.5 = [20 x i8] c"SignDriverFiles.bat\00"
@.str.6 = [14 x i8] c"--- done ---\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %80
12: ; preds = %2
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
store i8* %13, i8** %6
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %36
16: ; preds = %12
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %17, i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i64 -1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 92
br i1 %31, label %32, label %35
32: ; preds = %16
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %6
store i8 92, i8* %33
br label %35
35: ; preds = %32, %16
br label %36
36: ; preds = %35, %12
%37 = load i8*, i8** %6
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %40, i32** %7
%41 = load i32*, i32** %7
%42 = icmp ne i32* %41, null
br i1 %42, label %46, label %43
43: ; preds = %36
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %44)
br label %80
46: ; preds = %36
%47 = load i32*, i32** %7
%48 = call i32 @CreateCopyProductsBat(i32* %47)
%49 = load i32*, i32** %7
%50 = call i32 @fclose(i32* %49)
%51 = load i8*, i8** %6
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %54, i32** %7
%55 = load i32*, i32** %7
%56 = icmp ne i32* %55, null
br i1 %56, label %60, label %57
57: ; preds = %46
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %58)
br label %80
60: ; preds = %46
%61 = load i32*, i32** %7
%62 = call i32 @CreateIOCTLSampleHeader(i32* %61)
%63 = load i32*, i32** %7
%64 = call i32 @fclose(i32* %63)
%65 = load i8*, i8** %6
%66 = call i32 @strcpy(i8* %65, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %68, i32** %7
%69 = load i32*, i32** %7
%70 = icmp ne i32* %69, null
br i1 %70, label %74, label %71
71: ; preds = %60
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %72)
br label %80
74: ; preds = %60
%75 = load i32*, i32** %7
%76 = call i32 @CreateSignDriversBat(i32* %75)
%77 = load i32*, i32** %7
%78 = call i32 @fclose(i32* %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %80
80: ; preds = %74, %71, %57, %43, %10
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Usage: %s [<BAT output directory>]\0A\00"
@.str.1 = [17 x i8] c"CopyProducts.bat\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [24 x i8] c"Error creating file %s\0A\00"
@.str.4 = [19 x i8] c"ppjioctl_devname.h\00"
@.str.5 = [20 x i8] c"SignDriverFiles.bat\00"
@str = [13 x i8] c"--- done ---\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %49
8: ; preds = %2
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %22
10: ; preds = %8
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %4, i8* %12)
%14 = call i32 @strlen(i8* %4)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 92
br i1 %19, label %22, label %20
20: ; preds = %10
%21 = getelementptr inbounds i8, i8* %16, i64 1
store i8 92, i8* %16
br label %22
22: ; preds = %10, %20, %8
%23 = phi i8* [ %21, %20 ], [ %16, %10 ], [ %4, %8 ]
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %49
29: ; preds = %22
%30 = call i32 @CreateCopyProductsBat(i32* %25)
%31 = call i32 @fclose(i32* %25)
%32 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %49
37: ; preds = %29
%38 = call i32 @CreateIOCTLSampleHeader(i32* %33)
%39 = call i32 @fclose(i32* %33)
%40 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %49
45: ; preds = %37
%46 = call i32 @CreateSignDriversBat(i32* %41)
%47 = call i32 @fclose(i32* %41)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %45, %43, %35, %27, %6
ret void
}