#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 */
int /*<<< orphan*/ AT_FDCWD;
int O_CREAT;
int O_EXCL;
int O_RDWR;
int open(char *, int, int);
int /*<<< orphan*/ xerr(char *);
int /*<<< orphan*/ xerr2(char *, char *);
int /*<<< orphan*/ zip_build_directory(int);
int /*<<< orphan*/ zip_path(int, int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  int zip, i;
  if (argc < 3)
    xerr("Usage: attozip new.zip file1 ...\n"
         "       Copyright 2012 Kieran Clancy\n"
         "       http://git.io/ZaUszg");
  zip = open(argv[1], O_CREAT | O_EXCL | O_RDWR, 0644);
  if (zip < 0)
    xerr2(argv[1], "could not create or already exists");
  for (i = 2; i < argc; i++)
    zip_path(zip, AT_FDCWD, argv[i]);
  zip_build_directory(zip);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    117c <main+0x2c>
lea    0xe89(%rip),%rdi
call   1060 <xerr@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    0x2e3c(%rip),%rax
or     (%rax),%esi
mov    0x2e43(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ca <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <xerr2@plt>
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1208 <main+0xb8>
mov    -0x14(%rbp),%edi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
call   1040 <zip_path@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d1 <main+0x81>
mov    -0x14(%rbp),%edi
call   1030 <zip_build_directory@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%r14d
cmp    $0x2,%edi
jg     116f <main+0x1f>
lea    0xe96(%rip),%rdi
call   1060 <xerr@plt>
mov    0x2e82(%rip),%rax
mov    0x2e53(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x8(%r15),%rdi
mov    0x2e54(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1050 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
js     11a7 <main+0x57>
cmp    $0x3,%r14d
jge    11bd <main+0x6d>
jmp    11e8 <main+0x98>
mov    0x8(%r15),%rdi
lea    0xeaf(%rip),%rsi
call   1070 <xerr2@plt>
cmp    $0x3,%r14d
jl     11e8 <main+0x98>
mov    %r14d,%ebx
mov    $0x2,%ebp
mov    0x2df4(%rip),%r14
nopl   0x0(%rax)
mov    (%r14),%esi
mov    (%r15,%rbp,8),%rdx
mov    %r12d,%edi
call   1040 <zip_path@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11d0 <main+0x80>
mov    %r12d,%edi
call   1030 <zip_build_directory@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [97 x i8] c"Usage: attozip new.zip file1 ...\0A Copyright 2012 Kieran Clancy\0A http://git.io/ZaUszg\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_RDWR = global i32 0
@.str.1 = [35 x i8] c"could not create or already exists\00"
@AT_FDCWD = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @xerr(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_CREAT
%17 = load i32, i32* @O_EXCL
%18 = or i32 %16, %17
%19 = load i32, i32* @O_RDWR
%20 = or i32 %18, %19
%21 = call i32 @open(i8* %15, i32 %20, i32 420)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %12
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @xerr2(i8* %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %24, %12
store i32 2, i32* %7
br label %30
30: ; preds = %43, %29
%31 = load i32, i32* %7
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %46
34: ; preds = %30
%35 = load i32, i32* %6
%36 = load i32, i32* @AT_FDCWD
%37 = load i8**, i8*** %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @zip_path(i32 %35, i32 %36, i8* %41)
br label %43
43: ; preds = %34
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %30
46: ; preds = %30
%47 = load i32, i32* %6
%48 = call i32 @zip_build_directory(i32 %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [97 x i8] c"Usage: attozip new.zip file1 ...\0A Copyright 2012 Kieran Clancy\0A http://git.io/ZaUszg\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@O_RDWR = global i32 0
@.str.1 = [35 x i8] c"could not create or already exists\00"
@AT_FDCWD = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @xerr(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_CREAT
%10 = load i32, i32* @O_EXCL
%11 = or i32 %10, %9
%12 = load i32, i32* @O_RDWR
%13 = or i32 %11, %12
%14 = tail call i32 @open(i8* %8, i32 %13, i32 420)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %6
%17 = load i8*, i8** %7
%18 = tail call i32 @xerr2(i8* %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16, %6
%20 = icmp sgt i32 %0, 2
br i1 %20, label %21, label %31
21: ; preds = %19
%22 = zext i32 %0 to i64
br label %23
23: ; preds = %21, %23
%24 = phi i64 [ 2, %21 ], [ %29, %23 ]
%25 = load i32, i32* @AT_FDCWD
%26 = getelementptr inbounds i8*, i8** %1, i64 %24
%27 = load i8*, i8** %26
%28 = tail call i32 @zip_path(i32 %14, i32 %25, i8* %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %22
br i1 %30, label %31, label %23
31: ; preds = %23, %19
%32 = tail call i32 @zip_build_directory(i32 %14)
ret i32 0
}