#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*/ printf(char *, ...);
int check_cmd(int argc, char *top_usage, char **usage) {
  if (argc < 1) {
    printf("*** command missing\n");
    printf("usage: %s\n", top_usage);
    while (*usage != 0) {
      printf("         %s\n", *usage);
      usage++;
    }
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    118d <check_cmd+0x7d>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1181 <check_cmd+0x71>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    114d <check_cmd+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <check_cmd+0x84>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_cmd>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %edi,%edi
jg     1186 <check_cmd+0x66>
mov    %rdx,%rbx
mov    %rsi,%rbp
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
mov    $0xffffffff,%r14d
test   %rsi,%rsi
je     1186 <check_cmd+0x66>
add    $0x8,%rbx
lea    0xea4(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1170 <check_cmd+0x50>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"*** command missing\0A\00"
@.str.1 = [11 x i8] c"usage: %s\0A\00"
@.str.2 = [13 x i8] c" %s\0A\00"
define i32 @check_cmd(i32 %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %25
10: ; preds = %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %18, %10
%15 = load i8**, i8*** %7
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i8**, i8*** %7
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i8**, i8*** %7
%23 = getelementptr inbounds i8*, i8** %22, i32 1
store i8** %23, i8*** %7
br label %14
24: ; preds = %14
store i32 -1, i32* %4
br label %26
25: ; preds = %3
store i32 0, i32* %4
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"usage: %s\0A\00"
@.str.2 = [13 x i8] c" %s\0A\00"
@str = [20 x i8] c"*** command missing\00"
define i32 @check_cmd(i32 %0, i8* %1, i8** nocapture %2) {
%4 = icmp slt i32 %0, 1
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = load i8*, i8** %2
%9 = icmp eq i8* %8, null
br i1 %9, label %17, label %10
10: ; preds = %5, %10
%11 = phi i8* [ %15, %10 ], [ %8, %5 ]
%12 = phi i8** [ %14, %10 ], [ %2, %5 ]
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%14 = getelementptr inbounds i8*, i8** %12, i64 1
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %10
17: ; preds = %10, %5, %3
%18 = phi i32 [ 0, %3 ], [ -1, %5 ], [ -1, %10 ]
ret i32 %18
}