#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 */
scalar_t__ cmd_create(char const *, int, char const **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncmp(char const *, char *, int);
int /*<<< orphan*/ usage();
int main(int argc, const char *argv[]) {
  const char *command;
  if (argc < 3) {
    fprintf(stderr, "Error: invalid number of arguments\n");
    usage();
    return -1;
  }
  command = argv[2];
  if (!strncmp(command, "create", sizeof("create"))) {
    if (cmd_create(argv[1], argc - 3, &argv[3]))
      return -1;
  } else {
    fprintf(stderr, "Error: invalid command: %s\n", command);
    return -1;
  }
  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    118a <main+0x4a>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1218 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ea <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x8(%rbp),%esi
sub    $0x3,%esi
mov    -0x10(%rbp),%rdx
add    $0x18,%rdx
call   1060 <cmd_create@plt>
cmp    $0x0,%rax
je     11e5 <main+0xa5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1218 <main+0xd8>
jmp    1211 <main+0xd1>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1218 <main+0xd8>
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     1169 <main+0x29>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage@plt>
jmp    11a4 <main+0x64>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x10(%rsi),%r14
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ab <main+0x6b>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11c5 <main+0x85>
mov    0x8(%rbx),%rdi
add    $0xfffffffd,%ebp
add    $0x18,%rbx
mov    %ebp,%esi
mov    %rbx,%rdx
call   1060 <cmd_create@plt>
neg    %rax
sbb    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Error: invalid number of arguments\0A\00"
@.str.1 = [7 x i8] c"create\00"
@.str.2 = [28 x i8] c"Error: invalid command: %s\0A\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 %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %37
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 @strncmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 7)
%19 = icmp ne i32 %18, 0
br i1 %19, label %32, label %20
20: ; preds = %13
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 3
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = call i64 @cmd_create(i8* %23, i32 %25, i8** %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 -1, i32* %3
br label %37
31: ; preds = %20
br label %36
32: ; preds = %13
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %6
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %34)
store i32 -1, i32* %3
br label %37
36: ; preds = %31
store i32 0, i32* %3
br label %37
37: ; preds = %36, %32, %30, %9
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Error: invalid number of arguments\0A\00"
@.str.1 = [7 x i8] c"create\00"
@.str.2 = [28 x i8] c"Error: invalid command: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @usage()
br label %24
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @strncmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = add nsw i32 %0, -3
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = tail call i64 @cmd_create(i8* %15, i32 %16, i8** %17)
%19 = icmp ne i64 %18, 0
%20 = sext i1 %19 to i32
br label %24
21: ; preds = %8
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %24
24: ; preds = %13, %21, %4
%25 = phi i32 [ -1, %4 ], [ -1, %21 ], [ %20, %13 ]
ret i32 %25
}