#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*/ _eject_trailer();
int /*<<< orphan*/ archive(char *, char *);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ read_canned_config(char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int mkbootfs_main(int argc, char *argv[]) {
  argc--;
  argv++;
  if (argc > 1 && strcmp(argv[0], "-f") == 0) {
    read_canned_config(argv[1]);
    argc -= 2;
    argv += 2;
  }
  if (argc == 0)
    die("no directories to process?!");
  while (argc-- > 0) {
    char *x = strchr(*argv, '=');
    if (x != 0) {
      *x++ = 0;
    } else {
      x = "";
    }
    archive(*argv, x);
    argv++;
  }
  _eject_trailer();
  return 0;
}


x86 assembly (clang, -O0):
<mkbootfs_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    11cd <mkbootfs_main+0x6d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe64(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <mkbootfs_main+0x6d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <read_canned_config@plt>
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11e3 <mkbootfs_main+0x83>
lea    0xe25(%rip),%rdi
call   1070 <die@plt>
jmp    11e8 <mkbootfs_main+0x88>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
jle    125f <mkbootfs_main+0xff>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1233 <mkbootfs_main+0xd3>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    123e <mkbootfs_main+0xde>
lea    0xde4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <archive@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11e8 <mkbootfs_main+0x88>
mov    $0x0,%al
call   1030 <_eject_trailer@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkbootfs_main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    -0x1(%rbx),%r15d
lea    0x8(%rsi),%rbp
cmp    $0x3,%edi
jl     11a4 <mkbootfs_main+0x44>
mov    %rsi,%r14
mov    0x0(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11ab <mkbootfs_main+0x4b>
mov    0x10(%r14),%rdi
call   1050 <read_canned_config@plt>
add    $0xfffffffd,%ebx
add    $0x18,%r14
mov    %ebx,%r15d
mov    %r14,%rbp
test   %r15d,%r15d
je     11ff <mkbootfs_main+0x9f>
jle    120b <mkbootfs_main+0xab>
add    $0x1,%r15d
lea    0xe68(%rip),%r14
jmp    11d6 <mkbootfs_main+0x76>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <archive@plt>
add    $0x8,%rbp
add    $0xffffffff,%r15d
cmp    $0x1,%r15d
jbe    120b <mkbootfs_main+0xab>
mov    0x0(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %r14,%rsi
test   %rax,%rax
je     11c0 <mkbootfs_main+0x60>
mov    %rax,%rsi
add    $0x1,%rsi
movb   $0x0,(%rax)
mov    0x0(%rbp),%rbx
jmp    11c0 <mkbootfs_main+0x60>
lea    0xdfd(%rip),%rdi
call   1070 <die@plt>
xor    %eax,%eax
call   1030 <_eject_trailer@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-f\00"
@.str.1 = [28 x i8] c"no directories to process?!\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @mkbootfs_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = add nsw i32 %6, -1
store i32 %7, i32* %3
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i32 1
store i8** %9, i8*** %4
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %12
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @read_canned_config(i8* %21)
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 2
store i32 %24, i32* %3
%25 = load i8**, i8*** %4
%26 = getelementptr inbounds i8*, i8** %25, i64 2
store i8** %26, i8*** %4
br label %27
27: ; preds = %18, %12, %2
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %33
33: ; preds = %47, %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, -1
store i32 %35, i32* %3
%36 = icmp sgt i32 %34, 0
br i1 %36, label %37, label %54
37: ; preds = %33
%38 = load i8**, i8*** %4
%39 = load i8*, i8** %38
%40 = call i8* @strchr(i8* %39, i8 signext 61)
store i8* %40, i8** %5
%41 = load i8*, i8** %5
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %5
store i8 0, i8* %44
br label %47
46: ; preds = %37
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %47
47: ; preds = %46, %43
%48 = load i8**, i8*** %4
%49 = load i8*, i8** %48
%50 = load i8*, i8** %5
%51 = call i32 @archive(i8* %49, i8* %50)
%52 = load i8**, i8*** %4
%53 = getelementptr inbounds i8*, i8** %52, i32 1
store i8** %53, i8*** %4
br label %33
54: ; preds = %33
%55 = call i32 (...) @_eject_trailer()
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-f\00"
@.str.1 = [28 x i8] c"no directories to process?!\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @mkbootfs_main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = load i8*, i8** %4
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @read_canned_config(i8* %12)
%14 = add nsw i32 %0, -3
%15 = getelementptr inbounds i8*, i8** %1, i64 3
br label %16
16: ; preds = %10, %2
%17 = phi i32 [ %14, %10 ], [ %3, %2 ]
%18 = phi i8** [ %15, %10 ], [ %4, %2 ]
%19 = icmp eq i32 %17, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %43
22: ; preds = %16
%23 = icmp sgt i32 %17, 0
br i1 %23, label %24, label %43
24: ; preds = %6, %22
%25 = phi i32 [ %3, %6 ], [ %17, %22 ]
%26 = phi i8** [ %4, %6 ], [ %18, %22 ]
br label %27
27: ; preds = %24, %37
%28 = phi i32 [ %30, %37 ], [ %25, %24 ]
%29 = phi i8** [ %41, %37 ], [ %26, %24 ]
%30 = add nsw i32 %28, -1
%31 = load i8*, i8** %29
%32 = tail call i8* @strchr(i8* dereferenceable(1) %31, i8 signext 61)
%33 = icmp eq i8* %32, null
br i1 %33, label %37, label %34
34: ; preds = %27
%35 = getelementptr inbounds i8, i8* %32, i64 1
store i8 0, i8* %32
%36 = load i8*, i8** %29
br label %37
37: ; preds = %27, %34
%38 = phi i8* [ %36, %34 ], [ %31, %27 ]
%39 = phi i8* [ %35, %34 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %27 ]
%40 = tail call i32 @archive(i8* %38, i8* %39)
%41 = getelementptr inbounds i8*, i8** %29, i64 1
%42 = icmp ugt i32 %28, 1
br i1 %42, label %27, label %43
43: ; preds = %37, %20, %22
%44 = tail call i32 (...) @_eject_trailer()
ret i32 0
}