#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*/ cmd_copy;

/* Variables and functions */
char *basename(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strncpy(char *, char *, int);
int usage(char *cmd, char *msg) {
  char cmd_copy[256];
  char *command;
  strncpy(cmd_copy, cmd, sizeof(cmd_copy) - 1);
  command = basename(cmd_copy);
  if (msg)
    printf("%s\n", msg);
  printf("Usage: %s [options] [interval[fps]] frame.bmp ...\n\n", command);
  printf("-D, --no-daemon       Do not fork into the background, log\n"
         "                      to stdout\n");
  printf("-v, --verbose         Do not suppress debug messages in the\n"
         "                      log (may also be suppressed by syslog"
         " configuration)\n");
  printf("-c [<num>],\n"
         "--run-count[=<num>]   Display the sequence of frames <num>\n"
         "                      times, then exit. If <num> is omitted,\n"
         "                      repeat only once. If it is less than\n"
         "                      1, ignore the option\n");
  printf("-p, --preserve-mode   Do not restore framebuffer mode on exit\n"
         "                      which usually means leaving last frame"
         " displayed\n");
  printf("-i <fifo>,\n"
         "--command-pipe=<fifo> Open a named pipe <fifo> and wait for\n"
         "                      commands. The pipe should exist. If -c\n"
         "                      is specified, it is ignored. See %s(1)\n"
         "                      man page for command syntax.\n",
         command);
  printf("interval              Interval in milliseconds between frames.\n"
         "                      If \'fps\' suffix is present then it is in\n"
         "                      frames per second. Default:  41 (24fps)\n");
  printf("frame.bmp ...         list of filenames of frames in BMP"
         " format\n");
  return 1;
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0xff,%edx
call   1030 <strncpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <basename@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1188 <usage+0x58>
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x118(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x1039(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x118(%rbp),%rsi
lea    0x10aa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x1191(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x1240(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xff,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1060 <basename@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1178 <usage+0x38>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf99(%rip),%rdi
call   1040 <puts@plt>
lea    0xfe8(%rip),%rdi
call   1040 <puts@plt>
lea    0x1063(%rip),%rdi
call   1040 <puts@plt>
lea    0x1141(%rip),%rdi
call   1040 <puts@plt>
lea    0xe74(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x11a9(%rip),%rdi
call   1040 <puts@plt>
lea    0x1259(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [52 x i8] c"Usage: %s [options] [interval[fps]] frame.bmp ...\0A\0A\00"
@.str.2 = [92 x i8] c"-D, --no-daemon Do not fork into the background, log\0A to stdout\0A\00"
@.str.3 = [136 x i8] c"-v, --verbose Do not suppress debug messages in the\0A log (may also be suppressed by syslog configuration)\0A\00"
@.str.4 = [235 x i8] c"-c [<num>],\0A--run-count[=<num>] Display the sequence of frames <num>\0A times, then exit. If <num> is omitted,\0A repeat only once. If it is less than\0A 1, ignore the option\0A\00"
@.str.5 = [134 x i8] c"-p, --preserve-mode Do not restore framebuffer mode on exit\0A which usually means leaving last frame displayed\0A\00"
@.str.6 = [245 x i8] c"-i <fifo>,\0A--command-pipe=<fifo> Open a named pipe <fifo> and wait for\0A commands. The pipe should exist. If -c\0A is specified, it is ignored. See %s(1)\0A man page for command syntax.\0A\00"
@.str.7 = [189 x i8] c"interval Interval in milliseconds between frames.\0A If 'fps' suffix is present then it is in\0A frames per second. Default: 41 (24fps)\0A\00"
@.str.8 = [65 x i8] c"frame.bmp ... list of filenames of frames in BMP format\0A\00"
define i32 @usage(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @strncpy(i8* %7, i8* %8, i32 255)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = call i8* @basename(i8* %10)
store i8* %11, i8** %6
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %2
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([235 x i8], [235 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.5, i64 0, i64 0))
%24 = load i8*, i8** %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([245 x i8], [245 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str.1 = [52 x i8] c"Usage: %s [options] [interval[fps]] frame.bmp ...\0A\0A\00"
@.str.6 = [245 x i8] c"-i <fifo>,\0A--command-pipe=<fifo> Open a named pipe <fifo> and wait for\0A commands. The pipe should exist. If -c\0A is specified, it is ignored. See %s(1)\0A man page for command syntax.\0A\00"
@str = [91 x i8] c"-D, --no-daemon Do not fork into the background, log\0A to stdout\00"
@str.9 = [135 x i8] c"-v, --verbose Do not suppress debug messages in the\0A log (may also be suppressed by syslog configuration)\00"
@str.10 = [234 x i8] c"-c [<num>],\0A--run-count[=<num>] Display the sequence of frames <num>\0A times, then exit. If <num> is omitted,\0A repeat only once. If it is less than\0A 1, ignore the option\00"
@str.11 = [133 x i8] c"-p, --preserve-mode Do not restore framebuffer mode on exit\0A which usually means leaving last frame displayed\00"
@str.12 = [188 x i8] c"interval Interval in milliseconds between frames.\0A If 'fps' suffix is present then it is in\0A frames per second. Default: 41 (24fps)\00"
@str.13 = [64 x i8] c"frame.bmp ... list of filenames of frames in BMP format\00"
define i32 @usage(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* %0, i32 255)
%6 = call i8* @basename(i8* %4)
%7 = icmp eq i8* %1, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @puts(i8* %1)
br label %10
10: ; preds = %8, %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([135 x i8], [135 x i8]* @str.9, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([234 x i8], [234 x i8]* @str.10, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([133 x i8], [133 x i8]* @str.11, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([245 x i8], [245 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([188 x i8], [188 x i8]* @str.12, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.13, i64 0, i64 0))
ret i32 1
}