#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 */
char *applet(char *const);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void usage(FILE *f, char *const arg0) {
  fprintf(f,
          "Usage: %s [OPTIONS] [THREAD_ARGS...]\n"
          "\n"
          "pthread-signal(1) is a good template to begin with a new \n"
          "CLI in C, based on a basic skeleton using sigwaitinfo(3p)\n"
          " as main loop in main thread that propagates signals such\n"
          "as SIGTERM, SIGUSR1, SIGUSR2 to another thread.\n"
          "\n"
          "Options:\n"
          " -t or --timeout SEC   Set timeout in sec [default=5].\n"
          "                       Note: It is also used to wait for\n"
          "                       thread to join before returning.\n"
          " -v or --verbose       Turn on verbose messages.\n"
          " -D or --debug         Turn on debug messages.\n"
          " -h or --help          Display this message.\n"
          " -V or --version       Display the version.\n"
          "\n"
          "Signals:\n"
          "SIGINT                 Cancel thread.\n"
          "SIGTERM                Signal thread using Terminate to\n"
          "                       cause thread to exit.\n"
          "SIGUSR1                Signal thread using User signal 1.\n"
          "SIGUSR2                Signal thread using User signal 2.\n"
          "",
          applet(arg0));
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <applet@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rdx
lea    0xeb1(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <applet@plt>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
pop    %rbx
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [889 x i8] c"Usage: %s [OPTIONS] [THREAD_ARGS...]\0A\0Apthread-signal(1) is a good template to begin with a new \0ACLI in C, based on a basic skeleton using sigwaitinfo(3p)\0A as main loop in main thread that propagates signals such\0Aas SIGTERM, SIGUSR1, SIGUSR2 to another thread.\0A\0AOptions:\0A -t or --timeout SEC Set timeout in sec [default=5].\0A Note: It is also used to wait for\0A thread to join before returning.\0A -v or --verbose Turn on verbose messages.\0A -D or --debug Turn on debug messages.\0A -h or --help Display this message.\0A -V or --version Display the version.\0A\0ASignals:\0ASIGINT Cancel thread.\0ASIGTERM Signal thread using Terminate to\0A cause thread to exit.\0ASIGUSR1 Signal thread using User signal 1.\0ASIGUSR2 Signal thread using User signal 2.\0A\00"
define void @usage(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i32*, i32** %3
%6 = load i8*, i8** %4
%7 = call i8* @applet(i8* %6)
%8 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([889 x i8], [889 x i8]* @.str, i64 0, i64 0), i8* %7)
ret void
}

LLVM IR (-O2):
@.str = [889 x i8] c"Usage: %s [OPTIONS] [THREAD_ARGS...]\0A\0Apthread-signal(1) is a good template to begin with a new \0ACLI in C, based on a basic skeleton using sigwaitinfo(3p)\0A as main loop in main thread that propagates signals such\0Aas SIGTERM, SIGUSR1, SIGUSR2 to another thread.\0A\0AOptions:\0A -t or --timeout SEC Set timeout in sec [default=5].\0A Note: It is also used to wait for\0A thread to join before returning.\0A -v or --verbose Turn on verbose messages.\0A -D or --debug Turn on debug messages.\0A -h or --help Display this message.\0A -V or --version Display the version.\0A\0ASignals:\0ASIGINT Cancel thread.\0ASIGTERM Signal thread using Terminate to\0A cause thread to exit.\0ASIGUSR1 Signal thread using User signal 1.\0ASIGUSR2 Signal thread using User signal 2.\0A\00"
define void @usage(i32* nocapture %0, i8* %1) {
%3 = tail call i8* @applet(i8* %1)
%4 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([889 x i8], [889 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}