#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 */
scalar_t__ atof(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, size_t);
char *strtok(char *, char *);
double mean(char *str, char *town) {
  char buff[strlen(str)];
  strcpy(buff, str);
  char line[200];
  strcpy(line, "");
  char *pch = strtok(buff, "\n");
  while (pch != NULL) {
    if (strncmp(pch, town, strlen(town)) == 0) {
      strcpy(line, pch);
      break;
    }
    pch = strtok(NULL, "\n");
  }
  if (strlen(line) == 0)
    return -1;
  int cnt = 0;
  for (size_t i = 0; i < strlen(line); ++i) {
    if (isdigit(line[i]) || line[i] == '.' || line[i] == ',')
      line[cnt++] = line[i];
  }
  line[cnt] = '\0';
  double sum = 0;
  pch = strtok(line, ",");
  while (pch != NULL) {
    sum += atof(pch);
    pch = strtok(NULL, ",");
  }
  return sum / 12.0;
}


x86 assembly (clang, -O0):
<mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    %rcx,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x118(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0xf0(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x118(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0xf8(%rbp)
cmpq   $0x0,-0xf8(%rbp)
je     125f <mean+0xff>
mov    -0xf8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x128(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1243 <mean+0xe3>
lea    -0xf0(%rbp),%rdi
mov    -0xf8(%rbp),%rsi
call   1050 <strcpy@plt>
jmp    125f <mean+0xff>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc2(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0xf8(%rbp)
jmp    11db <mean+0x7b>
lea    -0xf0(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
jne    1291 <mean+0x131>
movsd  0xd8b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x1,-0xfc(%rbp)
jmp    1407 <mean+0x2a7>
movl   $0x0,-0x100(%rbp)
movq   $0x0,-0x108(%rbp)
mov    -0x108(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0xf0(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
cmp    %rcx,%rax
jae    1365 <mean+0x205>
mov    -0x108(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%edi
ff
call   1040 <isdigit@plt>
cmp    $0x0,%rax
jne    1321 <mean+0x1c1>
mov    -0x108(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0x2e,%eax
je     1321 <mean+0x1c1>
mov    -0x108(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0x2c,%eax
jne    1349 <mean+0x1e9>
mov    -0x108(%rbp),%rax
mov    -0xf0(%rbp,%rax,1),%cl
mov    -0x100(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x100(%rbp)
cltq
mov    %cl,-0xf0(%rbp,%rax,1)
jmp    134e <mean+0x1ee>
mov    -0x108(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x108(%rbp)
jmp    12a6 <mean+0x146>
movslq -0x100(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
lea    -0xf0(%rbp),%rdi
lea    0xc85(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0xf8(%rbp)
cmpq   $0x0,-0xf8(%rbp)
je     13e4 <mean+0x284>
mov    -0xf8(%rbp),%rdi
call   1060 <atof@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x110(%rbp),%xmm0
ff
movsd  %xmm0,-0x110(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xc3f(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0xf8(%rbp)
jmp    1399 <mean+0x239>
movsd  -0x110(%rbp),%xmm0
ff
movsd  0xc0c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x1,-0xfc(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
movsd  -0x8(%rbp),%xmm0
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mean>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1070 <strlen@plt>
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcpy@plt>
lea    0xe73(%rip),%rsi
lea    -0xf0(%rbp),%rdi
call   1050 <strcpy@plt>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     120e <mean+0xae>
mov    %rax,%rbx
lea    0xe48(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ff <mean+0x9f>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d0 <mean+0x70>
jmp    120e <mean+0xae>
lea    -0xf0(%rbp),%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    -0xf0(%rbp),%al
test   %al,%al
je     12df <mean+0x17f>
xor    %r15d,%r15d
mov    $0x1,%ebx
lea    -0xf0(%rbp),%r14
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <isdigit@plt>
movzbl -0xf1(%rbp,%rbx,1),%ecx
ff
test   %rax,%rax
jne    124d <mean+0xed>
mov    %ecx,%eax
or     $0x2,%al
cmp    $0x2e,%al
jne    125b <mean+0xfb>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %cl,-0xf0(%rbp,%rax,1)
mov    %r14,%rdi
call   1070 <strlen@plt>
cmp    %rax,%rbx
jae    1276 <mean+0x116>
movzbl -0xf0(%rbp,%rbx,1),%eax
ff
add    $0x1,%rbx
jmp    1230 <mean+0xd0>
movslq %r15d,%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
lea    0xd8a(%rip),%rsi
lea    -0xf0(%rbp),%rdi
call   1080 <strtok@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
je     12e9 <mean+0x189>
movsd  %xmm0,-0x20(%rbp)
lea    0xd69(%rip),%rbx
nopl   0x0(%rax)
mov    %rax,%rdi
call   1060 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x20(%rbp)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    12b0 <mean+0x150>
jmp    12ee <mean+0x18e>
movsd  0xd19(%rip),%xmm0
jmp    12fb <mean+0x19b>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  0xd0d(%rip),%xmm0
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c",\00"
define double @mean(i8* %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [200 x i8]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca double
store i8* %0, i8** %4
store i8* %1, i8** %5
%14 = load i8*, i8** %4
%15 = call i64 @strlen(i8* %14)
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca i8, i64 %15
store i64 %15, i64* %7
%18 = load i8*, i8** %4
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%22 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %9
br label %23
23: ; preds = %37, %2
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = load i8*, i8** %9
%28 = load i8*, i8** %5
%29 = load i8*, i8** %5
%30 = call i64 @strlen(i8* %29)
%31 = call i64 @strncmp(i8* %27, i8* %28, i64 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %26
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%35 = load i8*, i8** %9
%36 = call i32 @strcpy(i8* %34, i8* %35)
br label %39
37: ; preds = %26
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %38, i8** %9
br label %23
39: ; preds = %33, %23
%40 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%41 = call i64 @strlen(i8* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store double -1.000000e+00, double* %3
store i32 1, i32* %10
br label %99
44: ; preds = %39
store i32 0, i32* %11
store i64 0, i64* %12
br label %45
45: ; preds = %77, %44
%46 = load i64, i64* %12
%47 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%48 = call i64 @strlen(i8* %47)
%49 = icmp ult i64 %46, %48
br i1 %49, label %50, label %80
50: ; preds = %45
%51 = load i64, i64* %12
%52 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = call i64 @isdigit(i8 signext %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %68, label %56
56: ; preds = %50
%57 = load i64, i64* %12
%58 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 46
br i1 %61, label %68, label %62
62: ; preds = %56
%63 = load i64, i64* %12
%64 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 44
br i1 %67, label %68, label %76
68: ; preds = %62, %56, %50
%69 = load i64, i64* %12
%70 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = load i32, i32* %11
%73 = add nsw i32 %72, 1
store i32 %73, i32* %11
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %74
store i8 %71, i8* %75
br label %76
76: ; preds = %68, %62
br label %77
77: ; preds = %76
%78 = load i64, i64* %12
%79 = add i64 %78, 1
store i64 %79, i64* %12
br label %45
80: ; preds = %45
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %82
store i8 0, i8* %83
store double 0.000000e+00, double* %13
%84 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%85 = call i8* @strtok(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %85, i8** %9
br label %86
86: ; preds = %89, %80
%87 = load i8*, i8** %9
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %96
89: ; preds = %86
%90 = load i8*, i8** %9
%91 = call i64 @atof(i8* %90)
%92 = sitofp i64 %91 to double
%93 = load double, double* %13
%94 = fadd double %93, %92
store double %94, double* %13
%95 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %95, i8** %9
br label %86
96: ; preds = %86
%97 = load double, double* %13
%98 = fdiv double %97, 1.200000e+01
store double %98, double* %3
store i32 1, i32* %10
br label %99
99: ; preds = %96, %43
%100 = load i8*, i8** %6
%101 = load double, double* %3
ret double %101
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c",\00"
define double @mean(i8* %0, i8* %1) {
%3 = alloca [200 x i8]
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = alloca i8, i64 %4
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %2, %18
%12 = phi i8* [ %19, %18 ], [ %9, %2 ]
%13 = call i64 @strlen(i8* dereferenceable(1) %1)
%14 = call i64 @strncmp(i8* %12, i8* %1, i64 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @strcpy(i8* %7, i8* %12)
br label %21
18: ; preds = %11
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %11
21: ; preds = %18, %2, %16
%22 = load i8, i8* %7
%23 = icmp eq i8 %22, 0
br i1 %23, label %61, label %29
24: ; preds = %42
%25 = sext i32 %43 to i64
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %58, label %50
29: ; preds = %21, %47
%30 = phi i8 [ %49, %47 ], [ %22, %21 ]
%31 = phi i64 [ %44, %47 ], [ 0, %21 ]
%32 = phi i32 [ %43, %47 ], [ 0, %21 ]
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %31
%34 = call i64 @isdigit(i8 signext %30)
%35 = icmp eq i64 %34, 0
%36 = load i8, i8* %33
br i1 %35, label %37, label %38
37: ; preds = %29
switch i8 %36, label %42 [
i8 46, label %38
i8 44, label %38
]
38: ; preds = %29, %37, %37
%39 = add nsw i32 %32, 1
%40 = sext i32 %32 to i64
%41 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %40
store i8 %36, i8* %41
br label %42
42: ; preds = %37, %38
%43 = phi i32 [ %39, %38 ], [ %32, %37 ]
%44 = add nuw i64 %31, 1
%45 = call i64 @strlen(i8* %7)
%46 = icmp ult i64 %44, %45
br i1 %46, label %47, label %24
47: ; preds = %42
%48 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %44
%49 = load i8, i8* %48
br label %29
50: ; preds = %24, %50
%51 = phi double [ %55, %50 ], [ 0.000000e+00, %24 ]
%52 = phi i8* [ %56, %50 ], [ %27, %24 ]
%53 = call i64 @atof(i8* %52)
%54 = sitofp i64 %53 to double
%55 = fadd double %51, %54
%56 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %50
58: ; preds = %50, %24
%59 = phi double [ 0.000000e+00, %24 ], [ %55, %50 ]
%60 = fdiv double %59, 1.200000e+01
br label %61
61: ; preds = %21, %58
%62 = phi double [ %60, %58 ], [ -1.000000e+00, %21 ]
ret double %62
}