#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 */
typedef size_t int8_t;

/* Variables and functions */
int /*<<< orphan*/ strncmp(char const *, char const *const, unsigned int);
int parse_enum_n(const char *arg, unsigned num_chars, const char *const *names,
                 int8_t *dst) {
  int8_t i;
  for (i = 0; names[i]; i++) {
    if (!strncmp(arg, names[i], num_chars)) {
      *dst = i;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_enum_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1190 <parse_enum_n+0x80>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    117a <parse_enum_n+0x6a>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1197 <parse_enum_n+0x87>
jmp    117f <parse_enum_n+0x6f>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    112f <parse_enum_n+0x1f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_enum_n>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    (%rdx),%rsi
test   %rsi,%rsi
je     114d <parse_enum_n+0x3d>
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rdi,%r12
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1151 <parse_enum_n+0x41>
mov    0x8(%rbx,%rbp,8),%rsi
add    $0x1,%rbp
test   %rsi,%rsi
jne    1130 <parse_enum_n+0x20>
xor    %eax,%eax
jmp    1159 <parse_enum_n+0x49>
mov    %rbp,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parse_enum_n(i8* %0, i32 %1, i8** %2, i64* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i64*
%10 = alloca i64
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i64* %3, i64** %9
store i64 0, i64* %10
br label %11
11: ; preds = %30, %4
%12 = load i8**, i8*** %8
%13 = load i64, i64* %10
%14 = getelementptr inbounds i8*, i8** %12, i64 %13
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %33
17: ; preds = %11
%18 = load i8*, i8** %6
%19 = load i8**, i8*** %8
%20 = load i64, i64* %10
%21 = getelementptr inbounds i8*, i8** %19, i64 %20
%22 = load i8*, i8** %21
%23 = load i32, i32* %7
%24 = call i32 @strncmp(i8* %18, i8* %22, i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %17
%27 = load i64, i64* %10
%28 = load i64*, i64** %9
store i64 %27, i64* %28
store i32 1, i32* %5
br label %34
29: ; preds = %17
br label %30
30: ; preds = %29
%31 = load i64, i64* %10
%32 = add i64 %31, 1
store i64 %32, i64* %10
br label %11
33: ; preds = %11
store i32 0, i32* %5
br label %34
34: ; preds = %33, %26
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
define i32 @parse_enum_n(i8* %0, i32 %1, i8** nocapture %2, i64* nocapture writeonly %3) {
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %18, label %7
7: ; preds = %4, %13
%8 = phi i8* [ %16, %13 ], [ %5, %4 ]
%9 = phi i64 [ %14, %13 ], [ 0, %4 ]
%10 = tail call i32 @strncmp(i8* %0, i8* %8, i32 %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
store i64 %9, i64* %3
br label %18
13: ; preds = %7
%14 = add i64 %9, 1
%15 = getelementptr inbounds i8*, i8** %2, i64 %14
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %7
18: ; preds = %13, %4, %12
%19 = phi i32 [ 1, %12 ], [ 0, %4 ], [ 0, %13 ]
ret i32 %19
}