#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 export_logfile(char *, char *);
int import_logfile(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    printf("usage: mars-log-impex {im,ex}port filename [dirname]\n");
    return -1;
  }
  if (!strcmp(argv[1], "export")) {
    char *out_dirname = NULL;
    if (argc > 3 && argv[3])
      out_dirname = argv[3];
    return export_logfile(argv[2], out_dirname);
  }
  if (!strcmp(argv[1], "import") && argc > 3) {
    return import_logfile(argv[3], argv[2]);
  }
  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    1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1226 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11db <main+0x9b>
movq   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    11c2 <main+0x82>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     11c2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <export_logfile@plt>
mov    %eax,-0x4(%rbp)
jmp    1226 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    121f <main+0xdf>
cmpl   $0x3,-0x8(%rbp)
jle    121f <main+0xdf>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <import_logfile@plt>
mov    %eax,-0x4(%rbp)
jmp    1226 <main+0xe6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jg     115f <main+0x1f>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11a8 <main+0x68>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ebp
jb     115a <main+0x1a>
test   %ecx,%ecx
jne    115a <main+0x1a>
mov    0x10(%r14),%rsi
mov    0x18(%r14),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <import_logfile@plt>
cmp    $0x4,%ebp
jb     11b3 <main+0x73>
mov    0x18(%r14),%rsi
jmp    11b5 <main+0x75>
xor    %esi,%esi
mov    0x10(%r14),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <export_logfile@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"usage: mars-log-impex {im,ex}port filename [dirname]\0A\00"
@.str.1 = [7 x i8] c"export\00"
@.str.2 = [7 x i8] c"import\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %53
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %35, label %17
17: ; preds = %11
store i8* null, i8** %6
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 3
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
store i8* %28, i8** %6
br label %29
29: ; preds = %25, %20, %17
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = load i8*, i8** %6
%34 = call i32 @export_logfile(i8* %32, i8* %33)
store i32 %34, i32* %3
br label %53
35: ; preds = %11
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %52, label %41
41: ; preds = %35
%42 = load i32, i32* %4
%43 = icmp sgt i32 %42, 3
br i1 %43, label %44, label %52
44: ; preds = %41
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @import_logfile(i8* %47, i8* %50)
store i32 %51, i32* %3
br label %53
52: ; preds = %41, %35
store i32 0, i32* %3
br label %53
53: ; preds = %52, %44, %29, %9
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"export\00"
@.str.2 = [7 x i8] c"import\00"
@str = [53 x i8] c"usage: mars-log-impex {im,ex}port filename [dirname]\00"
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 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
br label %32
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %6
%12 = icmp ugt i32 %0, 3
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
br label %16
16: ; preds = %13, %11
%17 = phi i8* [ null, %11 ], [ %15, %13 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @export_logfile(i8* %19, i8* %17)
br label %32
21: ; preds = %6
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
%24 = icmp ugt i32 %0, 3
%25 = and i1 %24, %23
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = tail call i32 @import_logfile(i8* %28, i8* %30)
br label %32
32: ; preds = %21, %26, %16, %4
%33 = phi i32 [ -1, %4 ], [ %31, %26 ], [ %20, %16 ], [ 0, %21 ]
ret i32 %33
}