#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 */
struct option {
  char *name;
  scalar_t__ has_arg;
};

/* Variables and functions */
int /*<<< orphan*/ assert(char const *);
scalar_t__ optional_argument;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ required_argument;
void show_usage(const char *pname, const struct option *opt) {
  assert(pname);
  printf("%s\n", pname);
  while (opt && opt->name) {
    printf("  --%s", opt->name);
    if (opt->has_arg == required_argument)
      printf(" <arg>\n");
    else if (opt->has_arg == optional_argument)
      printf(" [arg]\n");
    else
      printf("\n");
    opt++;
  }
}


x86 assembly (clang, -O0):
<show_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1169 <show_usage+0x49>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1179 <show_usage+0x59>
jmp    1208 <show_usage+0xe8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e43(%rip),%rcx
cmp    (%rcx),%rax
jne    11b9 <show_usage+0x99>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <show_usage+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%rax
jne    11e4 <show_usage+0xc4>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <show_usage+0xd2>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <show_usage+0xd7>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    114b <show_usage+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_usage>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1060 <assert@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
test   %rbx,%rbx
je     11ec <show_usage+0xac>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11ec <show_usage+0xac>
add    $0x10,%rbx
lea    0xe82(%rip),%r14
mov    0x2e5b(%rip),%r13
lea    0xe82(%rip),%r15
mov    0x2e55(%rip),%rbp
lea    0xe6d(%rip),%r12
jmp    11b4 <show_usage+0x74>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <puts@plt>
mov    (%rbx),%rsi
add    $0x10,%rbx
test   %rsi,%rsi
je     11ec <show_usage+0xac>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x8(%rbx),%rax
cmp    0x0(%r13),%rax
je     11a0 <show_usage+0x60>
cmp    0x0(%rbp),%rax
jne    11e0 <show_usage+0xa0>
mov    %r12,%rdi
jmp    11a3 <show_usage+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a8 <show_usage+0x68>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i64 }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [7 x i8] c" --%s\00"
@required_argument = global i64 0
@.str.2 = [8 x i8] c" <arg>\0A\00"
@optional_argument = global i64 0
@.str.3 = [8 x i8] c" [arg]\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @show_usage(i8* %0, %struct.option* %1) {
%3 = alloca i8*
%4 = alloca %struct.option*
store i8* %0, i8** %3
store %struct.option* %1, %struct.option** %4
%5 = load i8*, i8** %3
%6 = call i32 @assert(i8* %5)
%7 = load i8*, i8** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %42, %2
%10 = load %struct.option*, %struct.option** %4
%11 = icmp ne %struct.option* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load %struct.option*, %struct.option** %4
%14 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br label %17
17: ; preds = %12, %9
%18 = phi i1 [ false, %9 ], [ %16, %12 ]
br i1 %18, label %19, label %45
19: ; preds = %17
%20 = load %struct.option*, %struct.option** %4
%21 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load %struct.option*, %struct.option** %4
%25 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 1
%26 = load i64, i64* %25
%27 = load i64, i64* @required_argument
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %42
31: ; preds = %19
%32 = load %struct.option*, %struct.option** %4
%33 = getelementptr inbounds %struct.option, %struct.option* %32, i32 0, i32 1
%34 = load i64, i64* %33
%35 = load i64, i64* @optional_argument
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %41
39: ; preds = %31
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
br label %42
42: ; preds = %41, %29
%43 = load %struct.option*, %struct.option** %4
%44 = getelementptr inbounds %struct.option, %struct.option* %43, i32 1
store %struct.option* %44, %struct.option** %4
br label %9
45: ; preds = %17
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i64 }
@.str.1 = [7 x i8] c" --%s\00"
@required_argument = global i64 0
@optional_argument = global i64 0
@str = [7 x i8] c" [arg]\00"
@str.5 = [7 x i8] c" <arg>\00"
define void @show_usage(i8* %0, %struct.option* %1) {
%3 = tail call i32 @assert(i8* %0)
%4 = tail call i32 @puts(i8* dereferenceable(1) %0)
%5 = icmp eq %struct.option* %1, null
br i1 %5, label %32, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.option, %struct.option* %1, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %32, label %10
10: ; preds = %6, %27
%11 = phi i8* [ %30, %27 ], [ %8, %6 ]
%12 = phi %struct.option* [ %28, %27 ], [ %1, %6 ]
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%14 = getelementptr inbounds %struct.option, %struct.option* %12, i64 0, i32 1
%15 = load i64, i64* %14
%16 = load i64, i64* @required_argument
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
br label %27
20: ; preds = %10
%21 = load i64, i64* @optional_argument
%22 = icmp eq i64 %15, %21
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %27
25: ; preds = %20
%26 = tail call i32 @putchar(i32 10)
br label %27
27: ; preds = %23, %25, %18
%28 = getelementptr inbounds %struct.option, %struct.option* %12, i64 1
%29 = getelementptr inbounds %struct.option, %struct.option* %28, i64 0, i32 0
%30 = load i8*, i8** %29
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %10
32: ; preds = %27, %6, %2
ret void
}