#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 */
struct t_irc_server {
  int dummy;
};

/* Variables and functions */
char *irc_server_get_prefix_chars(struct t_irc_server *);
char *strchr(char const *, char);
int irc_server_get_prefix_char_index(struct t_irc_server *server,
                                     char prefix_char) {
  const char *prefix_chars;
  char *pos;
  if (server) {
    prefix_chars = irc_server_get_prefix_chars(server);
    pos = strchr(prefix_chars, prefix_char);
    if (pos)
      return pos - prefix_chars;
  }
  return -1;
}


x86 assembly (clang, -O0):
<irc_server_get_prefix_char_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117e <irc_server_get_prefix_char_index+0x5e>
mov    -0x10(%rbp),%rdi
call   1040 <irc_server_get_prefix_chars@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1179 <irc_server_get_prefix_char_index+0x59>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    1185 <irc_server_get_prefix_char_index+0x65>
jmp    117e <irc_server_get_prefix_char_index+0x5e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_server_get_prefix_char_index>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     114e <irc_server_get_prefix_char_index+0x2e>
mov    %esi,%ebp
call   1040 <irc_server_get_prefix_chars@plt>
mov    %rax,%r14
movsbl %bpl,%esi
mov    %rax,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     114e <irc_server_get_prefix_char_index+0x2e>
sub    %r14d,%eax
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.t_irc_server = type { i32 }
define i32 @irc_server_get_prefix_char_index(%struct.t_irc_server* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca %struct.t_irc_server*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
store %struct.t_irc_server* %0, %struct.t_irc_server** %4
store i8 %1, i8* %5
%8 = load %struct.t_irc_server*, %struct.t_irc_server** %4
%9 = icmp ne %struct.t_irc_server* %8, null
br i1 %9, label %10, label %26
10: ; preds = %2
%11 = load %struct.t_irc_server*, %struct.t_irc_server** %4
%12 = call i8* @irc_server_get_prefix_chars(%struct.t_irc_server* %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = load i8, i8* %5
%15 = call i8* @strchr(i8* %13, i8 signext %14)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = load i8*, i8** %7
%20 = load i8*, i8** %6
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %3
br label %27
25: ; preds = %10
br label %26
26: ; preds = %25, %2
store i32 -1, i32* %3
br label %27
27: ; preds = %26, %18
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.t_irc_server = type { i32 }
define i32 @irc_server_get_prefix_char_index(%struct.t_irc_server* %0, i8 signext %1) {
%3 = icmp eq %struct.t_irc_server* %0, null
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = tail call i8* @irc_server_get_prefix_chars(%struct.t_irc_server* %0)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %5, i8 signext %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint i8* %5 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
br label %13
13: ; preds = %2, %4, %8
%14 = phi i32 [ %12, %8 ], [ -1, %4 ], [ -1, %2 ]
ret i32 %14
}