#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 *);
int /*<<< orphan*/ kapi_Error_pch1(int, int /*<<< orphan*/, char *, char *);
scalar_t__ strchr(char *, char);
scalar_t__ strlen(char *);
scalar_t__ strspn(char *, char *);
char *strtok(char *, char *);
void ParseLatency(char *pch, char **ppchFcSrc, char **ppchOppSrc,
                  int *piLatency) {
  char *pchSrc, *pchVal, *pchLatency;
  pchVal = (char *)strchr(pch, '=');
  if (pchVal == NULL) {
    kapi_Error_pch1(-1, 0, "Malformed latency attribute '%s' -- '=' required",
                    pch);
    return;
  }
  *pchVal = '\0';
  pchLatency = pchVal + 1;
  if (strspn(pchLatency, "0123456789-") != strlen(pchLatency)) {
    kapi_Error_pch1(-1, 0, "Badly formed bypass:  latency value '%s' not valid",
                    ((pchLatency) ? (pchLatency) : "Null"));
    return;
  }
  *piLatency = atoi(pchLatency);
  pchSrc = pch;
  *ppchFcSrc = NULL;
  *ppchOppSrc = NULL;
  *ppchFcSrc = strtok(pchSrc, " /");
  if (*ppchFcSrc) {
    *ppchOppSrc = strtok(NULL, " /");
  }
}


x86 assembly (clang, -O0):
<ParseLatency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b1 <ParseLatency+0x51>
mov    -0x8(%rbp),%rcx
mov    $0xffffffff,%edi
xor    %esi,%esi
lea    0xe59(%rip),%rdx
call   1060 <kapi_Error_pch1@plt>
jmp    12a6 <ParseLatency+0x146>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1050 <strspn@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
je     1235 <ParseLatency+0xd5>
cmpq   $0x0,-0x38(%rbp)
je     1209 <ParseLatency+0xa9>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1219 <ParseLatency+0xb9>
lea    0xe60(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    1219 <ParseLatency+0xb9>
mov    -0x48(%rbp),%rcx
mov    $0xffffffff,%edi
xor    %esi,%esi
lea    0xe12(%rip),%rdx
call   1060 <kapi_Error_pch1@plt>
jmp    12a6 <ParseLatency+0x146>
mov    -0x38(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     12a6 <ParseLatency+0x146>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdde(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseLatency>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1200 <ParseLatency+0xa0>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strspn@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbp
jne    1213 <ParseLatency+0xb3>
mov    %rbx,%rdi
call   1080 <atoi@plt>
mov    %eax,(%r12)
movq   $0x0,(%r15)
movq   $0x0,(%r14)
lea    0xea0(%rip),%rsi
mov    %r13,%rdi
call   1070 <strtok@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     11f1 <ParseLatency+0x91>
lea    0xe89(%rip),%rsi
xor    %edi,%edi
call   1070 <strtok@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf9(%rip),%rdx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    %r13,%rcx
jmp    1224 <ParseLatency+0xc4>
lea    0xe23(%rip),%rdx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <kapi_Error_pch1@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"Malformed latency attribute '%s' -- '=' required\00"
@.str.1 = [12 x i8] c"0123456789-\00"
@.str.2 = [51 x i8] c"Badly formed bypass: latency value '%s' not valid\00"
@.str.3 = [5 x i8] c"Null\00"
@.str.4 = [3 x i8] c" /\00"
define void @ParseLatency(i8* %0, i8** %1, i8** %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32* %3, i32** %8
%12 = load i8*, i8** %5
%13 = call i64 @strchr(i8* %12, i8 signext 61)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %10
%15 = load i8*, i8** %10
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %4
%18 = load i8*, i8** %5
%19 = call i32 @kapi_Error_pch1(i32 -1, i32 0, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %54
20: ; preds = %4
%21 = load i8*, i8** %10
store i8 0, i8* %21
%22 = load i8*, i8** %10
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %11
%24 = load i8*, i8** %11
%25 = call i64 @strspn(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %11
%27 = call i64 @strlen(i8* %26)
%28 = icmp ne i64 %25, %27
br i1 %28, label %29, label %38
29: ; preds = %20
%30 = load i8*, i8** %11
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i8*, i8** %11
br label %35
34: ; preds = %29
br label %35
35: ; preds = %34, %32
%36 = phi i8* [ %33, %32 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %34 ]
%37 = call i32 @kapi_Error_pch1(i32 -1, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %54
38: ; preds = %20
%39 = load i8*, i8** %11
%40 = call i32 @atoi(i8* %39)
%41 = load i32*, i32** %8
store i32 %40, i32* %41
%42 = load i8*, i8** %5
store i8* %42, i8** %9
%43 = load i8**, i8*** %6
store i8* null, i8** %43
%44 = load i8**, i8*** %7
store i8* null, i8** %44
%45 = load i8*, i8** %9
%46 = call i8* @strtok(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%47 = load i8**, i8*** %6
store i8* %46, i8** %47
%48 = load i8**, i8*** %6
%49 = load i8*, i8** %48
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %54
51: ; preds = %38
%52 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%53 = load i8**, i8*** %7
store i8* %52, i8** %53
br label %54
54: ; preds = %17, %35, %51, %38
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"Malformed latency attribute '%s' -- '=' required\00"
@.str.1 = [12 x i8] c"0123456789-\00"
@.str.2 = [51 x i8] c"Badly formed bypass: latency value '%s' not valid\00"
@.str.4 = [3 x i8] c" /\00"
define void @ParseLatency(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i32* 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 ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %23
10: ; preds = %4
store i8 0, i8* %6
%11 = getelementptr inbounds i8, i8* %6, i64 1
%12 = tail call i64 @strspn(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i64 @strlen(i8* %11)
%14 = icmp eq i64 %12, %13
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i32 @kapi_Error_pch1(i32 -1, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %23
17: ; preds = %10
%18 = tail call i32 @atoi(i8* %11)
store i32 %18, i32* %3
store i8* null, i8** %1
store i8* null, i8** %2
%19 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i8* %19, i8** %1
%20 = icmp eq i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i8* %22, i8** %2
br label %23
23: ; preds = %17, %21, %15, %8
ret void
}