#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__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, ...);
int /*<<< orphan*/ free(double *);
scalar_t__ realloc(double *, size_t);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
size_t _grow_data(double **data, size_t n) {
  unsigned int ntry, max_tries;
  size_t next_size = n * 2;
  ntry = max_tries = n / 32 - 1;
  double *newdata = (double *)realloc(*data, next_size * sizeof(double));
  while (!newdata && ntry > 0) {
    if (ntry == max_tries) {
      fprintf(
          stderr,
          "[WARN] (%s:%d: errno: %s) "
          "The dataset is large and you are "
          "running low on memory."
          "\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/loicseguin/desc/refs/heads/master/stats.c",
          146, (errno == 0 ? "None" : strerror(errno)));
    }
    next_size = n + ntry * 32;
    ntry--;
    newdata = (double *)realloc(*data, next_size * sizeof(double));
  }
  if (!(newdata)) {
    fprintf(
        stderr,
        "DEBUG %s:%d: "
        "Memory error"
        "\n",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/loicseguin/desc/refs/heads/master/stats.c",
        153);
    errno = 0;
    goto error;
  };
  *data = newdata;
  return next_size;
error:
  if (newdata)
    free(newdata);
  return (size_t)-1;
}


x86 assembly (clang, -O0):
<_grow_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x5,%rax
sub    $0x1,%rax
mov    %eax,-0x20(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
shl    $0x3,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x30(%rbp)
mov    %al,-0x31(%rbp)
jne    11a0 <_grow_data+0x60>
cmpl   $0x0,-0x1c(%rbp)
seta   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11b0 <_grow_data+0x70>
jmp    1256 <_grow_data+0x116>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    121d <_grow_data+0xdd>
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2e09(%rip),%rax
cmpq   $0x0,(%rax)
jne    11e9 <_grow_data+0xa9>
lea    0xef7(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11fc <_grow_data+0xbc>
mov    0x2de8(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x40(%rbp),%r8
lea    0xdf6(%rip),%rsi
lea    0xe42(%rip),%rdx
mov    $0x92,%ecx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x5,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
shl    $0x3,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x30(%rbp)
jmp    1186 <_grow_data+0x46>
cmpq   $0x0,-0x30(%rbp)
jne    1297 <_grow_data+0x157>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
lea    0xddb(%rip),%rdx
mov    $0x99,%ecx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d4d(%rip),%rax
movq   $0x0,(%rax)
jmp    12af <_grow_data+0x16f>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12cb <_grow_data+0x18b>
cmpq   $0x0,-0x30(%rbp)
je     12c3 <_grow_data+0x183>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_grow_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
lea    (%rsi,%rsi,1),%rbx
mov    (%rdi),%rdi
shl    $0x4,%rsi
call   1040 <realloc@plt>
test   %rax,%rax
sete   %cl
jne    121c <_grow_data+0xec>
mov    %r15,%r12
shr    $0x5,%r12
mov    %r12d,%r13d
add    $0xffffffff,%r13d
je     121c <_grow_data+0xec>
mov    0x2e68(%rip),%rax
mov    (%rax),%ebx
mov    0x2e57(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1193 <_grow_data+0x63>
call   1050 <strerror@plt>
mov    %rax,%r8
jmp    119a <_grow_data+0x6a>
lea    0xf3d(%rip),%r8
lea    0xe5f(%rip),%rsi
lea    0xeab(%rip),%rdx
mov    %ebx,%edi
mov    $0x92,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
shl    $0x5,%r13d
mov    %r13,%rbx
add    %r15,%rbx
mov    (%r14),%rdi
lea    0x0(,%rbx,8),%rsi
call   1040 <realloc@plt>
test   %rax,%rax
sete   %cl
jne    121c <_grow_data+0xec>
mov    %r12d,%edx
add    $0xfffffffe,%edx
je     121c <_grow_data+0xec>
lea    -0x3(%r12),%ebp
shl    $0x5,%r12d
add    $0xffffffc0,%r12d
nopl   (%rax)
mov    (%r14),%rdi
mov    %r12d,%ebx
add    %r15,%rbx
lea    0x0(,%rbx,8),%rsi
call   1040 <realloc@plt>
add    $0xffffffff,%ebp
setb   %dl
test   %rax,%rax
sete   %cl
jne    121c <_grow_data+0xec>
add    $0xffffffe0,%r12d
test   %dl,%dl
jne    11f0 <_grow_data+0xc0>
test   %cl,%cl
je     125a <_grow_data+0x12a>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
lea    0xe1c(%rip),%rdx
mov    $0x99,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2d8e(%rip),%rax
movq   $0x0,(%rax)
mov    $0xffffffffffffffff,%rbx
jmp    125d <_grow_data+0x12d>
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [83 x i8] c"[WARN] (%s:%d: errno: %s) The dataset is large and you are running low on memory.\0A\00"
@.str.1 = [132 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/loicseguin/desc/refs/heads/master/stats.c\00"
@errno = global i64 0
@.str.2 = [5 x i8] c"None\00"
@.str.3 = [27 x i8] c"DEBUG %s:%d: Memory error\0A\00"
define i64 @_grow_data(double** %0, i64 %1) {
%3 = alloca i64
%4 = alloca double**
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca double*
store double** %0, double*** %4
store i64 %1, i64* %5
%10 = load i64, i64* %5
%11 = mul i64 %10, 2
store i64 %11, i64* %8
%12 = load i64, i64* %5
%13 = udiv i64 %12, 32
%14 = sub i64 %13, 1
%15 = trunc i64 %14 to i32
store i32 %15, i32* %7
store i32 %15, i32* %6
%16 = load double**, double*** %4
%17 = load double*, double** %16
%18 = load i64, i64* %8
%19 = mul i64 %18, 8
%20 = call i64 @realloc(double* %17, i64 %19)
%21 = inttoptr i64 %20 to double*
store double* %21, double** %9
br label %22
22: ; preds = %45, %2
%23 = load double*, double** %9
%24 = icmp ne double* %23, null
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %6
%27 = icmp ugt i32 %26, 0
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ false, %22 ], [ %27, %25 ]
br i1 %29, label %30, label %59
30: ; preds = %28
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i64, i64* @errno
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
br label %42
39: ; preds = %34
%40 = load i64, i64* @errno
%41 = call i8* @strerror(i64 %40)
br label %42
42: ; preds = %39, %38
%43 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %38 ], [ %41, %39 ]
%44 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.1, i64 0, i64 0), i32 146, i8* %43)
br label %45
45: ; preds = %42, %30
%46 = load i64, i64* %5
%47 = load i32, i32* %6
%48 = mul i32 %47, 32
%49 = zext i32 %48 to i64
%50 = add i64 %46, %49
store i64 %50, i64* %8
%51 = load i32, i32* %6
%52 = add i32 %51, -1
store i32 %52, i32* %6
%53 = load double**, double*** %4
%54 = load double*, double** %53
%55 = load i64, i64* %8
%56 = mul i64 %55, 8
%57 = call i64 @realloc(double* %54, i64 %56)
%58 = inttoptr i64 %57 to double*
store double* %58, double** %9
br label %22
59: ; preds = %28
%60 = load double*, double** %9
%61 = icmp ne double* %60, null
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.1, i64 0, i64 0), i32 153)
store i64 0, i64* @errno
br label %69
65: ; preds = %59
%66 = load double*, double** %9
%67 = load double**, double*** %4
store double* %66, double** %67
%68 = load i64, i64* %8
store i64 %68, i64* %3
br label %76
69: ; preds = %62
%70 = load double*, double** %9
%71 = icmp ne double* %70, null
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load double*, double** %9
%74 = call i32 @free(double* %73)
br label %75
75: ; preds = %72, %69
store i64 -1, i64* %3
br label %76
76: ; preds = %75, %65
%77 = load i64, i64* %3
ret i64 %77
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [83 x i8] c"[WARN] (%s:%d: errno: %s) The dataset is large and you are running low on memory.\0A\00"
@.str.1 = [132 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/loicseguin/desc/refs/heads/master/stats.c\00"
@errno = global i64 0
@.str.2 = [5 x i8] c"None\00"
@.str.3 = [27 x i8] c"DEBUG %s:%d: Memory error\0A\00"
define i64 @_grow_data(double** nocapture %0, i64 %1) {
%3 = shl i64 %1, 1
%4 = lshr i64 %1, 5
%5 = trunc i64 %4 to i32
%6 = add i32 %5, -1
%7 = load double*, double** %0
%8 = shl i64 %1, 4
%9 = tail call i64 @realloc(double* %7, i64 %8)
%10 = icmp eq i64 %9, 0
%11 = icmp ne i32 %6, 0
%12 = and i1 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i64, i64* @errno
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i8* @strerror(i64 %15)
br label %19
19: ; preds = %13, %17
%20 = phi i8* [ %18, %17 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %13 ]
%21 = tail call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.1, i64 0, i64 0), i32 146, i8* %20)
%22 = shl i32 %6, 5
%23 = zext i32 %22 to i64
%24 = add i64 %23, %1
%25 = add i32 %5, -2
%26 = load double*, double** %0
%27 = shl i64 %24, 3
%28 = tail call i64 @realloc(double* %26, i64 %27)
%29 = icmp eq i64 %28, 0
%30 = icmp ne i32 %25, 0
%31 = and i1 %29, %30
br i1 %31, label %32, label %44
32: ; preds = %19, %32
%33 = phi i32 [ %38, %32 ], [ %25, %19 ]
%34 = load double*, double** %0
%35 = shl i32 %33, 5
%36 = zext i32 %35 to i64
%37 = add i64 %36, %1
%38 = add i32 %33, -1
%39 = shl i64 %37, 3
%40 = tail call i64 @realloc(double* %34, i64 %39)
%41 = icmp eq i64 %40, 0
%42 = icmp ne i32 %38, 0
%43 = select i1 %41, i1 %42, i1 false
br i1 %43, label %32, label %44
44: ; preds = %32, %19, %2
%45 = phi i64 [ %9, %2 ], [ %28, %19 ], [ %40, %32 ]
%46 = phi i64 [ %3, %2 ], [ %24, %19 ], [ %37, %32 ]
%47 = phi i1 [ %10, %2 ], [ %29, %19 ], [ %41, %32 ]
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = tail call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.1, i64 0, i64 0), i32 153)
store i64 0, i64* @errno
br label %53
51: ; preds = %44
%52 = inttoptr i64 %45 to double*
store double* %52, double** %0
br label %53
53: ; preds = %48, %51
%54 = phi i64 [ %46, %51 ], [ -1, %48 ]
ret i64 %54
}