#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int usage(char *name, char *reason) {
  fprintf(stderr,
          "ERROR: "
          "%s\n",
          reason);
  printf("%s <tty_name> <cmd>\n"
         "\n"
         "Commands:\n"
         "   hw_reset\t\treset whole board\n"
         "   reset_stats\t\treset statistics\n"
         "   enable_tx <0/1>\treset statistics\n"
         "   reg_read <addr>\tread specific register\n"
         "   reg_write <addr> <val> write specific register\n"
         "   reg_dump\t\tdump all registers\n"
         "   set_ival <ival>\tset interval between packets\n"
         "   set_dly <dly>\tset expected delay of returning packet\n"
         "   load_pkt <file>\tload packet from file\n"
         "   stats\t\tdump stats\n"
         "   set_mbps <mbps>\tset ival to achieve mbps\n"
         "   set_pps <pps>\tset ival to achieve pps\n"
         "   set_full_speed\tset ival to get 100Mbps\n"
         "\n",
         name);
  return 1;
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xebc(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbx
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
@.str.1 = [550 x i8] c"%s <tty_name> <cmd>\0A\0ACommands:\0A hw_reset\09\09reset whole board\0A reset_stats\09\09reset statistics\0A enable_tx <0/1>\09reset statistics\0A reg_read <addr>\09read specific register\0A reg_write <addr> <val> write specific register\0A reg_dump\09\09dump all registers\0A set_ival <ival>\09set interval between packets\0A set_dly <dly>\09set expected delay of returning packet\0A load_pkt <file>\09load packet from file\0A stats\09\09dump stats\0A set_mbps <mbps>\09set ival to achieve mbps\0A set_pps <pps>\09set ival to achieve pps\0A set_full_speed\09set ival to get 100Mbps\0A\0A\00"
define i32 @usage(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %4
%7 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %3
%9 = call i32 @printf(i8* getelementptr inbounds ([550 x i8], [550 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
@.str.1 = [550 x i8] c"%s <tty_name> <cmd>\0A\0ACommands:\0A hw_reset\09\09reset whole board\0A reset_stats\09\09reset statistics\0A enable_tx <0/1>\09reset statistics\0A reg_read <addr>\09read specific register\0A reg_write <addr> <val> write specific register\0A reg_dump\09\09dump all registers\0A set_ival <ival>\09set interval between packets\0A set_dly <dly>\09set expected delay of returning packet\0A load_pkt <file>\09load packet from file\0A stats\09\09dump stats\0A set_mbps <mbps>\09set ival to achieve mbps\0A set_pps <pps>\09set ival to achieve pps\0A set_full_speed\09set ival to get 100Mbps\0A\0A\00"
define i32 @usage(i8* %0, i8* %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([550 x i8], [550 x i8]* @.str.1, i64 0, i64 0), i8* %0)
ret i32 1
}