#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
char *getvalue(int *, int, char **);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char const *);
int getchoice(int *argip, int argc, char *argv[], const char *options[]) {
  const char *arg = getvalue(argip, argc, argv);
  int value = -1;
  while (options[++value])
    if ((strcmp(arg, options[value]) == 0))
      return value;
  fprintf(stderr, "Unrecognised option value %s\n", arg);
  exit(1);
}


x86 assembly (clang, -O0):
<getchoice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <getvalue@plt>
mov    %rax,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ba <getchoice+0x7a>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b5 <getchoice+0x75>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    1172 <getchoice+0x32>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<getchoice>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%rbx
call   1030 <getvalue@plt>
mov    %rax,%r14
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1183 <getchoice+0x43>
mov    %r14,%rdi
call   1040 <strcmp@plt>
add    $0x1,%ebp
add    $0x8,%rbx
test   %rax,%rax
jne    1160 <getchoice+0x20>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Unrecognised option value %s\0A\00"
define i32 @getchoice(i32* %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = load i8**, i8*** %7
%14 = call i8* @getvalue(i32* %11, i32 %12, i8** %13)
store i8* %14, i8** %9
store i32 -1, i32* %10
br label %15
15: ; preds = %34, %4
%16 = load i8**, i8*** %8
%17 = load i32, i32* %10
%18 = add nsw i32 %17, 1
store i32 %18, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %16, i64 %19
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %35
23: ; preds = %15
%24 = load i8*, i8** %9
%25 = load i8**, i8*** %8
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %24, i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %23
%33 = load i32, i32* %10
ret i32 %33
34: ; preds = %23
br label %15
35: ; preds = %15
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %9
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Unrecognised option value %s\0A\00"
define i32 @getchoice(i32* %0, i32 %1, i8** %2, i8** nocapture %3) {
%5 = tail call i8* @getvalue(i32* %0, i32 %1, i8** %2)
br label %6
6: ; preds = %12, %4
%7 = phi i64 [ %8, %12 ], [ -1, %4 ]
%8 = add nsw i64 %7, 1
%9 = getelementptr inbounds i8*, i8** %3, i64 %8
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = tail call i64 @strcmp(i8* %5, i8* %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %12
%16 = trunc i64 %8 to i32
ret i32 %16
17: ; preds = %6
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %5)
%20 = tail call i32 @exit(i32 1)
unreachable
}