#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 *, char *);
int /*<<< orphan*/ opt_err_pfx();
int /*<<< orphan*/ opt_err_sfx();
char *opt_name();
int /*<<< orphan*/ stderr;
void badchoice(const char **choices, const char *arg) {
  int i;
  for (i = 0; !(!(choices[i]) || !*(choices[i])); ++i)
    ;
  if (choices[i]) {
    const char *temp = choices[i];
    choices[i] = choices[0];
    choices[0] = temp;
    return;
  }
  opt_err_pfx();
  fprintf(stderr, "invalid choice '%s' for option %s", arg, opt_name());
  opt_err_sfx();
}


x86 assembly (clang, -O0):
<badchoice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    $0x1,%al
cmpq   $0x0,(%rcx,%rdx,8)
mov    %al,-0x21(%rbp)
je     1186 <badchoice+0x46>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpb   $0x0,(%rax)
setne  %al
xor    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    1198 <badchoice+0x58>
jmp    11ab <badchoice+0x6b>
jmp    119d <badchoice+0x5d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <badchoice+0x17>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11f1 <badchoice+0xb1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1230 <badchoice+0xf0>
mov    $0x0,%al
call   1050 <opt_err_pfx@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <opt_name@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xddc(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <opt_err_sfx@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<badchoice>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rdi),%rax
test   %rax,%rax
je     1173 <badchoice+0x33>
xor    %ecx,%ecx
mov    %rax,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,(%rdx)
je     11ab <badchoice+0x6b>
mov    0x8(%rdi,%rcx,8),%rdx
add    $0x1,%rcx
test   %rdx,%rdx
jne    1160 <badchoice+0x20>
xor    %eax,%eax
call   1050 <opt_err_pfx@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%ebp
xor    %eax,%eax
call   1030 <opt_name@plt>
lea    0xe6f(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <opt_err_sfx@plt>
mov    %ecx,%ecx
mov    %rax,(%rdi,%rcx,8)
mov    %rdx,(%rdi)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"invalid choice '%s' for option %s\00"
define void @badchoice(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %7
7: ; preds = %27, %2
%8 = load i8**, i8*** %3
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %7
%15 = load i8**, i8*** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
%22 = xor i1 %21, true
br label %23
23: ; preds = %14, %7
%24 = phi i1 [ true, %7 ], [ %22, %14 ]
%25 = xor i1 %24, true
br i1 %25, label %26, label %30
26: ; preds = %23
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %7
30: ; preds = %23
%31 = load i8**, i8*** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %53
37: ; preds = %30
%38 = load i8**, i8*** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
store i8* %42, i8** %6
%43 = load i8**, i8*** %3
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = load i8**, i8*** %3
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
store i8* %45, i8** %49
%50 = load i8*, i8** %6
%51 = load i8**, i8*** %3
%52 = getelementptr inbounds i8*, i8** %51, i64 0
store i8* %50, i8** %52
br label %60
53: ; preds = %30
%54 = call i32 (...) @opt_err_pfx()
%55 = load i32, i32* @stderr
%56 = load i8*, i8** %4
%57 = call i8* (...) @opt_name()
%58 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %56, i8* %57)
%59 = call i32 (...) @opt_err_sfx()
br label %60
60: ; preds = %53, %37
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"invalid choice '%s' for option %s\00"
define void @badchoice(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2, %10
%6 = phi i64 [ %11, %10 ], [ 0, %2 ]
%7 = phi i8* [ %13, %10 ], [ %3, %2 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = add nuw i64 %6, 1
%12 = getelementptr inbounds i8*, i8** %0, i64 %11
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %5
15: ; preds = %5
%16 = and i64 %6, 4294967295
%17 = getelementptr inbounds i8*, i8** %0, i64 %16
store i8* %3, i8** %17
store i8* %7, i8** %0
br label %24
18: ; preds = %10, %2
%19 = tail call i32 (...) @opt_err_pfx()
%20 = load i32, i32* @stderr
%21 = tail call i8* (...) @opt_name()
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %21)
%23 = tail call i32 (...) @opt_err_sfx()
br label %24
24: ; preds = %18, %15
ret void
}