#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 */
char *buflist_bar_item_get_name(int);
scalar_t__ strcmp(char const *, char const *);
int buflist_bar_item_get_index(const char *item_name) {
  int i;
  const char *ptr_item_name;
  for (i = 0; i < 3; i++) {
    ptr_item_name = buflist_bar_item_get_name(i);
    if (strcmp(ptr_item_name, item_name) == 0)
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<buflist_bar_item_get_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    117e <buflist_bar_item_get_index+0x5e>
mov    -0x14(%rbp),%edi
call   1040 <buflist_bar_item_get_name@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116b <buflist_bar_item_get_index+0x4b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <buflist_bar_item_get_index+0x65>
jmp    1170 <buflist_bar_item_get_index+0x50>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <buflist_bar_item_get_index+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buflist_bar_item_get_index>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <buflist_bar_item_get_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117b <buflist_bar_item_get_index+0x5b>
mov    $0x1,%ebp
mov    $0x1,%edi
call   1040 <buflist_bar_item_get_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117b <buflist_bar_item_get_index+0x5b>
mov    $0x2,%edi
call   1040 <buflist_bar_item_get_name@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
neg    %rax
sbb    %ebp,%ebp
or     $0x2,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @buflist_bar_item_get_index(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i8* @buflist_bar_item_get_name(i32 %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = load i8*, i8** %3
%14 = call i64 @strcmp(i8* %12, i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = load i32, i32* %4
store i32 %17, i32* %2
br label %23
18: ; preds = %9
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %6
22: ; preds = %6
store i32 -1, i32* %2
br label %23
23: ; preds = %22, %16
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @buflist_bar_item_get_index(i8* %0) {
%2 = tail call i8* @buflist_bar_item_get_name(i32 0)
%3 = tail call i64 @strcmp(i8* %2, i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = tail call i8* @buflist_bar_item_get_name(i32 1)
%7 = tail call i64 @strcmp(i8* %6, i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = tail call i8* @buflist_bar_item_get_name(i32 2)
%11 = tail call i64 @strcmp(i8* %10, i8* %0)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 2, i32 -1
br label %14
14: ; preds = %9, %5, %1
%15 = phi i32 [ 0, %1 ], [ 1, %5 ], [ %13, %9 ]
ret i32 %15
}