#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;
};

/* Variables and functions */
int /*<<< orphan*/ irc_mode_user_add(struct t_irc_server *, char const);
int /*<<< orphan*/ irc_mode_user_remove(struct t_irc_server *, char const);
void irc_mode_user_set(struct t_irc_server *server, const char *modes) {
  char set_flag;
  set_flag = '+';
  while (modes && modes[0]) {
    switch (modes[0]) {
    case ':':
    case ' ':
      break;
    case '+':
      set_flag = '+';
      break;
    case '-':
      set_flag = '-';
      break;
    default:
      if (set_flag == '+')
        irc_mode_user_add(server, modes[0]);
      else
        irc_mode_user_remove(server, modes[0]);
      break;
    }
    modes++;
  }
}


x86 assembly (clang, -O0):
<irc_mode_user_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x2b,-0x11(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x12(%rbp)
je     1154 <irc_mode_user_set+0x34>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1164 <irc_mode_user_set+0x44>
jmp    11f0 <irc_mode_user_set+0xd0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1a,%eax
ja     11a8 <irc_mode_user_set+0x88>
mov    -0x20(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11df <irc_mode_user_set+0xbf>
movb   $0x2b,-0x11(%rbp)
jmp    11df <irc_mode_user_set+0xbf>
movb   $0x2d,-0x11(%rbp)
jmp    11df <irc_mode_user_set+0xbf>
movsbl -0x11(%rbp),%eax
cmp    $0x2b,%eax
jne    11ca <irc_mode_user_set+0xaa>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <irc_mode_user_add@plt>
jmp    11da <irc_mode_user_set+0xba>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1040 <irc_mode_user_remove@plt>
jmp    11df <irc_mode_user_set+0xbf>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <irc_mode_user_set+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_mode_user_set>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     11aa <irc_mode_user_set+0x8a>
mov    %rsi,%rbx
mov    (%rsi),%al
test   %al,%al
je     11aa <irc_mode_user_set+0x8a>
mov    %rdi,%r14
add    $0x1,%rbx
mov    $0x2b,%bpl
lea    0xeba(%rip),%r15
jmp    116b <irc_mode_user_set+0x4b>
nopl   0x0(%rax,%rax,1)
mov    $0x2d,%bpl
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11aa <irc_mode_user_set+0x8a>
movsbl %al,%esi
lea    -0x20(%rsi),%eax
cmp    $0x1a,%eax
ja     1190 <irc_mode_user_set+0x70>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x2b,%bpl
jmp    1160 <irc_mode_user_set+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
cmp    $0x2b,%bpl
jne    11a3 <irc_mode_user_set+0x83>
call   1030 <irc_mode_user_add@plt>
mov    $0x2b,%bpl
jmp    1160 <irc_mode_user_set+0x40>
call   1040 <irc_mode_user_remove@plt>
jmp    1160 <irc_mode_user_set+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.t_irc_server = type { i32 }
define void @irc_mode_user_set(%struct.t_irc_server* %0, i8* %1) {
%3 = alloca %struct.t_irc_server*
%4 = alloca i8*
%5 = alloca i8
store %struct.t_irc_server* %0, %struct.t_irc_server** %3
store i8* %1, i8** %4
store i8 43, i8* %5
br label %6
6: ; preds = %42, %2
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br label %15
15: ; preds = %9, %6
%16 = phi i1 [ false, %6 ], [ %14, %9 ]
br i1 %16, label %17, label %45
17: ; preds = %15
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %25 [
i32 58, label %22
i32 32, label %22
i32 43, label %23
i32 45, label %24
]
22: ; preds = %17, %17
br label %42
23: ; preds = %17
store i8 43, i8* %5
br label %42
24: ; preds = %17
store i8 45, i8* %5
br label %42
25: ; preds = %17
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 43
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load %struct.t_irc_server*, %struct.t_irc_server** %3
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = call i32 @irc_mode_user_add(%struct.t_irc_server* %30, i8 signext %33)
br label %41
35: ; preds = %25
%36 = load %struct.t_irc_server*, %struct.t_irc_server** %3
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = call i32 @irc_mode_user_remove(%struct.t_irc_server* %36, i8 signext %39)
br label %41
41: ; preds = %35, %29
br label %42
42: ; preds = %41, %24, %23, %22
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
br label %6
45: ; preds = %15
ret void
}

LLVM IR (-O2):
%struct.t_irc_server = type { i32 }
define void @irc_mode_user_set(%struct.t_irc_server* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %4, %20
%8 = phi i8 [ %23, %20 ], [ %5, %4 ]
%9 = phi i8* [ %22, %20 ], [ %1, %4 ]
%10 = phi i8 [ %21, %20 ], [ 43, %4 ]
%11 = sext i8 %8 to i32
switch i32 %11, label %14 [
i32 58, label %20
i32 32, label %20
i32 43, label %12
i32 45, label %13
]
12: ; preds = %7
br label %20
13: ; preds = %7
br label %20
14: ; preds = %7
%15 = icmp eq i8 %10, 43
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @irc_mode_user_add(%struct.t_irc_server* %0, i8 signext %8)
br label %20
18: ; preds = %14
%19 = tail call i32 @irc_mode_user_remove(%struct.t_irc_server* %0, i8 signext %8)
br label %20
20: ; preds = %16, %18, %7, %7, %13, %12
%21 = phi i8 [ 43, %16 ], [ %10, %18 ], [ 45, %13 ], [ 43, %12 ], [ %10, %7 ], [ %10, %7 ]
%22 = getelementptr inbounds i8, i8* %9, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %7
25: ; preds = %20, %4, %2
ret void
}