#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*/ printf(char *, char const);
void output_optstring(const char *optstring) {
  int i;
  for (i = 0; optstring[i]; i++) {
    if (optstring[i + 1] == ':') {
      printf("# -%c <flag>\n", optstring[i]);
      printf("-%c @@\n\n", optstring[i]);
      i++;
    } else {
      printf("# -%c takes no arguments\n", optstring[i]);
    }
    printf("# End of -%c section\n\n", optstring[i]);
  }
}


x86 assembly (clang, -O0):
<output_optstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11cb <output_optstring+0xbb>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    118d <output_optstring+0x7d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xea2(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe98(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a5 <output_optstring+0x95>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe7b(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe7d(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <output_optstring+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_optstring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     119b <output_optstring+0x8b>
mov    %rdi,%r15
xor    %ebp,%ebp
mov    %rdi,%rbx
jmp    1166 <output_optstring+0x56>
nopl   0x0(%rax,%rax,1)
movsbl %al,%esi
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
mov    %r12,%r14
mov    %r12d,%ebp
mov    %r13,%r12
movsbl (%r15,%r12,1),%esi
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
lea    (%r15,%r14,1),%rbx
movzbl (%r15,%r14,1),%eax
test   %al,%al
je     119b <output_optstring+0x8b>
movslq %ebp,%r13
lea    0x1(%r13),%r12
cmpb   $0x3a,0x1(%r15,%r13,1)
jne    1130 <output_optstring+0x20>
movsbl %al,%esi
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movsbl (%rbx),%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
add    $0x2,%ebp
movslq %ebp,%r14
jmp    1148 <output_optstring+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"# -%c <flag>\0A\00"
@.str.1 = [9 x i8] c"-%c @@\0A\0A\00"
@.str.2 = [26 x i8] c"# -%c takes no arguments\0A\00"
@.str.3 = [23 x i8] c"# End of -%c section\0A\0A\00"
define void @output_optstring(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %49, %1
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %52
11: ; preds = %4
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 58
br i1 %19, label %20, label %35
20: ; preds = %11
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8 signext %31)
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %42
35: ; preds = %11
%36 = load i8*, i8** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8 signext %40)
br label %42
42: ; preds = %35, %20
%43 = load i8*, i8** %2
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8 signext %47)
br label %49
49: ; preds = %42
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %4
52: ; preds = %4
ret void
}

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