#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*/ STDERR_FILENO;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strnchr(char *, char, int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
void handle_msg_from_server(char *buf, int len) {
  char *p = NULL;
  char *p_head = NULL;
  int head_sz = 0;
  char *p_cmd = NULL;
  int cmd_sz = 0;
  int cur = 0;
  if (!buf || 0 >= len)
    return;
  if (':' == buf[0]) {
    p_head = &buf[1];
    p = strnchr(buf + cur, ' ', len - cur);
    if (!p) {
      p_head = NULL;
      head_sz = 0;
    err:
      fprintf(stderr, "error parse\n");
      write(STDERR_FILENO, buf, len);
      fprintf(stderr, "\n");
      return;
    }
    *p = '\0';
    head_sz = p - p_head;
    cur = p - buf + 1;
    p = strnchr(p_head, '!', head_sz);
    if (p) {
      *p = '\0';
    } else {
      p = strnchr(p_head, '@', head_sz);
    }
    if (p)
      p = '\0';
  }
  if (cur >= len)
    return;
  p_cmd = buf + cur;
  p = p_cmd;
  p = strnchr(p_cmd, ' ', len - cur);
  if (!p) {
    fprintf(stderr, "parse cmd error\n");
    goto err;
  }
  *p = '\0';
  cmd_sz = p - p_cmd;
  cur += cmd_sz + 1;
  int end_sz = 0;
  p = strnchr(buf + cur, '\r', len - cur);
  if (p) {
    *p = '\0';
    if ('\n' == *(p + 1)) {
      end_sz = p - buf + 2;
      *(p + 1) = '\0';
    } else
      end_sz = p - buf + 1;
  }
  if (0 == strncmp("PRIVMSG", p_cmd, cmd_sz) ||
      0 == strncmp("NOTICE", p_cmd, cmd_sz) ||
      0 == strncmp("001", p_cmd, cmd_sz)) {
    char *p_channel = NULL;
    int channel_sz = 0;
    p_channel = buf + cur;
    p = strnchr(p_channel, ' ', len - cur);
    if (!p) {
      p = strnchr(p_channel, '\0', len - cur);
    }
    if (!p) {
      fprintf(stderr, "parse channel error\n");
      goto err;
    }
    *p = '\0';
    channel_sz = p - p_channel;
    cur += channel_sz + 1;
    fprintf(stdout, "%s [%s]{%s} %s\n", p_cmd, p_channel, p_head, buf + cur);
  } else if (0 == strncmp("ERROR", p_cmd, cmd_sz) ||
             0 == strncmp("MODE", p_cmd, cmd_sz) ||
             0 == strncmp("332", p_cmd, cmd_sz)) {
    fprintf(stdout, "%s %s %s\n", p_head, p_cmd, buf + cur);
  }
  handle_msg_from_server(buf + end_sz, len - end_sz);
}


x86 assembly (clang, -O0):
<handle_msg_from_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11a2 <handle_msg_from_server+0x52>
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
jl     11a7 <handle_msg_from_server+0x57>
jmp    15af <handle_msg_from_server+0x45f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x3a,%eax
cmp    %ecx,%eax
jne    12c8 <handle_msg_from_server+0x178>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x38(%rbp),%rax
add    %rax,%rdi
mov    -0xc(%rbp),%edx
sub    -0x38(%rbp),%edx
mov    $0x20,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1248 <handle_msg_from_server+0xf8>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <write@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    15af <handle_msg_from_server+0x45f>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x21,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     129b <handle_msg_from_server+0x14b>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    12b0 <handle_msg_from_server+0x160>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x40,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12c3 <handle_msg_from_server+0x173>
movq   $0x0,-0x18(%rbp)
jmp    12c8 <handle_msg_from_server+0x178>
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     12d9 <handle_msg_from_server+0x189>
jmp    15af <handle_msg_from_server+0x45f>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    -0x38(%rbp),%edx
mov    $0x20,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    132f <handle_msg_from_server+0x1df>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1200 <handle_msg_from_server+0xb0>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x38(%rbp),%rax
add    %rax,%rdi
mov    -0xc(%rbp),%edx
sub    -0x38(%rbp),%edx
mov    $0xd,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     13d3 <handle_msg_from_server+0x283>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    13bc <handle_msg_from_server+0x26c>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x2,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    13ce <handle_msg_from_server+0x27e>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x3c(%rbp)
jmp    13d3 <handle_msg_from_server+0x283>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xc3d(%rip),%rdi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1436 <handle_msg_from_server+0x2e6>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xc24(%rip),%rdi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1436 <handle_msg_from_server+0x2e6>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xc0a(%rip),%rdi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1507 <handle_msg_from_server+0x3b7>
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    -0x38(%rbp),%edx
mov    $0x20,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    148c <handle_msg_from_server+0x33c>
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    -0x38(%rbp),%edx
xor    %esi,%esi
call   1050 <strnchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    14b3 <handle_msg_from_server+0x363>
mov    0x2b42(%rip),%rax
mov    (%rax),%edi
lea    0xb8a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1200 <handle_msg_from_server+0xb0>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2af5(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x8(%rbp),%r9
movslq -0x38(%rbp),%rax
add    %rax,%r9
lea    0xb4b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1599 <handle_msg_from_server+0x449>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xb41(%rip),%rdi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     156a <handle_msg_from_server+0x41a>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xb26(%rip),%rdi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     156a <handle_msg_from_server+0x41a>
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xb0a(%rip),%rdi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1594 <handle_msg_from_server+0x444>
mov    0x2a5f(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%r8
movslq -0x38(%rbp),%rax
add    %rax,%r8
lea    0xad8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1599 <handle_msg_from_server+0x449>
mov    -0x8(%rbp),%rdi
movslq -0x3c(%rbp),%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
sub    -0x3c(%rbp),%esi
call   1070 <handle_msg_from_server@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_msg_from_server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %rdi,%rdi
je     13c4 <handle_msg_from_server+0x284>
mov    %esi,%ebx
test   %esi,%esi
jle    13c4 <handle_msg_from_server+0x284>
mov    %rdi,%r14
jmp    11d2 <handle_msg_from_server+0x92>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1050 <strnchr@plt>
test   %rax,%rax
je     1240 <handle_msg_from_server+0x100>
movb   $0x0,(%rax)
sub    %r12d,%eax
mov    0x10(%rsp),%rcx
add    %ecx,%eax
add    $0x1,%eax
mov    0x2e31(%rip),%rcx
mov    (%rcx),%edi
movslq %eax,%r9
add    %r14,%r9
lea    0xe98(%rip),%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    0x8(%rsp),%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
movslq %ebx,%rax
add    %rax,%r14
mov    0x4(%rsp),%ebx
sub    %eax,%ebx
jle    13c4 <handle_msg_from_server+0x284>
cmpb   $0x3a,(%r14)
jne    1230 <handle_msg_from_server+0xf0>
mov    %r14,%rdi
mov    $0x20,%esi
mov    %ebx,%r15d
mov    %ebx,%edx
call   1050 <strnchr@plt>
test   %rax,%rax
je     13fa <handle_msg_from_server+0x2ba>
mov    %rax,%rbp
lea    0x1(%r14),%r12
movb   $0x0,(%rax)
mov    %ebp,%ebx
sub    %r12d,%ebx
sub    %r14d,%ebp
add    $0x1,%ebp
mov    %r12,%rdi
mov    $0x21,%esi
mov    %ebx,%edx
call   1050 <strnchr@plt>
test   %rax,%rax
je     125a <handle_msg_from_server+0x11a>
movb   $0x0,(%rax)
jmp    1269 <handle_msg_from_server+0x129>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    126c <handle_msg_from_server+0x12c>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <strnchr@plt>
test   %rax,%rax
jne    1188 <handle_msg_from_server+0x48>
jmp    13dc <handle_msg_from_server+0x29c>
mov    %r12,%rdi
mov    $0x40,%esi
mov    %ebx,%edx
call   1050 <strnchr@plt>
mov    %r15d,%ebx
mov    %ebx,%edx
sub    %ebp,%edx
jle    13c4 <handle_msg_from_server+0x284>
movslq %ebp,%r13
add    %r14,%r13
mov    %r13,%rdi
mov    $0x20,%esi
call   1050 <strnchr@plt>
test   %rax,%rax
je     13d3 <handle_msg_from_server+0x293>
mov    %rax,%r15
mov    %r12,0x8(%rsp)
movb   $0x0,(%rax)
sub    %r13d,%r15d
lea    (%r15,%rbp,1),%eax
add    $0x1,%eax
mov    %rax,0x10(%rsp)
cltq
lea    (%r14,%rax,1),%r12
mov    %ebx,%ebp
sub    %eax,%ebp
mov    %r12,%rdi
mov    $0xd,%esi
mov    %ebp,%edx
call   1050 <strnchr@plt>
test   %rax,%rax
mov    %ebx,0x4(%rsp)
je     12f0 <handle_msg_from_server+0x1b0>
movb   $0x0,(%rax)
mov    %eax,%ebx
sub    %r14d,%ebx
cmpb   $0xa,0x1(%rax)
jne    1300 <handle_msg_from_server+0x1c0>
add    $0x2,%ebx
movb   $0x0,0x1(%rax)
jmp    1303 <handle_msg_from_server+0x1c3>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
jmp    1303 <handle_msg_from_server+0x1c3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
lea    0xd14(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1170 <handle_msg_from_server+0x30>
lea    0xd01(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1170 <handle_msg_from_server+0x30>
lea    0xced(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1170 <handle_msg_from_server+0x30>
lea    0xcfb(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     139d <handle_msg_from_server+0x25d>
lea    0xcea(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     139d <handle_msg_from_server+0x25d>
lea    0xcd8(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11c0 <handle_msg_from_server+0x80>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
mov    0x8(%rsp),%rdx
mov    %r13,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11c0 <handle_msg_from_server+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc33(%rip),%rsi
jmp    13e7 <handle_msg_from_server+0x2a7>
lea    0xc4e(%rip),%rsi
mov    0x4(%rsp),%ebx
mov    %ebx,%r15d
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2bdf(%rip),%rbx
mov    (%rbx),%edi
lea    0xbf6(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    %r15d,%edx
call   1040 <write@plt>
mov    (%rbx),%edi
lea    0xbdd(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"error parse\0A\00"
@STDERR_FILENO = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"parse cmd error\0A\00"
@.str.3 = [8 x i8] c"PRIVMSG\00"
@.str.4 = [7 x i8] c"NOTICE\00"
@.str.5 = [4 x i8] c"001\00"
@.str.6 = [21 x i8] c"parse channel error\0A\00"
@stdout = global i32 0
@.str.7 = [16 x i8] c"%s [%s]{%s} %s\0A\00"
@.str.8 = [6 x i8] c"ERROR\00"
@.str.9 = [5 x i8] c"MODE\00"
@.str.10 = [4 x i8] c"332\00"
@.str.11 = [10 x i8] c"%s %s %s\0A\00"
define void @handle_msg_from_server(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* null, i8** %5
store i8* null, i8** %6
store i32 0, i32* %7
store i8* null, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp sge i32 0, %17
br i1 %18, label %19, label %20
19: ; preds = %16, %2
br label %242
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 58, %24
br i1 %25, label %26, label %80
26: ; preds = %20
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %6
%29 = load i8*, i8** %3
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i32, i32* %4
%34 = load i32, i32* %10
%35 = sub nsw i32 %33, %34
%36 = call i8* @strnchr(i8* %32, i8 signext 32, i32 %35)
store i8* %36, i8** %5
%37 = load i8*, i8** %5
%38 = icmp ne i8* %37, null
br i1 %38, label %49, label %39
39: ; preds = %26
store i8* null, i8** %6
store i32 0, i32* %7
br label %40
40: ; preds = %185, %98, %39
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%43 = load i32, i32* @STDERR_FILENO
%44 = load i8*, i8** %3
%45 = load i32, i32* %4
%46 = call i32 @write(i32 %43, i8* %44, i32 %45)
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %242
49: ; preds = %26
%50 = load i8*, i8** %5
store i8 0, i8* %50
%51 = load i8*, i8** %5
%52 = load i8*, i8** %6
%53 = ptrtoint i8* %51 to i64
%54 = ptrtoint i8* %52 to i64
%55 = sub i64 %53, %54
%56 = trunc i64 %55 to i32
store i32 %56, i32* %7
%57 = load i8*, i8** %5
%58 = load i8*, i8** %3
%59 = ptrtoint i8* %57 to i64
%60 = ptrtoint i8* %58 to i64
%61 = sub i64 %59, %60
%62 = add nsw i64 %61, 1
%63 = trunc i64 %62 to i32
store i32 %63, i32* %10
%64 = load i8*, i8** %6
%65 = load i32, i32* %7
%66 = call i8* @strnchr(i8* %64, i8 signext 33, i32 %65)
store i8* %66, i8** %5
%67 = load i8*, i8** %5
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %71
69: ; preds = %49
%70 = load i8*, i8** %5
store i8 0, i8* %70
br label %75
71: ; preds = %49
%72 = load i8*, i8** %6
%73 = load i32, i32* %7
%74 = call i8* @strnchr(i8* %72, i8 signext 64, i32 %73)
store i8* %74, i8** %5
br label %75
75: ; preds = %71, %69
%76 = load i8*, i8** %5
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %79
78: ; preds = %75
store i8* null, i8** %5
br label %79
79: ; preds = %78, %75
br label %80
80: ; preds = %79, %20
%81 = load i32, i32* %10
%82 = load i32, i32* %4
%83 = icmp sge i32 %81, %82
br i1 %83, label %84, label %85
84: ; preds = %80
br label %242
85: ; preds = %80
%86 = load i8*, i8** %3
%87 = load i32, i32* %10
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
store i8* %89, i8** %8
%90 = load i8*, i8** %8
store i8* %90, i8** %5
%91 = load i8*, i8** %8
%92 = load i32, i32* %4
%93 = load i32, i32* %10
%94 = sub nsw i32 %92, %93
%95 = call i8* @strnchr(i8* %91, i8 signext 32, i32 %94)
store i8* %95, i8** %5
%96 = load i8*, i8** %5
%97 = icmp ne i8* %96, null
br i1 %97, label %101, label %98
98: ; preds = %85
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %40
101: ; preds = %85
%102 = load i8*, i8** %5
store i8 0, i8* %102
%103 = load i8*, i8** %5
%104 = load i8*, i8** %8
%105 = ptrtoint i8* %103 to i64
%106 = ptrtoint i8* %104 to i64
%107 = sub i64 %105, %106
%108 = trunc i64 %107 to i32
store i32 %108, i32* %9
%109 = load i32, i32* %9
%110 = add nsw i32 %109, 1
%111 = load i32, i32* %10
%112 = add nsw i32 %111, %110
store i32 %112, i32* %10
store i32 0, i32* %11
%113 = load i8*, i8** %3
%114 = load i32, i32* %10
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = load i32, i32* %4
%118 = load i32, i32* %10
%119 = sub nsw i32 %117, %118
%120 = call i8* @strnchr(i8* %116, i8 signext 13, i32 %119)
store i8* %120, i8** %5
%121 = load i8*, i8** %5
%122 = icmp ne i8* %121, null
br i1 %122, label %123, label %149
123: ; preds = %101
%124 = load i8*, i8** %5
store i8 0, i8* %124
%125 = load i8*, i8** %5
%126 = getelementptr inbounds i8, i8* %125, i64 1
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp eq i32 10, %128
br i1 %129, label %130, label %140
130: ; preds = %123
%131 = load i8*, i8** %5
%132 = load i8*, i8** %3
%133 = ptrtoint i8* %131 to i64
%134 = ptrtoint i8* %132 to i64
%135 = sub i64 %133, %134
%136 = add nsw i64 %135, 2
%137 = trunc i64 %136 to i32
store i32 %137, i32* %11
%138 = load i8*, i8** %5
%139 = getelementptr inbounds i8, i8* %138, i64 1
store i8 0, i8* %139
br label %148
140: ; preds = %123
%141 = load i8*, i8** %5
%142 = load i8*, i8** %3
%143 = ptrtoint i8* %141 to i64
%144 = ptrtoint i8* %142 to i64
%145 = sub i64 %143, %144
%146 = add nsw i64 %145, 1
%147 = trunc i64 %146 to i32
store i32 %147, i32* %11
br label %148
148: ; preds = %140, %130
br label %149
149: ; preds = %148, %101
%150 = load i8*, i8** %8
%151 = load i32, i32* %9
%152 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %150, i32 %151)
%153 = icmp eq i64 0, %152
br i1 %153, label %164, label %154
154: ; preds = %149
%155 = load i8*, i8** %8
%156 = load i32, i32* %9
%157 = call i64 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %155, i32 %156)
%158 = icmp eq i64 0, %157
br i1 %158, label %164, label %159
159: ; preds = %154
%160 = load i8*, i8** %8
%161 = load i32, i32* %9
%162 = call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %160, i32 %161)
%163 = icmp eq i64 0, %162
br i1 %163, label %164, label %209
164: ; preds = %159, %154, %149
store i8* null, i8** %12
store i32 0, i32* %13
%165 = load i8*, i8** %3
%166 = load i32, i32* %10
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %165, i64 %167
store i8* %168, i8** %12
%169 = load i8*, i8** %12
%170 = load i32, i32* %4
%171 = load i32, i32* %10
%172 = sub nsw i32 %170, %171
%173 = call i8* @strnchr(i8* %169, i8 signext 32, i32 %172)
store i8* %173, i8** %5
%174 = load i8*, i8** %5
%175 = icmp ne i8* %174, null
br i1 %175, label %182, label %176
176: ; preds = %164
%177 = load i8*, i8** %12
%178 = load i32, i32* %4
%179 = load i32, i32* %10
%180 = sub nsw i32 %178, %179
%181 = call i8* @strnchr(i8* %177, i8 signext 0, i32 %180)
store i8* %181, i8** %5
br label %182
182: ; preds = %176, %164
%183 = load i8*, i8** %5
%184 = icmp ne i8* %183, null
br i1 %184, label %188, label %185
185: ; preds = %182
%186 = load i32, i32* @stderr
%187 = call i32 (i32, i8*, ...) @fprintf(i32 %186, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %40
188: ; preds = %182
%189 = load i8*, i8** %5
store i8 0, i8* %189
%190 = load i8*, i8** %5
%191 = load i8*, i8** %12
%192 = ptrtoint i8* %190 to i64
%193 = ptrtoint i8* %191 to i64
%194 = sub i64 %192, %193
%195 = trunc i64 %194 to i32
store i32 %195, i32* %13
%196 = load i32, i32* %13
%197 = add nsw i32 %196, 1
%198 = load i32, i32* %10
%199 = add nsw i32 %198, %197
store i32 %199, i32* %10
%200 = load i32, i32* @stdout
%201 = load i8*, i8** %8
%202 = load i8*, i8** %12
%203 = load i8*, i8** %6
%204 = load i8*, i8** %3
%205 = load i32, i32* %10
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i8, i8* %204, i64 %206
%208 = call i32 (i32, i8*, ...) @fprintf(i32 %200, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %201, i8* %202, i8* %203, i8* %207)
br label %234
209: ; preds = %159
%210 = load i8*, i8** %8
%211 = load i32, i32* %9
%212 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %210, i32 %211)
%213 = icmp eq i64 0, %212
br i1 %213, label %224, label %214
214: ; preds = %209
%215 = load i8*, i8** %8
%216 = load i32, i32* %9
%217 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %215, i32 %216)
%218 = icmp eq i64 0, %217
br i1 %218, label %224, label %219
219: ; preds = %214
%220 = load i8*, i8** %8
%221 = load i32, i32* %9
%222 = call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %220, i32 %221)
%223 = icmp eq i64 0, %222
br i1 %223, label %224, label %233
224: ; preds = %219, %214, %209
%225 = load i32, i32* @stdout
%226 = load i8*, i8** %6
%227 = load i8*, i8** %8
%228 = load i8*, i8** %3
%229 = load i32, i32* %10
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds i8, i8* %228, i64 %230
%232 = call i32 (i32, i8*, ...) @fprintf(i32 %225, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %226, i8* %227, i8* %231)
br label %233
233: ; preds = %224, %219
br label %234
234: ; preds = %233, %188
%235 = load i8*, i8** %3
%236 = load i32, i32* %11
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds i8, i8* %235, i64 %237
%239 = load i32, i32* %4
%240 = load i32, i32* %11
%241 = sub nsw i32 %239, %240
br label %242
242: ; preds = %234, %84, %40, %19
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [13 x i8] c"error parse\0A\00"
@STDERR_FILENO = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"parse cmd error\0A\00"
@.str.3 = [8 x i8] c"PRIVMSG\00"
@.str.4 = [7 x i8] c"NOTICE\00"
@.str.5 = [4 x i8] c"001\00"
@.str.6 = [21 x i8] c"parse channel error\0A\00"
@stdout = global i32 0
@.str.7 = [16 x i8] c"%s [%s]{%s} %s\0A\00"
@.str.8 = [6 x i8] c"ERROR\00"
@.str.9 = [5 x i8] c"MODE\00"
@.str.10 = [4 x i8] c"332\00"
@.str.11 = [10 x i8] c"%s %s %s\0A\00"
define void @handle_msg_from_server(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
br i1 %5, label %119, label %6
6: ; preds = %2, %114
%7 = phi i32 [ %117, %114 ], [ %1, %2 ]
%8 = phi i8* [ %116, %114 ], [ %0, %2 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 58
br i1 %10, label %11, label %40
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = tail call i8* @strnchr(i8* %8, i8 signext 32, i32 %7)
%14 = icmp eq i8* %13, null
br i1 %14, label %19, label %26
15: ; preds = %87, %44
%16 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %44 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), %87 ]
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* %16)
br label %19
19: ; preds = %11, %15
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @STDERR_FILENO
%23 = tail call i32 @write(i32 %22, i8* %8, i32 %7)
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %119
26: ; preds = %11
store i8 0, i8* %13
%27 = ptrtoint i8* %13 to i64
%28 = ptrtoint i8* %12 to i64
%29 = sub i64 %27, %28
%30 = trunc i64 %29 to i32
%31 = ptrtoint i8* %8 to i64
%32 = sub i64 %27, %31
%33 = trunc i64 %32 to i32
%34 = add i32 %33, 1
%35 = tail call i8* @strnchr(i8* %12, i8 signext 33, i32 %30)
%36 = icmp eq i8* %35, null
br i1 %36, label %38, label %37
37: ; preds = %26
store i8 0, i8* %35
br label %40
38: ; preds = %26
%39 = tail call i8* @strnchr(i8* %12, i8 signext 64, i32 %30)
br label %40
40: ; preds = %37, %38, %6
%41 = phi i8* [ null, %6 ], [ %12, %38 ], [ %12, %37 ]
%42 = phi i32 [ 0, %6 ], [ %34, %38 ], [ %34, %37 ]
%43 = icmp sgt i32 %7, %42
br i1 %43, label %44, label %119
44: ; preds = %40
%45 = sext i32 %42 to i64
%46 = getelementptr inbounds i8, i8* %8, i64 %45
%47 = sub nsw i32 %7, %42
%48 = tail call i8* @strnchr(i8* %46, i8 signext 32, i32 %47)
%49 = icmp eq i8* %48, null
br i1 %49, label %15, label %50
50: ; preds = %44
store i8 0, i8* %48
%51 = ptrtoint i8* %48 to i64
%52 = ptrtoint i8* %46 to i64
%53 = sub i64 %51, %52
%54 = trunc i64 %53 to i32
%55 = add nsw i32 %42, 1
%56 = add i32 %55, %54
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %8, i64 %57
%59 = sub nsw i32 %7, %56
%60 = tail call i8* @strnchr(i8* %58, i8 signext 13, i32 %59)
%61 = icmp eq i8* %60, null
br i1 %61, label %74, label %62
62: ; preds = %50
store i8 0, i8* %60
%63 = getelementptr inbounds i8, i8* %60, i64 1
%64 = load i8, i8* %63
%65 = icmp eq i8 %64, 10
%66 = ptrtoint i8* %60 to i64
%67 = ptrtoint i8* %8 to i64
%68 = sub i64 %66, %67
%69 = trunc i64 %68 to i32
br i1 %65, label %70, label %72
70: ; preds = %62
%71 = add i32 %69, 2
store i8 0, i8* %63
br label %74
72: ; preds = %62
%73 = add i32 %69, 1
br label %74
74: ; preds = %70, %72, %50
%75 = phi i32 [ %71, %70 ], [ %73, %72 ], [ 0, %50 ]
%76 = tail call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %46, i32 %54)
%77 = icmp eq i64 %76, 0
br i1 %77, label %84, label %78
78: ; preds = %74
%79 = tail call i64 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %46, i32 %54)
%80 = icmp eq i64 %79, 0
br i1 %80, label %84, label %81
81: ; preds = %78
%82 = tail call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %46, i32 %54)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %102
84: ; preds = %81, %78, %74
%85 = tail call i8* @strnchr(i8* %58, i8 signext 32, i32 %59)
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = tail call i8* @strnchr(i8* %58, i8 signext 0, i32 %59)
%89 = icmp eq i8* %88, null
br i1 %89, label %15, label %90
90: ; preds = %87, %84
%91 = phi i8* [ %88, %87 ], [ %85, %84 ]
store i8 0, i8* %91
%92 = ptrtoint i8* %91 to i64
%93 = ptrtoint i8* %58 to i64
%94 = sub i64 %92, %93
%95 = trunc i64 %94 to i32
%96 = add i32 %56, 1
%97 = add i32 %96, %95
%98 = load i32, i32* @stdout
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %8, i64 %99
%101 = tail call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %46, i8* %58, i8* %41, i8* %100)
br label %114
102: ; preds = %81
%103 = tail call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %46, i32 %54)
%104 = icmp eq i64 %103, 0
br i1 %104, label %111, label %105
105: ; preds = %102
%106 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %46, i32 %54)
%107 = icmp eq i64 %106, 0
br i1 %107, label %111, label %108
108: ; preds = %105
%109 = tail call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %46, i32 %54)
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %108, %105, %102
%112 = load i32, i32* @stdout
%113 = tail call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %41, i8* %46, i8* %58)
br label %114
114: ; preds = %90, %108, %111
%115 = sext i32 %75 to i64
%116 = getelementptr inbounds i8, i8* %8, i64 %115
%117 = sub nsw i32 %7, %75
%118 = icmp slt i32 %117, 1
br i1 %118, label %119, label %6
119: ; preds = %114, %40, %2, %19
ret void
}