#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 const *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char const *);
void usage(const char *cmd, const char *reqd, const char *optl) {
  char trailer[optl ? strlen(optl) + 4 : 1];
  trailer[0] = '\0';
  if (optl)
    sprintf(trailer, " [%s]", optl);
  fprintf(stderr, "USAGE: %s <%s>%s\n", cmd, reqd, trailer);
  fprintf(stderr, "Required argument %s not provided.\n", reqd);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1163 <usage+0x33>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x4,%eax
mov    %eax,-0x2c(%rbp)
jmp    1170 <usage+0x40>
mov    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1170 <usage+0x40>
mov    -0x2c(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x38(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x28(%rbp)
movb   $0x0,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     11bc <usage+0x8c>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe49(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x38(%rbp),%r8
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
test   %rdx,%rdx
je     1183 <usage+0x53>
mov    %rdx,%r12
mov    %rdx,%rdi
call   1030 <strlen@plt>
add    $0x4,%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
neg    %rax
movb   $0x0,(%rcx,%rax,1)
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
call   1050 <sprintf@plt>
jmp    1191 <usage+0x61>
mov    %rsp,%rax
lea    -0x10(%rax),%rbx
mov    %rbx,%rsp
movb   $0x0,-0x10(%rax)
mov    0x2e48(%rip),%r12
mov    (%r12),%edi
lea    0xe63(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
lea    0xe5a(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" [%s]\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"USAGE: %s <%s>%s\0A\00"
@.str.2 = [36 x i8] c"Required argument %s not provided.\0A\00"
define void @usage(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, 4
br label %16
15: ; preds = %3
br label %16
16: ; preds = %15, %11
%17 = phi i32 [ %14, %11 ], [ 1, %15 ]
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %7
%20 = alloca i8, i64 %18
store i64 %18, i64* %8
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 0, i8* %21
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i8*, i8** %6
%26 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %16
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30, i8* %20)
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %5
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" [%s]\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"USAGE: %s <%s>%s\0A\00"
@.str.2 = [36 x i8] c"Required argument %s not provided.\0A\00"
define void @usage(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = alloca i8
store i8 0, i8* %6
br label %13
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %2)
%9 = add nsw i32 %8, 4
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
store i8 0, i8* %11
%12 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %13
13: ; preds = %5, %7
%14 = phi i8* [ %6, %5 ], [ %11, %7 ]
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i8* %14)
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret void
}