#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*/ IsChannelChar(char const);
int strlen(char const *);
int IsValidChannel(const char *chan) {
  int ret = 1;
  int i;
  if (strlen(chan) > 63 || strlen(chan) < 2) {
    ret = 0;
  } else if (chan[0] != '#') {
    ret = 0;
  } else {
    for (i = 1; chan[i] != '\0'; i++) {
      if (!IsChannelChar(chan[i])) {
        ret = 0;
        break;
      }
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<IsValidChannel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3f,%eax
jg     1157 <IsValidChannel+0x37>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jge    1163 <IsValidChannel+0x43>
movl   $0x0,-0xc(%rbp)
jmp    11de <IsValidChannel+0xbe>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     117f <IsValidChannel+0x5f>
movl   $0x0,-0xc(%rbp)
jmp    11d9 <IsValidChannel+0xb9>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11d4 <IsValidChannel+0xb4>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <IsChannelChar@plt>
cmp    $0x0,%eax
jne    11c1 <IsValidChannel+0xa1>
movl   $0x0,-0xc(%rbp)
jmp    11d4 <IsValidChannel+0xb4>
jmp    11c6 <IsValidChannel+0xa6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1186 <IsValidChannel+0x66>
jmp    11d9 <IsValidChannel+0xb9>
jmp    11de <IsValidChannel+0xbe>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsValidChannel>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x3f,%eax
jg     116c <IsValidChannel+0x4c>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     116c <IsValidChannel+0x4c>
cmpb   $0x23,(%rbx)
jne    116c <IsValidChannel+0x4c>
mov    0x1(%rbx),%al
test   %al,%al
je     1167 <IsValidChannel+0x47>
add    $0x2,%rbx
nop
movsbl %al,%edi
call   1030 <IsChannelChar@plt>
test   %eax,%eax
je     116c <IsValidChannel+0x4c>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <IsValidChannel+0x30>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @IsValidChannel(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = icmp sgt i32 %6, 63
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %8, %1
store i32 0, i32* %3
br label %44
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 35
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 0, i32* %3
br label %43
20: ; preds = %13
store i32 1, i32* %4
br label %21
21: ; preds = %39, %20
%22 = load i8*, i8** %2
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %21
%30 = load i8*, i8** %2
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @IsChannelChar(i8 signext %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %29
store i32 0, i32* %3
br label %42
38: ; preds = %29
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %21
42: ; preds = %37, %21
br label %43
43: ; preds = %42, %19
br label %44
44: ; preds = %43, %12
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @IsValidChannel(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 63
br i1 %3, label %24, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp slt i32 %5, 2
br i1 %6, label %24, label %7
7: ; preds = %4
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 35
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %24, label %18
14: ; preds = %18
%15 = getelementptr inbounds i8, i8* %0, i64 %23
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %10, %14
%19 = phi i64 [ %23, %14 ], [ 1, %10 ]
%20 = phi i8 [ %16, %14 ], [ %12, %10 ]
%21 = tail call i32 @IsChannelChar(i8 signext %20)
%22 = icmp eq i32 %21, 0
%23 = add nuw i64 %19, 1
br i1 %22, label %24, label %14
24: ; preds = %14, %18, %10, %7, %1, %4
%25 = phi i32 [ 0, %4 ], [ 0, %1 ], [ 0, %7 ], [ 1, %10 ], [ 1, %14 ], [ 0, %18 ]
ret i32 %25
}