#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*/ kapi_Error_pch1(int, int /*<<< orphan*/, char *, char *);
scalar_t__ strchr(char *, char);
char *strtok(char *, char *);
void ParseClusterDistance(char *pch, char **ppchClrSrc, char **ppchClrDest,
                          char **ppchValue) {
  char *pchSrc, *pchValue;
  pchValue = (char *)strchr(pch, '=');
  if (pchValue == NULL) {
    kapi_Error_pch1(-1, 0,
                    "Malformed cluster distance attribute '%s' -- '=' required",
                    pch);
    return;
  }
  *pchValue = '\0';
  pchValue = pchValue + 1;
  *ppchValue = pchValue;
  pchSrc = pch;
  *ppchClrSrc = NULL;
  *ppchClrSrc = NULL;
  *ppchClrSrc = strtok(pchSrc, " :");
  if (*ppchClrSrc) {
    *ppchClrDest = strtok(NULL, " :");
  }
}


x86 assembly (clang, -O0):
<ParseClusterDistance>:
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    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1181 <ParseClusterDistance+0x51>
mov    -0x8(%rbp),%rcx
mov    $0xffffffff,%edi
xor    %esi,%esi
lea    0xe89(%rip),%rdx
call   1040 <kapi_Error_pch1@plt>
jmp    11ff <ParseClusterDistance+0xcf>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ff <ParseClusterDistance+0xcf>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4a(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseClusterDistance>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x3d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1199 <ParseClusterDistance+0x69>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,(%r12)
movq   $0x0,(%r15)
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     118d <ParseClusterDistance+0x5d>
lea    0xeb7(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe60(%rip),%rdx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <kapi_Error_pch1@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"Malformed cluster distance attribute '%s' -- '=' required\00"
@.str.1 = [3 x i8] c" :\00"
define void @ParseClusterDistance(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*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%11 = load i8*, i8** %5
%12 = call i64 @strchr(i8* %11, i8 signext 61)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %10
%14 = load i8*, i8** %10
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %4
%17 = load i8*, i8** %5
%18 = call i32 @kapi_Error_pch1(i32 -1, i32 0, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %37
19: ; preds = %4
%20 = load i8*, i8** %10
store i8 0, i8* %20
%21 = load i8*, i8** %10
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %10
%23 = load i8*, i8** %10
%24 = load i8**, i8*** %8
store i8* %23, i8** %24
%25 = load i8*, i8** %5
store i8* %25, i8** %9
%26 = load i8**, i8*** %6
store i8* null, i8** %26
%27 = load i8**, i8*** %6
store i8* null, i8** %27
%28 = load i8*, i8** %9
%29 = call i8* @strtok(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = load i8**, i8*** %6
store i8* %29, i8** %30
%31 = load i8**, i8*** %6
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %19
%35 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%36 = load i8**, i8*** %7
store i8* %35, i8** %36
br label %37
37: ; preds = %16, %34, %19
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"Malformed cluster distance attribute '%s' -- '=' required\00"
@.str.1 = [3 x i8] c" :\00"
define void @ParseClusterDistance(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = tail call i64 @strchr(i8* %0, i8 signext 61)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @kapi_Error_pch1(i32 -1, i32 0, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
10: ; preds = %4
store i8 0, i8* %6
%11 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %11, i8** %3
store i8* null, i8** %1
%12 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %1
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %2
br label %16
16: ; preds = %10, %14, %8
ret void
}