#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 strcspn(char *, char const *);
int strspn(char *, char const *);
int split_resource_name(char *resname, char **catptr, char **resptr) {
  const char *space = " \t\n";
  char *category = resname + strspn(resname, space);
  int catlen = strcspn(category, space);
  char *separator = category + catlen;
  char *resource = separator + strspn(separator, space);
  int reslen = strcspn(resource, space);
  if (!catlen || !reslen)
    return -1;
  *catptr = category;
  *resptr = resource;
  category[catlen] = '\0';
  resource[reslen] = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<split_resource_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strspn@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcspn@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strspn@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcspn@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11cc <split_resource_name+0xac>
cmpl   $0x0,-0x4c(%rbp)
jne    11d8 <split_resource_name+0xb8>
movl   $0xffffffff,-0x4(%rbp)
jmp    120d <split_resource_name+0xed>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_resource_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xec4(%rip),%rbp
mov    %rbp,%rsi
call   1030 <strspn@plt>
movslq %eax,%r13
add    %rbx,%r13
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <strcspn@plt>
movslq %eax,%r14
lea    (%r14,%r13,1),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <strspn@plt>
movslq %eax,%rbx
add    %r12,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcspn@plt>
mov    $0xffffffff,%ecx
test   %r14d,%r14d
je     119d <split_resource_name+0x7d>
test   %eax,%eax
je     119d <split_resource_name+0x7d>
mov    %r13,(%r15)
mov    (%rsp),%rcx
mov    %rbx,(%rcx)
movb   $0x0,(%r12)
cltq
movb   $0x0,(%rbx,%rax,1)
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
define i32 @split_resource_name(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %8
%14 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = load i8*, i8** %8
%17 = call i32 @strspn(i8* %15, i8* %16)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %14, i64 %18
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = load i8*, i8** %8
%22 = call i32 @strcspn(i8* %20, i8* %21)
store i32 %22, i32* %10
%23 = load i8*, i8** %9
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8* %26, i8** %11
%27 = load i8*, i8** %11
%28 = load i8*, i8** %11
%29 = load i8*, i8** %8
%30 = call i32 @strspn(i8* %28, i8* %29)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %27, i64 %31
store i8* %32, i8** %12
%33 = load i8*, i8** %12
%34 = load i8*, i8** %8
%35 = call i32 @strcspn(i8* %33, i8* %34)
store i32 %35, i32* %13
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %3
%39 = load i32, i32* %13
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %38, %3
store i32 -1, i32* %4
br label %55
42: ; preds = %38
%43 = load i8*, i8** %9
%44 = load i8**, i8*** %6
store i8* %43, i8** %44
%45 = load i8*, i8** %12
%46 = load i8**, i8*** %7
store i8* %45, i8** %46
%47 = load i8*, i8** %9
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 0, i8* %50
%51 = load i8*, i8** %12
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 0, i8* %54
store i32 0, i32* %4
br label %55
55: ; preds = %42, %41
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
define i32 @split_resource_name(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i32 @strcspn(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = tail call i32 @strspn(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = tail call i32 @strcspn(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i32 %7, 0
%15 = icmp ne i32 %13, 0
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %20
17: ; preds = %3
store i8* %6, i8** %1
store i8* %12, i8** %2
store i8 0, i8* %9
%18 = sext i32 %13 to i64
%19 = getelementptr inbounds i8, i8* %12, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %3, %17
%21 = phi i32 [ 0, %17 ], [ -1, %3 ]
ret i32 %21
}