#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 chanset_t {
  int dummy;
};

/* Variables and functions */
scalar_t__ channel_active(struct chanset_t *);
scalar_t__ channel_pending(struct chanset_t *);
struct chanset_t *findchan(char *);
int /*<<< orphan*/ newban(struct chanset_t *, char *, char *);
char *newsplit(char **);
int /*<<< orphan*/ strncpy(char *, char *, int);
int got367(char *from, char *origmsg) {
  char *ban, *who, *chname, buf[511], *msg;
  struct chanset_t *chan;
  strncpy(buf, origmsg, 510);
  buf[510] = 0;
  msg = buf;
  newsplit(&msg);
  chname = newsplit(&msg);
  chan = findchan(chname);
  if (!chan || !(channel_pending(chan) || channel_active(chan)))
    return 0;
  ban = newsplit(&msg);
  who = newsplit(&msg);
  if (who[0])
    newban(chan, ban, who);
  else
    newban(chan, ban, "existent");
  return 0;
}


x86 assembly (clang, -O0):
<got367>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1fe,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x32(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    -0x238(%rbp),%rdi
call   1080 <newsplit@plt>
lea    -0x238(%rbp),%rdi
call   1080 <newsplit@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <findchan@plt>
mov    %rax,-0x240(%rbp)
cmpq   $0x0,-0x240(%rbp)
je     1200 <got367+0xa0>
mov    -0x240(%rbp),%rdi
call   1040 <channel_pending@plt>
cmp    $0x0,%rax
jne    120c <got367+0xac>
mov    -0x240(%rbp),%rdi
call   1050 <channel_active@plt>
cmp    $0x0,%rax
jne    120c <got367+0xac>
movl   $0x0,-0x4(%rbp)
jmp    1270 <got367+0x110>
lea    -0x238(%rbp),%rdi
call   1080 <newsplit@plt>
mov    %rax,-0x20(%rbp)
lea    -0x238(%rbp),%rdi
call   1080 <newsplit@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1252 <got367+0xf2>
mov    -0x240(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <newban@plt>
jmp    1269 <got367+0x109>
mov    -0x240(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xd9c(%rip),%rdx
call   1070 <newban@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<got367>:
push   %r15
push   %r14
push   %rbx
sub    $0x210,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1fe,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x20e(%rsp)
mov    %rbx,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <newsplit@plt>
mov    %rbx,%rdi
call   1080 <newsplit@plt>
mov    %rax,%rdi
call   1060 <findchan@plt>
test   %rax,%rax
je     1204 <got367+0xa4>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <channel_pending@plt>
test   %rax,%rax
jne    11ca <got367+0x6a>
mov    %rbx,%rdi
call   1050 <channel_active@plt>
test   %rax,%rax
je     1204 <got367+0xa4>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1080 <newsplit@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1080 <newsplit@plt>
cmpb   $0x0,(%rax)
je     11f2 <got367+0x92>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
jmp    11ff <got367+0x9f>
lea    0xe07(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <newban@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.chanset_t = type { i32 }
@.str = [9 x i8] c"existent\00"
define i32 @got367(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [511 x i8]
%10 = alloca i8*
%11 = alloca %struct.chanset_t*
store i8* %0, i8** %4
store i8* %1, i8** %5
%12 = getelementptr inbounds [511 x i8], [511 x i8]* %9, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 510)
%15 = getelementptr inbounds [511 x i8], [511 x i8]* %9, i64 0, i64 510
store i8 0, i8* %15
%16 = getelementptr inbounds [511 x i8], [511 x i8]* %9, i64 0, i64 0
store i8* %16, i8** %10
%17 = call i8* @newsplit(i8** %10)
%18 = call i8* @newsplit(i8** %10)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = call %struct.chanset_t* @findchan(i8* %19)
store %struct.chanset_t* %20, %struct.chanset_t** %11
%21 = load %struct.chanset_t*, %struct.chanset_t** %11
%22 = icmp ne %struct.chanset_t* %21, null
br i1 %22, label %23, label %31
23: ; preds = %2
%24 = load %struct.chanset_t*, %struct.chanset_t** %11
%25 = call i64 @channel_pending(%struct.chanset_t* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %23
%28 = load %struct.chanset_t*, %struct.chanset_t** %11
%29 = call i64 @channel_active(%struct.chanset_t* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %27, %2
store i32 0, i32* %3
br label %49
32: ; preds = %27, %23
%33 = call i8* @newsplit(i8** %10)
store i8* %33, i8** %6
%34 = call i8* @newsplit(i8** %10)
store i8* %34, i8** %7
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %32
%40 = load %struct.chanset_t*, %struct.chanset_t** %11
%41 = load i8*, i8** %6
%42 = load i8*, i8** %7
%43 = call i32 @newban(%struct.chanset_t* %40, i8* %41, i8* %42)
br label %48
44: ; preds = %32
%45 = load %struct.chanset_t*, %struct.chanset_t** %11
%46 = load i8*, i8** %6
%47 = call i32 @newban(%struct.chanset_t* %45, i8* %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %48
48: ; preds = %44, %39
store i32 0, i32* %3
br label %49
49: ; preds = %48, %31
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.chanset_t = type { i32 }
@.str = [9 x i8] c"existent\00"
define i32 @got367(i8* nocapture readnone %0, i8* %1) {
%3 = alloca [511 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [511 x i8], [511 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = call i32 @strncpy(i8* %5, i8* %1, i32 510)
%8 = getelementptr inbounds [511 x i8], [511 x i8]* %3, i64 0, i64 510
store i8 0, i8* %8
store i8* %5, i8** %4
%9 = call i8* @newsplit(i8** %4)
%10 = call i8* @newsplit(i8** %4)
%11 = call %struct.chanset_t* @findchan(i8* %10)
%12 = icmp eq %struct.chanset_t* %11, null
br i1 %12, label %28, label %13
13: ; preds = %2
%14 = call i64 @channel_pending(%struct.chanset_t* %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i64 @channel_active(%struct.chanset_t* %11)
%18 = icmp eq i64 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %16, %13
%20 = call i8* @newsplit(i8** %4)
%21 = call i8* @newsplit(i8** %4)
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = call i32 @newban(%struct.chanset_t* %11, i8* %20, i8* %21)
br label %28
26: ; preds = %19
%27 = call i32 @newban(%struct.chanset_t* %11, i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %24, %26, %2, %16
ret i32 0
}