#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 ssize_t;

/* Variables and functions */
char *strchr(char const *const, char);
ssize_t irc_ischannel(char const *const channel) {
  char *ret;
  char prefix;
  char const *const prefixes = "&#+!";
  if (channel == NULL) {
    return (-1);
  }
  prefix = channel[0];
  ret = strchr(prefixes, prefix);
  if (ret != 0) {
    return (ssize_t)(ret - prefixes);
  } else {
    return (-1);
  }
}


x86 assembly (clang, -O0):
<irc_ischannel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113e <irc_ischannel+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1183 <irc_ischannel+0x73>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
lea    0xeb2(%rip),%rdi
movsbl -0x19(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117c <irc_ischannel+0x6c>
mov    -0x18(%rbp),%rax
lea    0xe8f(%rip),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    1183 <irc_ischannel+0x73>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_ischannel>:
push   %rbx
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     113a <irc_ischannel+0x2a>
movsbl (%rdi),%esi
lea    0xedb(%rip),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     113a <irc_ischannel+0x2a>
lea    0xeca(%rip),%rcx
sub    %ecx,%eax
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"&#+!\00"
define i32 @irc_ischannel(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
store i8* %0, i8** %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %24
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
store i8 %13, i8* %5
%14 = load i8, i8* %5
%15 = call i8* @strchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 signext %14)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %23
18: ; preds = %10
%19 = load i8*, i8** %4
%20 = ptrtoint i8* %19 to i64
%21 = sub i64 %20, ptrtoint ([5 x i8]* @.str to i64)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
br label %24
23: ; preds = %10
store i32 -1, i32* %2
br label %24
24: ; preds = %23, %18, %9
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"&#+!\00"
define i32 @irc_ischannel(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = tail call i8* @strchr(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = ptrtoint i8* %5 to i64
%9 = trunc i64 %8 to i32
%10 = sub i32 %9, ptrtoint ([5 x i8]* @.str to i32)
br label %11
11: ; preds = %3, %1, %7
%12 = phi i32 [ %10, %7 ], [ -1, %1 ], [ -1, %3 ]
ret i32 %12
}