#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 */
scalar_t__ strlen(char *);
char *strsep(char **, char const *);
int irc_split_source(char *source, char **nick, char **user, char **host) {
  const char *delim = "!@";
  char *token = NULL;
  int i = -1;
  *nick = *user = *host = NULL;
  while ((token = strsep(&source, delim)) && (i < 3)) {
    if (strlen(token) == 0)
      continue;
    i++;
    switch (i) {
    case 0:
      *nick = token;
      break;
    case 1:
      *user = token;
      break;
    case 2:
      *host = token;
      break;
    }
  }
  return (i < 0 ? -1 : 0);
}


x86 assembly (clang, -O0):
<irc_split_source>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
call   1040 <strsep@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x35(%rbp)
je     11a0 <irc_split_source+0x80>
cmpl   $0x3,-0x34(%rbp)
setl   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    11b0 <irc_split_source+0x90>
jmp    1236 <irc_split_source+0x116>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11c8 <irc_split_source+0xa8>
jmp    1173 <irc_split_source+0x53>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
test   %eax,%eax
je     1206 <irc_split_source+0xe6>
jmp    11e4 <irc_split_source+0xc4>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
je     1216 <irc_split_source+0xf6>
jmp    11f5 <irc_split_source+0xd5>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     1226 <irc_split_source+0x106>
jmp    1231 <irc_split_source+0x111>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1231 <irc_split_source+0x111>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1231 <irc_split_source+0x111>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1173 <irc_split_source+0x53>
mov    -0x34(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_split_source>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,(%rsp)
movq   $0x0,(%rcx)
movq   $0x0,(%rdx)
movq   $0x0,(%rsi)
mov    $0xffffffff,%ebp
lea    0xeb7(%rip),%r13
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strsep@plt>
test   %rax,%rax
je     118f <irc_split_source+0x7f>
cmp    $0x2,%ebp
jg     118f <irc_split_source+0x7f>
cmpb   $0x0,(%rax)
je     1150 <irc_split_source+0x40>
lea    0x1(%rbp),%ecx
mov    %r12,%rdx
cmp    $0xffffffff,%ebp
je     1188 <irc_split_source+0x78>
cmp    $0x1,%ebp
je     1185 <irc_split_source+0x75>
mov    %r15,%rdx
test   %ebp,%ebp
mov    %ecx,%ebp
jne    1150 <irc_split_source+0x40>
jmp    1188 <irc_split_source+0x78>
mov    %r14,%rdx
mov    %rax,(%rdx)
mov    %ecx,%ebp
jmp    1150 <irc_split_source+0x40>
sar    $0x1f,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"!@\00"
define i32 @irc_split_source(i8* %0, i8** %1, i8** %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* null, i8** %10
store i32 -1, i32* %11
%12 = load i8**, i8*** %8
store i8* null, i8** %12
%13 = load i8**, i8*** %7
store i8* null, i8** %13
%14 = load i8**, i8*** %6
store i8* null, i8** %14
br label %15
15: ; preds = %42, %28, %4
%16 = load i8*, i8** %9
%17 = call i8* @strsep(i8** %5, i8* %16)
store i8* %17, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %11
%21 = icmp slt i32 %20, 3
br label %22
22: ; preds = %19, %15
%23 = phi i1 [ false, %15 ], [ %21, %19 ]
br i1 %23, label %24, label %43
24: ; preds = %22
%25 = load i8*, i8** %10
%26 = call i64 @strlen(i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
br label %15
29: ; preds = %24
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
%32 = load i32, i32* %11
switch i32 %32, label %42 [
i32 0, label %33
i32 1, label %36
i32 2, label %39
]
33: ; preds = %29
%34 = load i8*, i8** %10
%35 = load i8**, i8*** %6
store i8* %34, i8** %35
br label %42
36: ; preds = %29
%37 = load i8*, i8** %10
%38 = load i8**, i8*** %7
store i8* %37, i8** %38
br label %42
39: ; preds = %29
%40 = load i8*, i8** %10
%41 = load i8**, i8*** %8
store i8* %40, i8** %41
br label %42
42: ; preds = %29, %39, %36, %33
br label %15
43: ; preds = %22
%44 = load i32, i32* %11
%45 = icmp slt i32 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i32 -1, i32 0
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"!@\00"
define i32 @irc_split_source(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = alloca i8*
store i8* %0, i8** %5
store i8* null, i8** %3
store i8* null, i8** %2
store i8* null, i8** %1
br label %6
6: ; preds = %22, %4
%7 = phi i32 [ -1, %4 ], [ %17, %22 ]
%8 = icmp slt i32 %7, 3
br label %9
9: ; preds = %6, %13
%10 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i8* %10, null
%12 = select i1 %11, i1 %8, i1 false
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i8, i8* %10
%15 = icmp eq i8 %14, 0
br i1 %15, label %9, label %16
16: ; preds = %13
%17 = add nsw i32 %7, 1
switch i32 %7, label %22 [
i32 -1, label %20
i32 0, label %18
i32 1, label %19
]
18: ; preds = %16
br label %20
19: ; preds = %16
br label %20
20: ; preds = %16, %18, %19
%21 = phi i8** [ %3, %19 ], [ %2, %18 ], [ %1, %16 ]
store i8* %10, i8** %21
br label %22
22: ; preds = %20, %16
br label %6
23: ; preds = %9
%24 = ashr i32 %7, 31
ret i32 %24
}