#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ print_usage(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ search_usage(int /*<<< orphan*/ *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ update_usage(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ version(int /*<<< orphan*/ *, char *);
void usage(char *cmd, FILE *out, char *arg0) {
  version(out, cmd);
  if (cmd == NULL) {
    fprintf(
        out,
        "Usage: %s [OPTS] [COMMAND [COMMANDOPTS]]\n"
        "\n"
        "Options:\n"
        "  -v,--verbose            Increase verbosity\n"
        "  -s,--silent             Decrease verbosity\n"
        "  -h,--help     COMMAND   Print this help or the command specific\n"
        "  --version               Print the version\n"
        "\n"
        "  -c,--config      FILE   Use the specified config\n"
        "  -d,--db          FILE   Use the specified database\n"
        "  -b,--verbose-db         Write the database in verbose format "
        "(debugging only)\n"
        "  -B,--binary-db          Write the database in binary format "
        "(default)\n"
        "  -r,--libraryroot FILE   User FILE as the database root\n\n"
        "  -e,--exclude     GLOB   Add GLOB to the exclusion list\n"
        "  -f,--format      FMT    Format the output with FMT\n"
        "  -x,--fix-fs             Stay within one filesystem\n"
        "  -X,--no-fix-fs          Allow indexing across filesystems\n"
        "\n"
        "Commands (default: update)\n"
        "  print                   Print the database\n"
        "  update                  Update the database\n"
        "  search                  Search the database\n",
        arg0);
  } else if (strcmp(cmd, "print") == 0) {
    print_usage(out, arg0);
  } else if (strcmp(cmd, "update") == 0) {
    update_usage(out, arg0);
  } else if (strcmp(cmd, "search") == 0) {
    search_usage(out, arg0);
  }
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <version@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11a5 <usage+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe65(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1233 <usage+0xd3>
mov    -0x8(%rbp),%rdi
lea    0x120b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d1 <usage+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <print_usage@plt>
jmp    122e <usage+0xce>
mov    -0x8(%rbp),%rdi
lea    0x11e5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fd <usage+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <update_usage@plt>
jmp    1229 <usage+0xc9>
mov    -0x8(%rbp),%rdi
lea    0x11c0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1224 <usage+0xc4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <search_usage@plt>
jmp    1229 <usage+0xc9>
jmp    122e <usage+0xce>
jmp    1233 <usage+0xd3>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1060 <version@plt>
test   %rbx,%rbx
je     11c0 <usage+0x60>
lea    0x1236(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d7 <usage+0x77>
lea    0x1228(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e7 <usage+0x87>
lea    0x121b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f7 <usage+0x97>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe39(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <print_usage@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <update_usage@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <search_usage@plt>

LLVM IR (-O0):
@.str = [955 x i8] c"Usage: %s [OPTS] [COMMAND [COMMANDOPTS]]\0A\0AOptions:\0A -v,--verbose Increase verbosity\0A -s,--silent Decrease verbosity\0A -h,--help COMMAND Print this help or the command specific\0A --version Print the version\0A\0A -c,--config FILE Use the specified config\0A -d,--db FILE Use the specified database\0A -b,--verbose-db Write the database in verbose format (debugging only)\0A -B,--binary-db Write the database in binary format (default)\0A -r,--libraryroot FILE User FILE as the database root\0A\0A -e,--exclude GLOB Add GLOB to the exclusion list\0A -f,--format FMT Format the output with FMT\0A -x,--fix-fs Stay within one filesystem\0A -X,--no-fix-fs Allow indexing across filesystems\0A\0ACommands (default: update)\0A print Print the database\0A update Update the database\0A search Search the database\0A\00"
@.str.1 = [6 x i8] c"print\00"
@.str.2 = [7 x i8] c"update\00"
@.str.3 = [7 x i8] c"search\00"
define void @usage(i8* %0, i32* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%7 = load i32*, i32** %5
%8 = load i8*, i8** %4
%9 = call i32 @version(i32* %7, i8* %8)
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32*, i32** %5
%14 = load i8*, i8** %6
%15 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([955 x i8], [955 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %43
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = load i8*, i8** %6
%23 = call i32 @print_usage(i32* %21, i8* %22)
br label %42
24: ; preds = %16
%25 = load i8*, i8** %4
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32*, i32** %5
%30 = load i8*, i8** %6
%31 = call i32 @update_usage(i32* %29, i8* %30)
br label %41
32: ; preds = %24
%33 = load i8*, i8** %4
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32*, i32** %5
%38 = load i8*, i8** %6
%39 = call i32 @search_usage(i32* %37, i8* %38)
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %28
br label %42
42: ; preds = %41, %20
br label %43
43: ; preds = %42, %12
ret void
}

LLVM IR (-O2):
@.str = [955 x i8] c"Usage: %s [OPTS] [COMMAND [COMMANDOPTS]]\0A\0AOptions:\0A -v,--verbose Increase verbosity\0A -s,--silent Decrease verbosity\0A -h,--help COMMAND Print this help or the command specific\0A --version Print the version\0A\0A -c,--config FILE Use the specified config\0A -d,--db FILE Use the specified database\0A -b,--verbose-db Write the database in verbose format (debugging only)\0A -B,--binary-db Write the database in binary format (default)\0A -r,--libraryroot FILE User FILE as the database root\0A\0A -e,--exclude GLOB Add GLOB to the exclusion list\0A -f,--format FMT Format the output with FMT\0A -x,--fix-fs Stay within one filesystem\0A -X,--no-fix-fs Allow indexing across filesystems\0A\0ACommands (default: update)\0A print Print the database\0A update Update the database\0A search Search the database\0A\00"
@.str.1 = [6 x i8] c"print\00"
@.str.2 = [7 x i8] c"update\00"
@.str.3 = [7 x i8] c"search\00"
define void @usage(i8* %0, i32* %1, i8* %2) {
%4 = tail call i32 @version(i32* %1, i8* %0)
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([955 x i8], [955 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %23
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @print_usage(i32* %1, i8* %2)
br label %23
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @update_usage(i32* %1, i8* %2)
br label %23
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @search_usage(i32* %1, i8* %2)
br label %23
23: ; preds = %11, %18, %21, %16, %6
ret void
}