#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 */
int irc_server_get_prefix_char_index(struct t_irc_server *, char);
char *irc_server_get_prefix_modes(struct t_irc_server *);
char irc_server_get_prefix_mode_for_char(struct t_irc_server *server,
                                         char prefix_char) {
  const char *prefix_modes;
  int index;
  if (server) {
    prefix_modes = irc_server_get_prefix_modes(server);
    index = irc_server_get_prefix_char_index(server, prefix_char);
    if (index >= 0)
      return prefix_modes[index];
  }
  return ' ';
}


x86 assembly (clang, -O0):
<irc_server_get_prefix_mode_for_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <irc_server_get_prefix_mode_for_char+0x5c>
mov    -0x10(%rbp),%rdi
call   1030 <irc_server_get_prefix_modes@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1040 <irc_server_get_prefix_char_index@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1177 <irc_server_get_prefix_mode_for_char+0x57>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1(%rbp)
jmp    1180 <irc_server_get_prefix_mode_for_char+0x60>
jmp    117c <irc_server_get_prefix_mode_for_char+0x5c>
movb   $0x20,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_server_get_prefix_mode_for_char>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x20,%bpl
test   %rdi,%rdi
je     1153 <irc_server_get_prefix_mode_for_char+0x33>
mov    %esi,%r15d
mov    %rdi,%rbx
call   1030 <irc_server_get_prefix_modes@plt>
mov    %rax,%r14
movsbl %r15b,%esi
mov    %rbx,%rdi
call   1040 <irc_server_get_prefix_char_index@plt>
test   %eax,%eax
js     1153 <irc_server_get_prefix_mode_for_char+0x33>
mov    %eax,%eax
mov    (%r14,%rax,1),%bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.t_irc_server = type { i32 }
define signext i8 @irc_server_get_prefix_mode_for_char(%struct.t_irc_server* %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca %struct.t_irc_server*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i32
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 %25
10: ; preds = %2
%11 = load %struct.t_irc_server*, %struct.t_irc_server** %4
%12 = call i8* @irc_server_get_prefix_modes(%struct.t_irc_server* %11)
store i8* %12, i8** %6
%13 = load %struct.t_irc_server*, %struct.t_irc_server** %4
%14 = load i8, i8* %5
%15 = call i32 @irc_server_get_prefix_char_index(%struct.t_irc_server* %13, i8 signext %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %10
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %3
br label %26
24: ; preds = %10
br label %25
25: ; preds = %24, %2
store i8 32, i8* %3
br label %26
26: ; preds = %25, %18
%27 = load i8, i8* %3
ret i8 %27
}

LLVM IR (-O2):
%struct.t_irc_server = type { i32 }
define signext i8 @irc_server_get_prefix_mode_for_char(%struct.t_irc_server* %0, i8 signext %1) {
%3 = icmp eq %struct.t_irc_server* %0, null
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call i8* @irc_server_get_prefix_modes(%struct.t_irc_server* %0)
%6 = tail call i32 @irc_server_get_prefix_char_index(%struct.t_irc_server* %0, i8 signext %1)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = zext i32 %6 to i64
%10 = getelementptr inbounds i8, i8* %5, i64 %9
%11 = load i8, i8* %10
br label %12
12: ; preds = %2, %4, %8
%13 = phi i8 [ %11, %8 ], [ 32, %4 ], [ 32, %2 ]
ret i8 %13
}