#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 O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char const *, int, int);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ tar(char *, int);
int main(int argc, char const *argv[]) {
  int archive;
  if (argc > 3 && strcmp(argv[1], "-cf") == 0) {
    if ((archive = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0600)) == -1) {
      exit(-2);
    }
    int i;
    for (i = 3; i < argc; i++) {
      tar((char *)argv[i], archive);
    }
    close(archive);
  }
  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)
jle    120e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    120e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
mov    0x2e52(%rip),%rax
or     (%rax),%esi
mov    0x2e41(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11d1 <main+0x81>
mov    $0xfffffffe,%edi
call   1070 <exit@plt>
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1206 <main+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x14(%rbp),%esi
call   1060 <tar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d8 <main+0x88>
mov    -0x14(%rbp),%edi
call   1030 <close@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
cmp    $0x4,%edi
jl     11dd <main+0x8d>
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x8(%rsi),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11dd <main+0x8d>
mov    0x2e45(%rip),%rax
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%r15),%rdi
mov    0x2e57(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     11e8 <main+0x98>
mov    %eax,%r12d
mov    %r14d,%ebx
mov    $0x3,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbp,8),%rdi
mov    %r12d,%esi
call   1060 <tar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11c0 <main+0x70>
mov    %r12d,%edi
call   1030 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xfffffffe,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"-cf\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = 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 sgt i32 %8, 3
br i1 %9, label %10, label %48
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %48
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = load i32, i32* @O_WRONLY
%21 = load i32, i32* @O_CREAT
%22 = or i32 %20, %21
%23 = load i32, i32* @O_TRUNC
%24 = or i32 %22, %23
%25 = call i32 @open(i8* %19, i32 %24, i32 384)
store i32 %25, i32* %6
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %16
%28 = call i32 @exit(i32 -2)
unreachable
29: ; preds = %16
store i32 3, i32* %7
br label %30
30: ; preds = %42, %29
%31 = load i32, i32* %7
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = load i8**, i8*** %5
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* %6
%41 = call i32 @tar(i8* %39, i32 %40)
br label %42
42: ; preds = %34
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %30
45: ; preds = %30
%46 = load i32, i32* %6
%47 = call i32 @close(i32 %46)
br label %48
48: ; preds = %45, %10, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"-cf\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 3
br i1 %3, label %4, label %32
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_WRONLY
%13 = load i32, i32* @O_CREAT
%14 = or i32 %13, %12
%15 = load i32, i32* @O_TRUNC
%16 = or i32 %14, %15
%17 = tail call i32 @open(i8* %11, i32 %16, i32 384)
%18 = icmp eq i32 %17, -1
br i1 %18, label %21, label %19
19: ; preds = %9
%20 = zext i32 %0 to i64
br label %23
21: ; preds = %9
%22 = tail call i32 @exit(i32 -2)
unreachable
23: ; preds = %19, %23
%24 = phi i64 [ 3, %19 ], [ %28, %23 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 @tar(i8* %26, i32 %17)
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, %20
br i1 %29, label %30, label %23
30: ; preds = %23
%31 = tail call i32 @close(i32 %17)
br label %32
32: ; preds = %30, %4, %2
ret i32 0
}