#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 t_irc_server {
  int dummy;
};
struct t_irc_nick {
  int dummy;
};
struct t_irc_channel {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
struct t_irc_channel *irc_channel_search(struct t_irc_server *, char const *);
char *irc_nick_default_ban_mask(struct t_irc_nick *);
struct t_irc_nick *irc_nick_search(struct t_irc_server *,
                                   struct t_irc_channel *, char const *);
int /*<<< orphan*/ irc_server_sendf(struct t_irc_server *, int,
                                    int /*<<< orphan*/ *, char *, char const *,
                                    char const *, char *);
int /*<<< orphan*/ strchr(char const *, char);
void irc_command_send_ban(struct t_irc_server *server, const char *channel_name,
                          const char *mode, const char *nick) {
  struct t_irc_channel *ptr_channel;
  struct t_irc_nick *ptr_nick;
  char *mask;
  mask = NULL;
  if (!strchr(nick, '!') && !strchr(nick, '@')) {
    ptr_channel = irc_channel_search(server, channel_name);
    if (ptr_channel) {
      ptr_nick = irc_nick_search(server, ptr_channel, nick);
      if (ptr_nick)
        mask = irc_nick_default_ban_mask(ptr_nick);
    }
  }
  irc_server_sendf(server, 1, NULL, "MODE %s %s %s", channel_name, mode,
                   (mask) ? mask : nick);
  if (mask)
    free(mask);
}


x86 assembly (clang, -O0):
<irc_command_send_ban>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x21,%esi
call   1060 <strchr@plt>
cmp    $0x0,%eax
jne    1201 <irc_command_send_ban+0xa1>
mov    -0x20(%rbp),%rdi
mov    $0x40,%esi
call   1060 <strchr@plt>
cmp    $0x0,%eax
jne    1201 <irc_command_send_ban+0xa1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <irc_channel_search@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fc <irc_command_send_ban+0x9c>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1080 <irc_nick_search@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11f7 <irc_command_send_ban+0x97>
mov    -0x30(%rbp),%rdi
call   1050 <irc_nick_default_ban_mask@plt>
mov    %rax,-0x38(%rbp)
jmp    11fc <irc_command_send_ban+0x9c>
jmp    1201 <irc_command_send_ban+0xa1>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1231 <irc_command_send_ban+0xd1>
mov    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
jmp    1239 <irc_command_send_ban+0xd9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%r9
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
lea    0xda7(%rip),%rcx
mov    %rax,(%rsp)
call   1040 <irc_server_sendf@plt>
cmpq   $0x0,-0x38(%rbp)
je     1276 <irc_command_send_ban+0x116>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_command_send_ban>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rcx,%rdi
mov    $0x21,%esi
call   1060 <strchr@plt>
test   %eax,%eax
jne    119b <irc_command_send_ban+0x3b>
mov    %rbx,%rdi
mov    $0x40,%esi
call   1060 <strchr@plt>
test   %eax,%eax
je     11c9 <irc_command_send_ban+0x69>
mov    %rbx,(%rsp)
lea    0xe5a(%rip),%rcx
mov    %r12,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    %r15,%r8
mov    %r14,%r9
call   1040 <irc_server_sendf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <irc_channel_search@plt>
test   %rax,%rax
je     119b <irc_command_send_ban+0x3b>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1080 <irc_nick_search@plt>
test   %rax,%rax
je     119b <irc_command_send_ban+0x3b>
mov    %rax,%rdi
call   1050 <irc_nick_default_ban_mask@plt>
mov    %rax,%r13
test   %rax,%rax
cmovne %rax,%rbx
mov    %rbx,(%rsp)
lea    0xdf7(%rip),%rcx
mov    %r12,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    %r15,%r8
mov    %r14,%r9
call   1040 <irc_server_sendf@plt>
test   %r13,%r13
je     11bb <irc_command_send_ban+0x5b>
mov    %r13,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.t_irc_server = type { i32 }
%struct.t_irc_channel = type { i32 }
%struct.t_irc_nick = type { i32 }
@.str = [14 x i8] c"MODE %s %s %s\00"
define void @irc_command_send_ban(%struct.t_irc_server* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca %struct.t_irc_server*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.t_irc_channel*
%10 = alloca %struct.t_irc_nick*
%11 = alloca i8*
store %struct.t_irc_server* %0, %struct.t_irc_server** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i8* null, i8** %11
%12 = load i8*, i8** %8
%13 = call i32 @strchr(i8* %12, i8 signext 33)
%14 = icmp ne i32 %13, 0
br i1 %14, label %37, label %15
15: ; preds = %4
%16 = load i8*, i8** %8
%17 = call i32 @strchr(i8* %16, i8 signext 64)
%18 = icmp ne i32 %17, 0
br i1 %18, label %37, label %19
19: ; preds = %15
%20 = load %struct.t_irc_server*, %struct.t_irc_server** %5
%21 = load i8*, i8** %6
%22 = call %struct.t_irc_channel* @irc_channel_search(%struct.t_irc_server* %20, i8* %21)
store %struct.t_irc_channel* %22, %struct.t_irc_channel** %9
%23 = load %struct.t_irc_channel*, %struct.t_irc_channel** %9
%24 = icmp ne %struct.t_irc_channel* %23, null
br i1 %24, label %25, label %36
25: ; preds = %19
%26 = load %struct.t_irc_server*, %struct.t_irc_server** %5
%27 = load %struct.t_irc_channel*, %struct.t_irc_channel** %9
%28 = load i8*, i8** %8
%29 = call %struct.t_irc_nick* @irc_nick_search(%struct.t_irc_server* %26, %struct.t_irc_channel* %27, i8* %28)
store %struct.t_irc_nick* %29, %struct.t_irc_nick** %10
%30 = load %struct.t_irc_nick*, %struct.t_irc_nick** %10
%31 = icmp ne %struct.t_irc_nick* %30, null
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = load %struct.t_irc_nick*, %struct.t_irc_nick** %10
%34 = call i8* @irc_nick_default_ban_mask(%struct.t_irc_nick* %33)
store i8* %34, i8** %11
br label %35
35: ; preds = %32, %25
br label %36
36: ; preds = %35, %19
br label %37
37: ; preds = %36, %15, %4
%38 = load %struct.t_irc_server*, %struct.t_irc_server** %5
%39 = load i8*, i8** %6
%40 = load i8*, i8** %7
%41 = load i8*, i8** %11
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = load i8*, i8** %11
br label %47
45: ; preds = %37
%46 = load i8*, i8** %8
br label %47
47: ; preds = %45, %43
%48 = phi i8* [ %44, %43 ], [ %46, %45 ]
%49 = call i32 @irc_server_sendf(%struct.t_irc_server* %38, i32 1, i32* null, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %39, i8* %40, i8* %48)
%50 = load i8*, i8** %11
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = load i8*, i8** %11
%54 = call i32 @free(i8* %53)
br label %55
55: ; preds = %52, %47
ret void
}

LLVM IR (-O2):
%struct.t_irc_server = type { i32 }
%struct.t_irc_channel = type { i32 }
%struct.t_irc_nick = type { i32 }
@.str = [14 x i8] c"MODE %s %s %s\00"
define void @irc_command_send_ban(%struct.t_irc_server* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @strchr(i8* %3, i8 signext 33)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = tail call i32 @strchr(i8* %3, i8 signext 64)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = tail call %struct.t_irc_channel* @irc_channel_search(%struct.t_irc_server* %0, i8* %1)
%12 = icmp eq %struct.t_irc_channel* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call %struct.t_irc_nick* @irc_nick_search(%struct.t_irc_server* %0, %struct.t_irc_channel* %11, i8* %3)
%15 = icmp eq %struct.t_irc_nick* %14, null
br i1 %15, label %16, label %18
16: ; preds = %4, %7, %13, %10
%17 = tail call i32 @irc_server_sendf(%struct.t_irc_server* %0, i32 1, i32* null, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %3)
br label %25
18: ; preds = %13
%19 = tail call i8* @irc_nick_default_ban_mask(%struct.t_irc_nick* %14)
%20 = icmp eq i8* %19, null
%21 = select i1 %20, i8* %3, i8* %19
%22 = tail call i32 @irc_server_sendf(%struct.t_irc_server* %0, i32 1, i32* null, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %21)
br i1 %20, label %25, label %23
23: ; preds = %18
%24 = tail call i32 @free(i8* %19)
br label %25
25: ; preds = %16, %23, %18
ret void
}