#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 int /*<<< orphan*/ int32_t;

/* Variables and functions */
scalar_t__ parse_int32(char const *, int /*<<< orphan*/ *, char const **);
scalar_t__ strncmp(char *, char const *, int);
int get_index(const char *key, int32_t *index, const char **suffix) {
  const char *tail;
  if (strncmp("dev", key, 3)) {
    return 1;
  }
  if (parse_int32(key + 3, index, &tail) != 0) {
    return 1;
  }
  if (*tail != ' ') {
    return 1;
  }
  ++tail;
  if (suffix != NULL) {
    *suffix = tail;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec1(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     115f <get_index+0x3f>
movl   $0x1,-0x4(%rbp)
jmp    11cf <get_index+0xaf>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <parse_int32@plt>
cmp    $0x0,%rax
je     118a <get_index+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11cf <get_index+0xaf>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11a6 <get_index+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11cf <get_index+0xaf>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c8 <get_index+0xa8>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_index>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    117c <get_index+0x5c>
add    $0x3,%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <parse_int32@plt>
test   %rax,%rax
jne    117c <get_index+0x5c>
mov    (%rsp),%rax
cmpb   $0x20,(%rax)
jne    117c <get_index+0x5c>
xor    %ebp,%ebp
test   %r14,%r14
je     117c <get_index+0x5c>
add    $0x1,%rax
mov    %rax,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"dev\00"
define i32 @get_index(i8* %0, i32* %1, i8** writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = tail call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0, i32 3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %0, i64 3
%10 = call i64 @parse_int32(i8* %9, i32* %1, i8** %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = icmp eq i8** %2, null
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %19, i8** %2
br label %20
20: ; preds = %16, %18, %12, %8, %3
%21 = phi i32 [ 1, %3 ], [ 1, %8 ], [ 1, %12 ], [ 0, %18 ], [ 0, %16 ]
ret i32 %21
}