#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*/ printf(char *, char *);
void output_longopts(const struct option *longopts) {
  int i;
  for (i = 0; longopts[i].name; i++) {
    printf("# Start of --%s section\n", longopts[i].name);
    if (longopts[i].has_arg) {
      printf("# --%s <flag>\n", longopts[i].name);
      printf("--%s @@\n\n", longopts[i].name);
    } else {
      printf("# --%s takes no arguments\n", longopts[i].name);
    }
    printf("# End of --%s flag section\n\n", longopts[i].name);
  }
}


x86 assembly (clang, -O0):
<output_longopts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     11ff <output_longopts+0xef>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,0x8(%rax)
je     11b5 <output_longopts+0xa5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <output_longopts+0xc3>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <output_longopts+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_longopts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%rsi
test   %rsi,%rsi
je     1192 <output_longopts+0x82>
mov    %rdi,%rbx
lea    0xed3(%rip),%r14
lea    0xefe(%rip),%r15
lea    0xf12(%rip),%r12
lea    0xed7(%rip),%r13
lea    0xedf(%rip),%rbp
jmp    1170 <output_longopts+0x60>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <printf@plt>
mov    (%rbx),%rsi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x10(%rbx),%rsi
add    $0x10,%rbx
test   %rsi,%rsi
je     1192 <output_longopts+0x82>
mov    %r14,%rdi
call   1030 <printf@plt>
cmpq   $0x0,0x8(%rbx)
mov    (%rbx),%rsi
je     1150 <output_longopts+0x40>
mov    %r13,%rdi
call   1030 <printf@plt>
mov    (%rbx),%rsi
mov    %rbp,%rdi
jmp    1153 <output_longopts+0x43>
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 = [25 x i8] c"# Start of --%s section\0A\00"
@.str.1 = [15 x i8] c"# --%s <flag>\0A\00"
@.str.2 = [10 x i8] c"--%s @@\0A\0A\00"
@.str.3 = [27 x i8] c"# --%s takes no arguments\0A\00"
@.str.4 = [29 x i8] c"# End of --%s flag section\0A\0A\00"
define void @output_longopts(%struct.option* %0) {
%2 = alloca %struct.option*
%3 = alloca i32
store %struct.option* %0, %struct.option** %2
store i32 0, i32* %3
br label %4
4: ; preds = %58, %1
%5 = load %struct.option*, %struct.option** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds %struct.option, %struct.option* %5, i64 %7
%9 = getelementptr inbounds %struct.option, %struct.option* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %61
12: ; preds = %4
%13 = load %struct.option*, %struct.option** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds %struct.option, %struct.option* %13, i64 %15
%17 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load %struct.option*, %struct.option** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds %struct.option, %struct.option* %20, i64 %22
%24 = getelementptr inbounds %struct.option, %struct.option* %23, i32 0, i32 1
%25 = load i64, i64* %24
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %42
27: ; preds = %12
%28 = load %struct.option*, %struct.option** %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds %struct.option, %struct.option* %28, i64 %30
%32 = getelementptr inbounds %struct.option, %struct.option* %31, i32 0, i32 0
%33 = load i8*, i8** %32
%34 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load %struct.option*, %struct.option** %2
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds %struct.option, %struct.option* %35, i64 %37
%39 = getelementptr inbounds %struct.option, %struct.option* %38, i32 0, i32 0
%40 = load i8*, i8** %39
%41 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %50
42: ; preds = %12
%43 = load %struct.option*, %struct.option** %2
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds %struct.option, %struct.option* %43, i64 %45
%47 = getelementptr inbounds %struct.option, %struct.option* %46, i32 0, i32 0
%48 = load i8*, i8** %47
%49 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %42, %27
%51 = load %struct.option*, %struct.option** %2
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds %struct.option, %struct.option* %51, i64 %53
%55 = getelementptr inbounds %struct.option, %struct.option* %54, i32 0, i32 0
%56 = load i8*, i8** %55
%57 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 1
store i32 %60, i32* %3
br label %4
61: ; preds = %4
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i64 }
@.str = [25 x i8] c"# Start of --%s section\0A\00"
@.str.1 = [15 x i8] c"# --%s <flag>\0A\00"
@.str.2 = [10 x i8] c"--%s @@\0A\0A\00"
@.str.3 = [27 x i8] c"# --%s takes no arguments\0A\00"
@.str.4 = [29 x i8] c"# End of --%s flag section\0A\0A\00"
define void @output_longopts(%struct.option* nocapture %0) {
%2 = getelementptr inbounds %struct.option, %struct.option* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %27, label %5
5: ; preds = %1, %20
%6 = phi i64 [ %23, %20 ], [ 0, %1 ]
%7 = phi i8* [ %25, %20 ], [ %3, %1 ]
%8 = phi i8** [ %24, %20 ], [ %2, %1 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %7)
%10 = getelementptr inbounds %struct.option, %struct.option* %0, i64 %6, i32 1
%11 = load i64, i64* %10
%12 = icmp eq i64 %11, 0
%13 = load i8*, i8** %8
br i1 %12, label %18, label %14
14: ; preds = %5
%15 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%16 = load i8*, i8** %8
%17 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %20
18: ; preds = %5
%19 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %20
20: ; preds = %18, %14
%21 = load i8*, i8** %8
%22 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = add nuw i64 %6, 1
%24 = getelementptr inbounds %struct.option, %struct.option* %0, i64 %23, i32 0
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %5
27: ; preds = %20, %1
ret void
}