#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 */
int /*<<< orphan*/ irc_isnickchar(int /*<<< orphan*/, int);
int irc_isnick(const char *str) {
  if (!irc_isnickchar(*str++, 1))
    return 0;
  while (*str) {
    if (!irc_isnickchar(*str++, 0))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<irc_isnick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
mov    $0x1,%esi
call   1030 <irc_isnickchar@plt>
cmp    $0x0,%eax
jne    114d <irc_isnick+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    1199 <irc_isnick+0x89>
jmp    1152 <irc_isnick+0x42>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1192 <irc_isnick+0x82>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
xor    %esi,%esi
call   1030 <irc_isnickchar@plt>
cmp    $0x0,%eax
jne    118d <irc_isnick+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    1199 <irc_isnick+0x89>
jmp    1152 <irc_isnick+0x42>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_isnick>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
mov    $0x1,%esi
call   1030 <irc_isnickchar@plt>
test   %eax,%eax
je     1148 <irc_isnick+0x38>
add    $0x1,%rbx
xor    %ebp,%ebp
nopl   (%rax)
movsbl (%rbx),%edi
test   %edi,%edi
je     114c <irc_isnick+0x3c>
xor    %esi,%esi
call   1030 <irc_isnickchar@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1130 <irc_isnick+0x20>
jmp    1151 <irc_isnick+0x41>
xor    %ebp,%ebp
jmp    1151 <irc_isnick+0x41>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @irc_isnick(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i32 1
store i8* %5, i8** %3
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = call i32 @irc_isnickchar(i32 %7, i32 1)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %26
11: ; preds = %1
br label %12
12: ; preds = %24, %11
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
%21 = call i32 @irc_isnickchar(i32 %20, i32 0)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %16
store i32 0, i32* %2
br label %26
24: ; preds = %16
br label %12
25: ; preds = %12
store i32 1, i32* %2
br label %26
26: ; preds = %25, %23, %10
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @irc_isnick(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = tail call i32 @irc_isnickchar(i32 %3, i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %1, %11
%7 = phi i8* [ %8, %11 ], [ %0, %1 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = sext i8 %9 to i32
%13 = tail call i32 @irc_isnickchar(i32 %12, i32 0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %11, %1
%16 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 0, %11 ]
ret i32 %16
}