#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 nandfs_lssnap(int, char **);
int nandfs_mksnap(int, char **);
int nandfs_rmsnap(int, char **);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int error = 0;
  char *cmd;
  if (argc < 2)
    usage();
  cmd = argv[1];
  argc -= 2;
  argv += 2;
  if (strcmp(cmd, "lssnap") == 0)
    error = nandfs_lssnap(argc, argv);
  else if (strcmp(cmd, "mksnap") == 0)
    error = nandfs_mksnap(argc, argv);
  else if (strcmp(cmd, "rmsnap") == 0)
    error = nandfs_rmsnap(argc, argv);
  else
    usage();
  return (error);
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    117e <main+0x2e>
mov    $0x0,%al
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <main+0x7d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <nandfs_lssnap@plt>
mov    %eax,-0x14(%rbp)
jmp    123a <main+0xea>
mov    -0x20(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fb <main+0xab>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <nandfs_mksnap@plt>
mov    %eax,-0x14(%rbp)
jmp    1235 <main+0xe5>
mov    -0x20(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1229 <main+0xd9>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <nandfs_rmsnap@plt>
mov    %eax,-0x14(%rbp)
jmp    1230 <main+0xe0>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    1235 <main+0xe5>
jmp    123a <main+0xea>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1165 <main+0x15>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x8(%rbx),%r14
add    $0xfffffffe,%ebp
add    $0x10,%rbx
lea    0xe89(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ba <main+0x6a>
lea    0xe7c(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c8 <main+0x78>
lea    0xe6f(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d6 <main+0x86>
xor    %eax,%eax
call   1060 <usage@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <nandfs_lssnap@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <nandfs_mksnap@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <nandfs_rmsnap@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"lssnap\00"
@.str.1 = [7 x i8] c"mksnap\00"
@.str.2 = [7 x i8] c"rmsnap\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
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
store i8* %15, i8** %7
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 2
store i32 %17, i32* %4
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
store i8** %19, i8*** %5
%20 = load i8*, i8** %7
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %12
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
%26 = call i32 @nandfs_lssnap(i32 %24, i8** %25)
store i32 %26, i32* %6
br label %47
27: ; preds = %12
%28 = load i8*, i8** %7
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* %4
%33 = load i8**, i8*** %5
%34 = call i32 @nandfs_mksnap(i32 %32, i8** %33)
store i32 %34, i32* %6
br label %46
35: ; preds = %27
%36 = load i8*, i8** %7
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* %4
%41 = load i8**, i8*** %5
%42 = call i32 @nandfs_rmsnap(i32 %40, i8** %41)
store i32 %42, i32* %6
br label %45
43: ; preds = %35
%44 = call i32 (...) @usage()
br label %45
45: ; preds = %43, %39
br label %46
46: ; preds = %45, %31
br label %47
47: ; preds = %46, %23
%48 = load i32, i32* %6
ret i32 %48
}

LLVM IR (-O2):
@.str = [7 x i8] c"lssnap\00"
@.str.1 = [7 x i8] c"mksnap\00"
@.str.2 = [7 x i8] c"rmsnap\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = add nsw i32 %0, -2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @nandfs_lssnap(i32 %9, i8** %10)
br label %27
15: ; preds = %6
%16 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @nandfs_mksnap(i32 %9, i8** %10)
br label %27
20: ; preds = %15
%21 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @nandfs_rmsnap(i32 %9, i8** %10)
br label %27
25: ; preds = %20
%26 = tail call i32 (...) @usage()
br label %27
27: ; preds = %18, %25, %23, %13
%28 = phi i32 [ %14, %13 ], [ %19, %18 ], [ %24, %23 ], [ 0, %25 ]
ret i32 %28
}