#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*/ EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
double strtod(char *, char **);
char *strtok_r(char *, char *, char **);
int get_all_frequencies(double *frequencies, int max, char *line) {
  char *tok = NULL;
  char *savebuffer = NULL;
  int count = 0;
  double frequency = 0.0;
  char *endptr = NULL;
  do {
    if (count == 0)
      tok = strtok_r(line, " \n", &savebuffer);
    else
      tok = strtok_r(NULL, " \n", &savebuffer);
    if ((count == 0) && (tok == NULL)) {
      frequencies[count] = 0.0;
    }
    if (tok != NULL) {
      frequency = strtod(tok, &endptr);
      if (!(0 == errno)) {
        fprintf(stderr,
                "[ERROR] (%s:%d: errno: %s) "
                "strtod sets errno to zero"
                "\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/efferifick/wave/refs/heads/"
                "master/src/wave.c",
                363, (errno == 0 ? "None" : strerror(errno)));
        errno = 0;
        goto error;
      };
      if (!(tok != endptr)) {
        fprintf(stderr,
                "[ERROR] (%s:%d: errno: %s) "
                "no frequency found"
                "\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/efferifick/wave/refs/heads/"
                "master/src/wave.c",
                364, (errno == 0 ? "None" : strerror(errno)));
        errno = 0;
        goto error;
      };
      frequencies[count] = frequency;
      fprintf(stderr,
              "DEBUG %s:%d: "
              "frequency[%d]: %lf"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/efferifick/wave/refs/heads/master/src/"
              "wave.c",
              366, count, frequencies[count]);
    }
    count++;
  } while ((tok != NULL) && (count < max));
  return count;
error:
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<get_all_frequencies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11b1 <get_all_frequencies+0x61>
mov    -0x18(%rbp),%rdi
lea    0xe61(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x20(%rbp)
jmp    11c9 <get_all_frequencies+0x79>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe44(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11ee <get_all_frequencies+0x9e>
cmpq   $0x0,-0x20(%rbp)
jne    11ee <get_all_frequencies+0x9e>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cmpq   $0x0,-0x20(%rbp)
je     1359 <get_all_frequencies+0x209>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x38(%rbp)
xor    %eax,%eax
mov    0x2dc4(%rip),%rcx
cmp    (%rcx),%rax
je     1291 <get_all_frequencies+0x141>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2da8(%rip),%rax
cmpq   $0x0,(%rax)
jne    124a <get_all_frequencies+0xfa>
lea    0xe7f(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    125d <get_all_frequencies+0x10d>
mov    0x2d87(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x50(%rbp),%r8
lea    0xd98(%rip),%rsi
lea    0xdc7(%rip),%rdx
mov    $0x16b,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d53(%rip),%rax
movq   $0x0,(%rax)
jmp    1392 <get_all_frequencies+0x242>
mov    -0x20(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    1313 <get_all_frequencies+0x1c3>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2d26(%rip),%rax
cmpq   $0x0,(%rax)
jne    12cc <get_all_frequencies+0x17c>
lea    0xdfd(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    12df <get_all_frequencies+0x18f>
mov    0x2d05(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    %rax,-0x60(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x60(%rbp),%r8
lea    0xdd8(%rip),%rsi
lea    0xd45(%rip),%rdx
mov    $0x16c,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cd1(%rip),%rax
movq   $0x0,(%rax)
jmp    1392 <get_all_frequencies+0x242>
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%r8d
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdae(%rip),%rsi
lea    0xcec(%rip),%rdx
mov    $0x16e,%ecx
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x61(%rbp)
je     137e <get_all_frequencies+0x22e>
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    118a <get_all_frequencies+0x3a>
mov    -0x2c(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<get_all_frequencies>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rdi,%r15
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
movslq %esi,%r13
xor    %ebx,%ebx
lea    0xf71(%rip),%r14
lea    0xeaf(%rip),%rbp
nopw   0x0(%rax,%rax,1)
test   %rbx,%rbx
je     11c0 <get_all_frequencies+0x70>
xor    %edi,%edi
lea    0xe62(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11de <get_all_frequencies+0x8e>
jmp    1231 <get_all_frequencies+0xe1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp),%rdi
lea    0xe34(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,%r12
test   %rax,%rax
je     1236 <get_all_frequencies+0xe6>
mov    %r12,%rdi
mov    %rsp,%rsi
call   1030 <strtod@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    1253 <get_all_frequencies+0x103>
cmp    (%rsp),%r12
je     1272 <get_all_frequencies+0x122>
movsd  %xmm0,(%r15,%rbx,8)
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    $0x16e,%ecx
mov    %ebx,%r8d
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %r13,%rbx
jl     1190 <get_all_frequencies+0x40>
jmp    1242 <get_all_frequencies+0xf2>
add    $0x1,%ebx
jmp    1242 <get_all_frequencies+0xf2>
movq   $0x0,(%r15)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d86(%rip),%rax
mov    (%rax),%ebx
call   1070 <strerror@plt>
mov    %rax,%r8
lea    0xd98(%rip),%rsi
mov    $0x16b,%ecx
jmp    128e <get_all_frequencies+0x13e>
mov    0x2d67(%rip),%rax
mov    (%rax),%ebx
lea    0xe43(%rip),%rsi
mov    $0x16c,%ecx
lea    0xe32(%rip),%r8
lea    0xda4(%rip),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d33(%rip),%rax
movq   $0x0,(%rax)
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" \0A\00"
@errno = global i64 0
@stderr = global i32 0
@.str.1 = [54 x i8] c"[ERROR] (%s:%d: errno: %s) strtod sets errno to zero\0A\00"
@.str.2 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/efferifick/wave/refs/heads/master/src/wave.c\00"
@.str.3 = [5 x i8] c"None\00"
@.str.4 = [47 x i8] c"[ERROR] (%s:%d: errno: %s) no frequency found\0A\00"
@.str.5 = [33 x i8] c"DEBUG %s:%d: frequency[%d]: %lf\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @get_all_frequencies(double* %0, i32 %1, i8* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca double
%11 = alloca i8*
store double* %0, double** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i32 0, i32* %9
store double 0.000000e+00, double* %10
store i8* null, i8** %11
br label %12
12: ; preds = %89, %3
%13 = load i32, i32* %9
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %6
%17 = call i8* @strtok_r(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %17, i8** %7
br label %20
18: ; preds = %12
%19 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %19, i8** %7
br label %20
20: ; preds = %18, %15
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load double*, double** %4
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
store double 0.000000e+00, double* %30
br label %31
31: ; preds = %26, %23, %20
%32 = load i8*, i8** %7
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %79
34: ; preds = %31
%35 = load i8*, i8** %7
%36 = call double @strtod(i8* %35, i8** %11)
store double %36, double* %10
%37 = load i64, i64* @errno
%38 = icmp eq i64 0, %37
br i1 %38, label %50, label %39
39: ; preds = %34
%40 = load i32, i32* @stderr
%41 = load i64, i64* @errno
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
br label %47
44: ; preds = %39
%45 = load i64, i64* @errno
%46 = call i8* @strerror(i64 %45)
br label %47
47: ; preds = %44, %43
%48 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %43 ], [ %46, %44 ]
%49 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 363, i8* %48)
store i64 0, i64* @errno
br label %93
50: ; preds = %34
%51 = load i8*, i8** %7
%52 = load i8*, i8** %11
%53 = icmp ne i8* %51, %52
br i1 %53, label %65, label %54
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = load i64, i64* @errno
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
br label %62
59: ; preds = %54
%60 = load i64, i64* @errno
%61 = call i8* @strerror(i64 %60)
br label %62
62: ; preds = %59, %58
%63 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %58 ], [ %61, %59 ]
%64 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 364, i8* %63)
store i64 0, i64* @errno
br label %93
65: ; preds = %50
%66 = load double, double* %10
%67 = load double*, double** %4
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
%71 = load i32, i32* @stderr
%72 = load i32, i32* %9
%73 = load double*, double** %4
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 366, i32 %72, double %77)
br label %79
79: ; preds = %65, %31
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
store i32 %81, i32* %9
br label %82
82: ; preds = %79
%83 = load i8*, i8** %7
%84 = icmp ne i8* %83, null
br i1 %84, label %85, label %89
85: ; preds = %82
%86 = load i32, i32* %9
%87 = load i32, i32* %5
%88 = icmp slt i32 %86, %87
br label %89
89: ; preds = %85, %82
%90 = phi i1 [ false, %82 ], [ %88, %85 ]
br i1 %90, label %12, label %91
91: ; preds = %89
%92 = load i32, i32* %9
ret i32 %92
93: ; preds = %62, %47
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 @exit(i32 %94)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c" \0A\00"
@errno = global i64 0
@stderr = global i32 0
@.str.1 = [54 x i8] c"[ERROR] (%s:%d: errno: %s) strtod sets errno to zero\0A\00"
@.str.2 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/efferifick/wave/refs/heads/master/src/wave.c\00"
@.str.3 = [5 x i8] c"None\00"
@.str.4 = [47 x i8] c"[ERROR] (%s:%d: errno: %s) no frequency found\0A\00"
@.str.5 = [33 x i8] c"DEBUG %s:%d: frequency[%d]: %lf\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @get_all_frequencies(double* nocapture writeonly %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = sext i32 %1 to i64
br label %9
9: ; preds = %35, %3
%10 = phi i64 [ %40, %35 ], [ 0, %3 ]
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = call i8* @strtok_r(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %4)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %22
15: ; preds = %12
store double 0.000000e+00, double* %0
br label %44
16: ; preds = %9
%17 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %4)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = trunc i64 %10 to i32
%21 = add nuw nsw i32 %20, 1
br label %44
22: ; preds = %12, %16
%23 = phi i8* [ %17, %16 ], [ %13, %12 ]
%24 = call double @strtod(i8* %23, i8** %5)
%25 = load i64, i64* @errno
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = call i8* @strerror(i64 %25)
br label %46
30: ; preds = %22
%31 = load i8*, i8** %5
%32 = icmp eq i8* %23, %31
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* @stderr
br label %46
35: ; preds = %30
%36 = getelementptr inbounds double, double* %0, i64 %10
store double %24, double* %36
%37 = load i32, i32* @stderr
%38 = trunc i64 %10 to i32
%39 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 366, i32 %38, double %24)
%40 = add nuw nsw i64 %10, 1
%41 = icmp slt i64 %40, %8
br i1 %41, label %9, label %42
42: ; preds = %35
%43 = trunc i64 %40 to i32
br label %44
44: ; preds = %15, %42, %19
%45 = phi i32 [ %21, %19 ], [ 1, %15 ], [ %43, %42 ]
ret i32 %45
46: ; preds = %33, %27
%47 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %33 ], [ %29, %27 ]
%48 = phi i32 [ 364, %33 ], [ 363, %27 ]
%49 = phi i8* [ getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), %33 ], [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), %27 ]
%50 = phi i32 [ %34, %33 ], [ %28, %27 ]
%51 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %50, i8* %49, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 %48, i8* %47)
store i64 0, i64* @errno
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
}