#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*/ fontColor(int, int, int);
int /*<<< orphan*/ fontColorA(int, int, int, int);
scalar_t__ pow(int, int);
int sscanf(char *, char *, int *, int *, int *, ...);
int fontSetColorFromToken(char *s) {
  int clr[4];
  int ret = 1;
  if (*s == 'c') {
    s += 1;
    if (sscanf(s, "(%d %d %d)", &clr[0], &clr[1], &clr[2]) != 3)
      return -1;
    fontColor(clr[0] * (float)pow(255, -1), clr[1] * (float)pow(255, -1),
              clr[2] * (float)pow(255, -1));
  } else if (*s == 'a') {
    s += 1;
    if (sscanf(s, "(%d %d %d %d)", &clr[0], &clr[1], &clr[2], &clr[3]) != 4)
      return -1;
    fontColorA(clr[0] * (float)pow(255, -1), clr[1] * (float)pow(255, -1),
               clr[2] * (float)pow(255, -1), clr[3] * (float)pow(255, -1));
  }
  while (*s != ')' && ret++)
    s += 1;
  return ret + 1;
}


x86 assembly (clang, -O0):
<fontSetColorFromToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    1241 <fontSetColorFromToken+0x101>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x20(%rbp),%rcx
add    $0x4,%rcx
lea    -0x20(%rbp),%r8
add    $0x8,%r8
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     11aa <fontSetColorFromToken+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <fontSetColorFromToken+0x280>
cvtsi2ssl -0x20(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x38(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x34(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x30(%rbp),%xmm0
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
call   1050 <fontColor@plt>
jmp    1368 <fontSetColorFromToken+0x228>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jne    1363 <fontSetColorFromToken+0x223>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x20(%rbp),%rcx
add    $0x4,%rcx
lea    -0x20(%rbp),%r8
add    $0x8,%r8
lea    -0x20(%rbp),%r9
add    $0xc,%r9
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x4,%eax
je     12a0 <fontSetColorFromToken+0x160>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <fontSetColorFromToken+0x280>
cvtsi2ssl -0x20(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x54(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x44(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x50(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x40(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x4c(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
movss  -0x48(%rbp),%xmm0
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
call   1030 <fontColorA@plt>
jmp    1368 <fontSetColorFromToken+0x228>
jmp    136d <fontSetColorFromToken+0x22d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x29,%ecx
mov    %al,-0x55(%rbp)
je     1396 <fontSetColorFromToken+0x256>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    13a6 <fontSetColorFromToken+0x266>
jmp    13b7 <fontSetColorFromToken+0x277>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    136d <fontSetColorFromToken+0x22d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fontSetColorFromToken>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
mov    (%rdi),%cl
cmp    $0x61,%cl
je     1232 <fontSetColorFromToken+0xf2>
cmp    $0x63,%cl
jne    1339 <fontSetColorFromToken+0x1f9>
add    $0x1,%rbx
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0xe8a(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x3,%ecx
jne    135d <fontSetColorFromToken+0x21d>
cvtsi2ssl 0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%r14d
xorps  %xmm0,%xmm0
cvtsi2ssl 0x14(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%ebp
xorps  %xmm0,%xmm0
cvtsi2ssl 0x18(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%edx
mov    %r14d,%edi
mov    %ebp,%esi
call   1050 <fontColor@plt>
jmp    1337 <fontSetColorFromToken+0x1f7>
add    $0x1,%rbx
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x1c(%rsp),%r9
lea    0xdbf(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x4,%ecx
jne    135d <fontSetColorFromToken+0x21d>
cvtsi2ssl 0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%r14d
xorps  %xmm0,%xmm0
cvtsi2ssl 0x14(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%r15d
xorps  %xmm0,%xmm0
cvtsi2ssl 0x18(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%ebp
xorps  %xmm0,%xmm0
cvtsi2ssl 0x1c(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xff,%edi
mov    $0xffffffff,%esi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%ecx
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <fontColorA@plt>
mov    (%rbx),%cl
mov    $0x2,%eax
cmp    $0x29,%cl
je     135d <fontSetColorFromToken+0x21d>
mov    $0x1,%eax
nopl   0x0(%rax,%rax,1)
cmpb   $0x29,(%rbx,%rax,1)
lea    0x1(%rax),%rax
jne    1350 <fontSetColorFromToken+0x210>
add    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"(%d %d %d)\00"
@.str.1 = [14 x i8] c"(%d %d %d %d)\00"
define i32 @fontSetColorFromToken(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4 x i32]
%5 = alloca i32
store i8* %0, i8** %3
store i32 1, i32* %5
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 99
br i1 %9, label %10, label %43
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%17 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %14, i32* %15, i32* %16)
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %20
19: ; preds = %10
store i32 -1, i32* %2
br label %108
20: ; preds = %10
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%22 = load i32, i32* %21
%23 = sitofp i32 %22 to float
%24 = call i64 @pow(i32 255, i32 -1)
%25 = sitofp i64 %24 to float
%26 = fmul float %23, %25
%27 = fptosi float %26 to i32
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%29 = load i32, i32* %28
%30 = sitofp i32 %29 to float
%31 = call i64 @pow(i32 255, i32 -1)
%32 = sitofp i64 %31 to float
%33 = fmul float %30, %32
%34 = fptosi float %33 to i32
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%36 = load i32, i32* %35
%37 = sitofp i32 %36 to float
%38 = call i64 @pow(i32 255, i32 -1)
%39 = sitofp i64 %38 to float
%40 = fmul float %37, %39
%41 = fptosi float %40 to i32
%42 = call i32 @fontColor(i32 %27, i32 %34, i32 %41)
br label %90
43: ; preds = %1
%44 = load i8*, i8** %3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 97
br i1 %47, label %48, label %89
48: ; preds = %43
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 1
store i8* %50, i8** %3
%51 = load i8*, i8** %3
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%55 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
%56 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %52, i32* %53, i32* %54, i32* %55)
%57 = icmp ne i32 %56, 4
br i1 %57, label %58, label %59
58: ; preds = %48
store i32 -1, i32* %2
br label %108
59: ; preds = %48
%60 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%61 = load i32, i32* %60
%62 = sitofp i32 %61 to float
%63 = call i64 @pow(i32 255, i32 -1)
%64 = sitofp i64 %63 to float
%65 = fmul float %62, %64
%66 = fptosi float %65 to i32
%67 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%68 = load i32, i32* %67
%69 = sitofp i32 %68 to float
%70 = call i64 @pow(i32 255, i32 -1)
%71 = sitofp i64 %70 to float
%72 = fmul float %69, %71
%73 = fptosi float %72 to i32
%74 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%75 = load i32, i32* %74
%76 = sitofp i32 %75 to float
%77 = call i64 @pow(i32 255, i32 -1)
%78 = sitofp i64 %77 to float
%79 = fmul float %76, %78
%80 = fptosi float %79 to i32
%81 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
%82 = load i32, i32* %81
%83 = sitofp i32 %82 to float
%84 = call i64 @pow(i32 255, i32 -1)
%85 = sitofp i64 %84 to float
%86 = fmul float %83, %85
%87 = fptosi float %86 to i32
%88 = call i32 @fontColorA(i32 %66, i32 %73, i32 %80, i32 %87)
br label %89
89: ; preds = %59, %43
br label %90
90: ; preds = %89, %20
br label %91
91: ; preds = %102, %90
%92 = load i8*, i8** %3
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 41
br i1 %95, label %96, label %100
96: ; preds = %91
%97 = load i32, i32* %5
%98 = add nsw i32 %97, 1
store i32 %98, i32* %5
%99 = icmp ne i32 %97, 0
br label %100
100: ; preds = %96, %91
%101 = phi i1 [ false, %91 ], [ %99, %96 ]
br i1 %101, label %102, label %105
102: ; preds = %100
%103 = load i8*, i8** %3
%104 = getelementptr inbounds i8, i8* %103, i64 1
store i8* %104, i8** %3
br label %91
105: ; preds = %100
%106 = load i32, i32* %5
%107 = add nsw i32 %106, 1
store i32 %107, i32* %2
br label %108
108: ; preds = %105, %58, %19
%109 = load i32, i32* %2
ret i32 %109
}

LLVM IR (-O2):
@.str = [11 x i8] c"(%d %d %d)\00"
@.str.1 = [14 x i8] c"(%d %d %d %d)\00"
define i32 @fontSetColorFromToken(i8* nocapture %0) {
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = load i8, i8* %0
switch i8 %4, label %69 [
i8 99, label %5
i8 97, label %32
]
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%10 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %80
12: ; preds = %5
%13 = load i32, i32* %7
%14 = sitofp i32 %13 to float
%15 = call i64 @pow(i32 255, i32 -1)
%16 = sitofp i64 %15 to float
%17 = fmul float %14, %16
%18 = fptosi float %17 to i32
%19 = load i32, i32* %8
%20 = sitofp i32 %19 to float
%21 = call i64 @pow(i32 255, i32 -1)
%22 = sitofp i64 %21 to float
%23 = fmul float %20, %22
%24 = fptosi float %23 to i32
%25 = load i32, i32* %9
%26 = sitofp i32 %25 to float
%27 = call i64 @pow(i32 255, i32 -1)
%28 = sitofp i64 %27 to float
%29 = fmul float %26, %28
%30 = fptosi float %29 to i32
%31 = call i32 @fontColor(i32 %18, i32 %24, i32 %30)
br label %66
32: ; preds = %1
%33 = getelementptr inbounds i8, i8* %0, i64 1
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%38 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %34, i32* %35, i32* %36, i32* %37)
%39 = icmp eq i32 %38, 4
br i1 %39, label %40, label %80
40: ; preds = %32
%41 = load i32, i32* %34
%42 = sitofp i32 %41 to float
%43 = call i64 @pow(i32 255, i32 -1)
%44 = sitofp i64 %43 to float
%45 = fmul float %42, %44
%46 = fptosi float %45 to i32
%47 = load i32, i32* %35
%48 = sitofp i32 %47 to float
%49 = call i64 @pow(i32 255, i32 -1)
%50 = sitofp i64 %49 to float
%51 = fmul float %48, %50
%52 = fptosi float %51 to i32
%53 = load i32, i32* %36
%54 = sitofp i32 %53 to float
%55 = call i64 @pow(i32 255, i32 -1)
%56 = sitofp i64 %55 to float
%57 = fmul float %54, %56
%58 = fptosi float %57 to i32
%59 = load i32, i32* %37
%60 = sitofp i32 %59 to float
%61 = call i64 @pow(i32 255, i32 -1)
%62 = sitofp i64 %61 to float
%63 = fmul float %60, %62
%64 = fptosi float %63 to i32
%65 = call i32 @fontColorA(i32 %46, i32 %52, i32 %58, i32 %64)
br label %66
66: ; preds = %12, %40
%67 = phi i8* [ %33, %40 ], [ %6, %12 ]
%68 = load i8, i8* %67
br label %69
69: ; preds = %66, %1
%70 = phi i8 [ %68, %66 ], [ %4, %1 ]
%71 = phi i8* [ %67, %66 ], [ %0, %1 ]
%72 = icmp eq i8 %70, 41
br i1 %72, label %80, label %73
73: ; preds = %69, %73
%74 = phi i32 [ %77, %73 ], [ 2, %69 ]
%75 = phi i8* [ %76, %73 ], [ %71, %69 ]
%76 = getelementptr inbounds i8, i8* %75, i64 1
%77 = add i32 %74, 1
%78 = load i8, i8* %76
%79 = icmp eq i8 %78, 41
br i1 %79, label %80, label %73
80: ; preds = %73, %69, %32, %5
%81 = phi i32 [ -1, %5 ], [ -1, %32 ], [ 2, %69 ], [ %77, %73 ]
ret i32 %81
}