#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 */
scalar_t__ strcaseeq(char const *, char const *);
int check_chan(const char *userchan, const char *serverchan) {
  char temp[100];
  int x = 0;
  if (strcaseeq(userchan, "all")) {
    return (1);
  }
  if (strcaseeq(userchan, serverchan)) {
    return (1);
  }
  while (*userchan != '\0') {
    if (*userchan == ',') {
      temp[x] = '\0';
      if (strcaseeq(temp, serverchan)) {
        return (1);
      } else {
        x = 0;
        userchan++;
      }
    } else {
      temp[x++] = *userchan++;
    }
  }
  temp[x] = '\0';
  if (strcaseeq(temp, serverchan)) {
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<check_chan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec8(%rip),%rsi
call   1030 <strcaseeq@plt>
cmp    $0x0,%rax
je     1153 <check_chan+0x43>
movl   $0x1,-0x4(%rbp)
jmp    1248 <check_chan+0x138>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcaseeq@plt>
cmp    $0x0,%rax
je     1176 <check_chan+0x66>
movl   $0x1,-0x4(%rbp)
jmp    1248 <check_chan+0x138>
jmp    117b <check_chan+0x6b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1212 <check_chan+0x102>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    11e5 <check_chan+0xd5>
movslq -0x84(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcaseeq@plt>
cmp    $0x0,%rax
je     11ca <check_chan+0xba>
movl   $0x1,-0x4(%rbp)
jmp    1248 <check_chan+0x138>
movl   $0x0,-0x84(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    120d <check_chan+0xfd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x84(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x84(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
jmp    117b <check_chan+0x6b>
movslq -0x84(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcaseeq@plt>
cmp    $0x0,%rax
je     1241 <check_chan+0x131>
movl   $0x1,-0x4(%rbp)
jmp    1248 <check_chan+0x138>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_chan>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xed9(%rip),%rsi
call   1030 <strcaseeq@plt>
mov    $0x1,%r14d
test   %rax,%rax
jne    11a8 <check_chan+0x98>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcaseeq@plt>
test   %rax,%rax
jne    11a8 <check_chan+0x98>
xor    %ecx,%ecx
mov    %rsp,%r15
nopl   0x0(%rax)
movzbl 0x0(%rbp),%eax
cmp    $0x2c,%al
je     1170 <check_chan+0x60>
movslq %ecx,%rdx
test   %al,%al
je     118f <check_chan+0x7f>
add    $0x1,%ecx
mov    %al,(%rsp,%rdx,1)
add    $0x1,%rbp
jmp    1150 <check_chan+0x40>
nopl   0x0(%rax,%rax,1)
movslq %ecx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcaseeq@plt>
xor    %ecx,%ecx
test   %rax,%rax
jne    11a8 <check_chan+0x98>
add    $0x1,%rbp
jmp    1150 <check_chan+0x40>
movb   $0x0,(%rsp,%rdx,1)
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcaseeq@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
mov    %r14d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"all\00"
define i32 @check_chan(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [100 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = call i64 @strcaseeq(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %61
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = call i64 @strcaseeq(i8* %13, i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %3
br label %61
18: ; preds = %12
br label %19
19: ; preds = %50, %18
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %51
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 44
br i1 %28, label %29, label %42
29: ; preds = %24
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %31
store i8 0, i8* %32
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%34 = load i8*, i8** %5
%35 = call i64 @strcaseeq(i8* %33, i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %29
store i32 1, i32* %3
br label %61
38: ; preds = %29
store i32 0, i32* %7
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
br label %41
41: ; preds = %38
br label %50
42: ; preds = %24
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
%45 = load i8, i8* %43
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %48
store i8 %45, i8* %49
br label %50
50: ; preds = %42, %41
br label %19
51: ; preds = %19
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %53
store i8 0, i8* %54
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%56 = load i8*, i8** %5
%57 = call i64 @strcaseeq(i8* %55, i8* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %51
store i32 1, i32* %3
br label %61
60: ; preds = %51
store i32 0, i32* %3
br label %61
61: ; preds = %60, %59, %37, %17, %11
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [4 x i8] c"all\00"
define i32 @check_chan(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @strcaseeq(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %32
7: ; preds = %2
%8 = tail call i64 @strcaseeq(i8* %0, i8* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %7, %23
%11 = phi i8* [ %25, %23 ], [ %0, %7 ]
%12 = phi i32 [ %24, %23 ], [ 0, %7 ]
%13 = load i8, i8* %11
switch i8 %13, label %19 [
i8 0, label %26
i8 44, label %14
]
14: ; preds = %10
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i64 @strcaseeq(i8* %4, i8* %1)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %32
19: ; preds = %10
%20 = add nsw i32 %12, 1
%21 = sext i32 %12 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %21
store i8 %13, i8* %22
br label %23
23: ; preds = %14, %19
%24 = phi i32 [ %20, %19 ], [ 0, %14 ]
%25 = getelementptr inbounds i8, i8* %11, i64 1
br label %10
26: ; preds = %10
%27 = sext i32 %12 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i64 @strcaseeq(i8* %4, i8* %1)
%30 = icmp ne i64 %29, 0
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %14, %26, %7, %2
%33 = phi i32 [ 1, %2 ], [ 1, %7 ], [ %31, %26 ], [ 1, %14 ]
ret i32 %33
}