#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ mime_pack(char **, int);
int /*<<< orphan*/ mime_unpack(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2 || !strcmp(argv[1], "-h")) {
    fprintf(stderr, "Usage: %s [-hlu | attachment1 attachment2...] < mail\n",
            argv[0]);
    return 1;
  } else if (!strcmp(argv[1], "-l"))
    mime_unpack(0);
  else if (!strcmp(argv[1], "-u"))
    mime_unpack(1);
  else
    mime_pack(argv + 1, argc - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     117d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a5 <main+0x65>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6f(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ce <main+0x8e>
xor    %edi,%edi
call   1060 <mime_unpack@plt>
jmp    1212 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fa <main+0xba>
mov    $0x1,%edi
call   1060 <mime_unpack@plt>
jmp    120d <main+0xcd>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <mime_pack@plt>
jmp    1212 <main+0xd2>
jmp    1217 <main+0xd7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     119e <main+0x5e>
mov    %edi,%ebp
mov    0x8(%rbx),%r14
lea    0xea7(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     119e <main+0x5e>
lea    0xecd(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11bd <main+0x7d>
lea    0xebd(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c8 <main+0x88>
add    $0x8,%rbx
add    $0xffffffff,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <mime_pack@plt>
jmp    11d2 <main+0x92>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
jmp    11d4 <main+0x94>
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <mime_unpack@plt>
jmp    11d4 <main+0x94>
mov    $0x1,%edi
call   1060 <mime_unpack@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"Usage: %s [-hlu | attachment1 attachment2...] < mail\0A\00"
@.str.2 = [3 x i8] c"-l\00"
@.str.3 = [3 x i8] c"-u\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %8, %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %45
20: ; preds = %8
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %20
%27 = call i32 @mime_unpack(i32 0)
br label %43
28: ; preds = %20
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %28
%35 = call i32 @mime_unpack(i32 1)
br label %42
36: ; preds = %28
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 1
%41 = call i32 @mime_pack(i8** %38, i32 %40)
br label %42
42: ; preds = %36, %34
br label %43
43: ; preds = %42, %26
br label %44
44: ; preds = %43
store i32 0, i32* %3
br label %45
45: ; preds = %44, %14
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"Usage: %s [-hlu | attachment1 attachment2...] < mail\0A\00"
@.str.2 = [3 x i8] c"-l\00"
@.str.3 = [3 x i8] c"-u\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4, %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %26
13: ; preds = %4
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @mime_unpack(i32 0)
br label %26
18: ; preds = %13
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @mime_unpack(i32 1)
br label %26
23: ; preds = %18
%24 = add nsw i32 %0, -1
%25 = tail call i32 @mime_pack(i8** %5, i32 %24)
br label %26
26: ; preds = %21, %23, %16, %9
%27 = phi i32 [ 1, %9 ], [ 0, %16 ], [ 0, %23 ], [ 0, %21 ]
ret i32 %27
}