#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*/ zip_file_path;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ Error(char *);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ remove_directory(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ unlink(char *);
scalar_t__ wait(int /*<<< orphan*/ *);
bool create_zip_file(char *path) {
  char zip_file_path[4096] = {0};
  snprintf(zip_file_path, sizeof(zip_file_path), "%s.zip", path);
  char *args[5] = {0};
  char *vdirript =
      "ArchiveFolder Wscript.Arguments.Item(0), Wscript.Arguments.Item(1)\r\n"
      "Sub ArchiveFolder (zipFile, sFolder)\r\n"
      "With CreateObject(\"Scripting.FileSystemObject\")\r\n"
      "zipFile = .GetAbsolutePathName(zipFile)\r\n"
      "sFolder = .GetAbsolutePathName(sFolder)\r\n"
      "	With .CreateTextFile(zipFile, True)\r\n"
      "		.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, "
      "chr(0))\r\n"
      "	End With\r\n"
      "End With\r\n"
      "With CreateObject(\"Shell.Application\")\r\n"
      "	.NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items\r\n"
      "	Do Until .NameSpace(zipFile).Items.Count = _\r\n"
      "		.NameSpace(sFolder).Items.Count\r\n"
      "	WScript.Sleep 1000\r\n"
      "	Loop\r\n"
      "End With\r\n"
      "End Sub\r\n";
  FILE *f = fopen("zip.vbs", "w");
  fprintf(f, "%s", vdirript);
  fclose(f);
  args[0] = "cscript";
  args[1] = "zip.vbs";
  args[2] = zip_file_path;
  args[3] = path;
  args[4] = NULL;
  pid_t p = fork();
  if (p < 0)
    Error("fork");
  else if (p == 0) {
    execvp(args[0], args);
    exit(1);
  }
  p = wait(NULL);
  unlink("zip.vbs");
  remove_directory(path);
  return true;
}


x86 assembly (clang, -O0):
<create_zip_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1000,%esi
lea    0xe07(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x1040(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
lea    0xdef(%rip),%rax
mov    %rax,-0x1048(%rbp)
lea    0x102f(%rip),%rdi
lea    0x1030(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rdi
mov    -0x1048(%rbp),%rdx
lea    0x1011(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x1050(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xffc(%rip),%rax
mov    %rax,-0x1040(%rbp)
lea    0xfe1(%rip),%rax
mov    %rax,-0x1038(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1028(%rbp)
movq   $0x0,-0x1020(%rbp)
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x1058(%rbp)
cmpq   $0x0,-0x1058(%rbp)
jge    12cc <create_zip_file+0x10c>
lea    0xfa8(%rip),%rdi
call   1060 <Error@plt>
jmp    12fc <create_zip_file+0x13c>
cmpq   $0x0,-0x1058(%rbp)
jne    12f7 <create_zip_file+0x137>
mov    -0x1040(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
call   10b0 <execvp@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12fc <create_zip_file+0x13c>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <wait@plt>
mov    %rax,-0x1058(%rbp)
lea    0xf42(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x8(%rbp),%rdi
call   1040 <remove_directory@plt>
mov    $0x1,%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_zip_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1038,%rsp
mov    %rdi,%r12
lea    0x30(%rsp),%r14
mov    $0x1000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xe14(%rip),%rdx
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %r12,%rcx
call   1070 <snprintf@plt>
lea    0x1052(%rip),%r15
lea    0x1053(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xdeb(%rip),%rdi
mov    $0x24d,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0x1022(%rip),%rax
mov    %rax,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %r12,0x18(%rsp)
movq   $0x0,0x20(%rsp)
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
js     1280 <create_zip_file+0xc0>
jne    128c <create_zip_file+0xcc>
lea    0xff1(%rip),%rdi
mov    %rsp,%rsi
call   10a0 <execvp@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xfe0(%rip),%rdi
call   1060 <Error@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
lea    0xfbb(%rip),%rdi
call   1030 <unlink@plt>
mov    %r12,%rdi
call   1040 <remove_directory@plt>
mov    $0x1,%eax
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s.zip\00"
@.str.1 = [590 x i8] c"ArchiveFolder Wscript.Arguments.Item(0), Wscript.Arguments.Item(1)\0D\0ASub ArchiveFolder (zipFile, sFolder)\0D\0AWith CreateObject(\22Scripting.FileSystemObject\22)\0D\0AzipFile = .GetAbsolutePathName(zipFile)\0D\0AsFolder = .GetAbsolutePathName(sFolder)\0D\0A\09With .CreateTextFile(zipFile, True)\0D\0A\09\09.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))\0D\0A\09End With\0D\0AEnd With\0D\0AWith CreateObject(\22Shell.Application\22)\0D\0A\09.NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items\0D\0A\09Do Until .NameSpace(zipFile).Items.Count = _\0D\0A\09\09.NameSpace(sFolder).Items.Count\0D\0A\09WScript.Sleep 1000\0D\0A\09Loop\0D\0AEnd With\0D\0AEnd Sub\0D\0A\00"
@.str.2 = [8 x i8] c"zip.vbs\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [8 x i8] c"cscript\00"
@.str.6 = [5 x i8] c"fork\00"
define i32 @create_zip_file(i8* %0) {
%2 = alloca i8*
%3 = alloca [4096 x i8]
%4 = alloca [5 x i8*]
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
store i8* %0, i8** %2
%8 = bitcast [4096 x i8]* %3 to i8*
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = call i32 @snprintf(i8* %9, i32 4096, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = bitcast [5 x i8*]* %4 to i8*
store i8* getelementptr inbounds ([590 x i8], [590 x i8]* @.str.1, i64 0, i64 0), i8** %5
%13 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = load i8*, i8** %5
%16 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = load i32*, i32** %6
%18 = call i32 @fclose(i32* %17)
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 2
store i8* %21, i8** %22
%23 = load i8*, i8** %2
%24 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 3
store i8* %23, i8** %24
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 4
store i8* null, i8** %25
%26 = call i64 (...) @fork()
store i64 %26, i64* %7
%27 = load i64, i64* %7
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %1
%30 = call i32 @Error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %41
31: ; preds = %1
%32 = load i64, i64* %7
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
%36 = load i8*, i8** %35
%37 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
%38 = call i32 @execvp(i8* %36, i8** %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %31
br label %41
41: ; preds = %40, %29
%42 = call i64 @wait(i32* null)
store i64 %42, i64* %7
%43 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%44 = load i8*, i8** %2
%45 = call i32 @remove_directory(i8* %44)
ret i32 1
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s.zip\00"
@.str.1 = [590 x i8] c"ArchiveFolder Wscript.Arguments.Item(0), Wscript.Arguments.Item(1)\0D\0ASub ArchiveFolder (zipFile, sFolder)\0D\0AWith CreateObject(\22Scripting.FileSystemObject\22)\0D\0AzipFile = .GetAbsolutePathName(zipFile)\0D\0AsFolder = .GetAbsolutePathName(sFolder)\0D\0A\09With .CreateTextFile(zipFile, True)\0D\0A\09\09.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))\0D\0A\09End With\0D\0AEnd With\0D\0AWith CreateObject(\22Shell.Application\22)\0D\0A\09.NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items\0D\0A\09Do Until .NameSpace(zipFile).Items.Count = _\0D\0A\09\09.NameSpace(sFolder).Items.Count\0D\0A\09WScript.Sleep 1000\0D\0A\09Loop\0D\0AEnd With\0D\0AEnd Sub\0D\0A\00"
@.str.2 = [8 x i8] c"zip.vbs\00"
@.str.3 = [2 x i8] c"w\00"
@.str.5 = [8 x i8] c"cscript\00"
@.str.6 = [5 x i8] c"fork\00"
define i32 @create_zip_file(i8* %0) {
%2 = alloca [4096 x i8]
%3 = alloca [5 x i8*]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 4096, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = bitcast [5 x i8*]* %3 to i8*
%7 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%8 = call i64 @fwrite(i8* getelementptr inbounds ([590 x i8], [590 x i8]* @.str.1, i64 0, i64 0), i64 589, i64 1, i32* %7)
%9 = call i32 @fclose(i32* %7)
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 2
store i8* %4, i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 3
store i8* %0, i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 4
store i8* null, i8** %14
%15 = call i64 (...) @fork()
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i32 @Error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %24
19: ; preds = %1
%20 = icmp eq i64 %15, 0
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = call i32 @execvp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %10)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %19, %17
%25 = call i64 @wait(i32* null)
%26 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @remove_directory(i8* %0)
ret i32 1
}