#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 */
typedef double uint64_t;
struct odflow_spec {
  int dummy;
};

/* Variables and functions */
scalar_t__ isspace(char);
int /*<<< orphan*/ protospec_parse(char *, struct odflow_spec *, double *,
                                   double *);
char *strchr(char *, char);
char *proto_parse(char **strp, uint64_t byte, uint64_t packet,
                  struct odflow_spec *odpsp, uint64_t *byte2,
                  uint64_t *packet2) {
  char *cp, *ap;
  double perc, perc2;
  if (strp == NULL || (cp = *strp) == NULL)
    return (NULL);
  while (isspace(*cp))
    cp++;
  if (*cp == '\0')
    return (NULL);
  ap = strchr(&cp[1], '[');
  *strp = ap;
  if (ap != NULL) {
    ap[-1] = '\0';
  } else {
    if (strchr(cp, ']') == NULL)
      return (NULL);
  }
  protospec_parse(cp, odpsp, &perc, &perc2);
  *byte2 = (uint64_t)(perc * byte / 100);
  *packet2 = (uint64_t)(perc2 * packet / 100);
  return (cp);
}


x86 assembly (clang, -O0):
<proto_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1172 <proto_parse+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    117f <proto_parse+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    1284 <proto_parse+0x154>
jmp    1184 <proto_parse+0x54>
mov    -0x40(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11ab <proto_parse+0x7b>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1184 <proto_parse+0x54>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c8 <proto_parse+0x98>
movq   $0x0,-0x8(%rbp)
jmp    1284 <proto_parse+0x154>
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    $0x5b,%esi
call   1040 <strchr@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x48(%rbp)
je     1201 <proto_parse+0xd1>
mov    -0x48(%rbp),%rax
movb   $0x0,-0x1(%rax)
jmp    122b <proto_parse+0xfb>
mov    -0x40(%rbp),%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    1226 <proto_parse+0xf6>
movq   $0x0,-0x8(%rbp)
jmp    1284 <proto_parse+0x154>
jmp    122b <proto_parse+0xfb>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1030 <protospec_parse@plt>
movsd  -0x50(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xdae(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd90(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proto_parse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdi,%rdi
je     1202 <proto_parse+0xd2>
mov    %rdi,%rbx
mov    (%rdi),%rbp
test   %rbp,%rbp
je     1202 <proto_parse+0xd2>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%rbp),%edi
call   1050 <isspace@plt>
add    $0x1,%rbp
test   %rax,%rax
jne    1170 <proto_parse+0x40>
cmpb   $0x0,-0x1(%rbp)
je     1202 <proto_parse+0xd2>
lea    -0x1(%rbp),%r13
mov    %rbp,%rdi
mov    $0x5b,%esi
call   1040 <strchr@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11a7 <proto_parse+0x77>
movb   $0x0,-0x1(%rax)
jmp    11b9 <proto_parse+0x89>
mov    %r13,%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1202 <proto_parse+0xd2>
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <protospec_parse@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
movsd  0xe1e(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
movsd  0x10(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
jmp    1205 <proto_parse+0xd5>
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.odflow_spec = type { i32 }
define i8* @proto_parse(i8** %0, double %1, double %2, %struct.odflow_spec* %3, double* %4, double* %5) {
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca double
%10 = alloca double
%11 = alloca %struct.odflow_spec*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca double
%17 = alloca double
store i8** %0, i8*** %8
store double %1, double* %9
store double %2, double* %10
store %struct.odflow_spec* %3, %struct.odflow_spec** %11
store double* %4, double** %12
store double* %5, double** %13
%18 = load i8**, i8*** %8
%19 = icmp eq i8** %18, null
br i1 %19, label %24, label %20
20: ; preds = %6
%21 = load i8**, i8*** %8
%22 = load i8*, i8** %21
store i8* %22, i8** %14
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %20, %6
store i8* null, i8** %7
br label %72
25: ; preds = %20
br label %26
26: ; preds = %31, %25
%27 = load i8*, i8** %14
%28 = load i8, i8* %27
%29 = call i64 @isspace(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %14
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %14
br label %26
34: ; preds = %26
%35 = load i8*, i8** %14
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
store i8* null, i8** %7
br label %72
40: ; preds = %34
%41 = load i8*, i8** %14
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = call i8* @strchr(i8* %42, i8 signext 91)
store i8* %43, i8** %15
%44 = load i8*, i8** %15
%45 = load i8**, i8*** %8
store i8* %44, i8** %45
%46 = load i8*, i8** %15
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %51
48: ; preds = %40
%49 = load i8*, i8** %15
%50 = getelementptr inbounds i8, i8* %49, i64 -1
store i8 0, i8* %50
br label %57
51: ; preds = %40
%52 = load i8*, i8** %14
%53 = call i8* @strchr(i8* %52, i8 signext 93)
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %56
55: ; preds = %51
store i8* null, i8** %7
br label %72
56: ; preds = %51
br label %57
57: ; preds = %56, %48
%58 = load i8*, i8** %14
%59 = load %struct.odflow_spec*, %struct.odflow_spec** %11
%60 = call i32 @protospec_parse(i8* %58, %struct.odflow_spec* %59, double* %16, double* %17)
%61 = load double, double* %16
%62 = load double, double* %9
%63 = fmul double %61, %62
%64 = fdiv double %63, 1.000000e+02
%65 = load double*, double** %12
store double %64, double* %65
%66 = load double, double* %17
%67 = load double, double* %10
%68 = fmul double %66, %67
%69 = fdiv double %68, 1.000000e+02
%70 = load double*, double** %13
store double %69, double* %70
%71 = load i8*, i8** %14
store i8* %71, i8** %7
br label %72
72: ; preds = %57, %55, %39, %24
%73 = load i8*, i8** %7
ret i8* %73
}

LLVM IR (-O2):
%struct.odflow_spec = type { i32 }
define i8* @proto_parse(i8** %0, double %1, double %2, %struct.odflow_spec* %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %7 to i8*
%10 = bitcast double* %8 to i8*
%11 = icmp eq i8** %0, null
br i1 %11, label %40, label %12
12: ; preds = %6
%13 = load i8*, i8** %0
%14 = icmp eq i8* %13, null
br i1 %14, label %40, label %15
15: ; preds = %12, %15
%16 = phi i8* [ %20, %15 ], [ %13, %12 ]
%17 = load i8, i8* %16
%18 = tail call i64 @isspace(i8 signext %17)
%19 = icmp eq i64 %18, 0
%20 = getelementptr inbounds i8, i8* %16, i64 1
br i1 %19, label %21, label %15
21: ; preds = %15
%22 = load i8, i8* %16
%23 = icmp eq i8 %22, 0
br i1 %23, label %40, label %24
24: ; preds = %21
%25 = tail call i8* @strchr(i8* %20, i8 signext 91)
store i8* %25, i8** %0
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = getelementptr inbounds i8, i8* %25, i64 -1
store i8 0, i8* %28
br label %32
29: ; preds = %24
%30 = tail call i8* @strchr(i8* %16, i8 signext 93)
%31 = icmp eq i8* %30, null
br i1 %31, label %40, label %32
32: ; preds = %29, %27
%33 = call i32 @protospec_parse(i8* %16, %struct.odflow_spec* %3, double* %7, double* %8)
%34 = load double, double* %7
%35 = fmul double %34, %1
%36 = fdiv double %35, 1.000000e+02
store double %36, double* %4
%37 = load double, double* %8
%38 = fmul double %37, %2
%39 = fdiv double %38, 1.000000e+02
store double %39, double* %5
br label %40
40: ; preds = %29, %21, %6, %12, %32
%41 = phi i8* [ %16, %32 ], [ null, %12 ], [ null, %6 ], [ null, %21 ], [ null, %29 ]
ret i8* %41
}