#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 atoi(char *);
char *strchr(char *, char);
void ircproto_parse_message(char *msg, char **prefix, char **cmd, int *ncmd,
                            char **params) {
  char *spc;
  if (*msg == ':') {
    spc = strchr(msg, ' ');
    *spc = '\0';
    *prefix = msg + 1;
    msg = spc + 1;
  } else {
    prefix = NULL;
  }
  spc = strchr(msg, ' ');
  *spc = '\0';
  *cmd = msg;
  *ncmd = atoi(msg);
  msg = spc + 1;
  *params = msg;
}


x86 assembly (clang, -O0):
<ircproto_parse_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1185 <ircproto_parse_message+0x65>
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    118d <ircproto_parse_message+0x6d>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ircproto_parse_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rdi,%rbp
cmpb   $0x3a,(%rdi)
jne    115e <ircproto_parse_message+0x3e>
mov    %rsi,%r13
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
add    $0x1,%rbp
mov    %rbp,0x0(%r13)
add    $0x1,%rax
mov    %rax,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rbp,(%r12)
mov    %rbp,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r15)
add    $0x1,%rbx
mov    %rbx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ircproto_parse_message(i8* %0, i8** %1, i8** %2, i32* %3, i8** %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8**
%11 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
store i8** %4, i8*** %10
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 58
br i1 %15, label %16, label %25
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = call i8* @strchr(i8* %17, i8 signext 32)
store i8* %18, i8** %11
%19 = load i8*, i8** %11
store i8 0, i8* %19
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8**, i8*** %7
store i8* %21, i8** %22
%23 = load i8*, i8** %11
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %24, i8** %6
br label %26
25: ; preds = %5
store i8** null, i8*** %7
br label %26
26: ; preds = %25, %16
%27 = load i8*, i8** %6
%28 = call i8* @strchr(i8* %27, i8 signext 32)
store i8* %28, i8** %11
%29 = load i8*, i8** %11
store i8 0, i8* %29
%30 = load i8*, i8** %6
%31 = load i8**, i8*** %8
store i8* %30, i8** %31
%32 = load i8*, i8** %6
%33 = call i32 @atoi(i8* %32)
%34 = load i32*, i32** %9
store i32 %33, i32* %34
%35 = load i8*, i8** %11
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %10
store i8* %37, i8** %38
ret void
}

LLVM IR (-O2):
define void @ircproto_parse_message(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i32* nocapture writeonly %3, i8** nocapture writeonly %4) {
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 58
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i8* @strchr(i8* %0, i8 signext 32)
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %10, i8** %1
%11 = getelementptr inbounds i8, i8* %9, i64 1
br label %12
12: ; preds = %5, %8
%13 = phi i8* [ %11, %8 ], [ %0, %5 ]
%14 = tail call i8* @strchr(i8* %13, i8 signext 32)
store i8 0, i8* %14
store i8* %13, i8** %2
%15 = tail call i32 @atoi(i8* %13)
store i32 %15, i32* %3
%16 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %16, i8** %4
ret void
}