#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*/ reset_delays(long);
void analyze_times(long dot_millis) {
  static int cursor = 3;
  static long vect[10] = {120L, 120L, 100L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
  long sum = 0L;
  long new_dot_len;
  int counter;
  vect[cursor++] = dot_millis;
  if (cursor >= 10)
    cursor = 0;
  for (counter = 0; counter < 10; counter++) {
    if (!vect[counter])
      return;
    sum += vect[counter];
  }
  new_dot_len = sum / 10;
  reset_delays(new_dot_len);
}


x86 assembly (clang, -O0):
<analyze_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    0x2f02(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ef7(%rip)
movslq %eax,%rcx
lea    0x2efd(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
cmpl   $0xa,0x2ee2(%rip)
jl     115e <analyze_times+0x4e>
movl   $0x0,0x2ed2(%rip)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11af <analyze_times+0x9f>
movslq -0x1c(%rbp),%rcx
lea    0x2ec6(%rip),%rax
cmpq   $0x0,(%rax,%rcx,8)
jne    118a <analyze_times+0x7a>
jmp    11ca <analyze_times+0xba>
movslq -0x1c(%rbp),%rcx
lea    0x2eab(%rip),%rax
mov    (%rax,%rcx,8),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <analyze_times+0x55>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <reset_delays@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze_times>:
push   %rbx
movslq 0x2f18(%rip),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x2f0f(%rip)
lea    0x2f18(%rip),%rcx
mov    %rdi,(%rcx,%rax,8)
cmp    $0x9,%rax
jl     113c <analyze_times+0x2c>
movl   $0x0,0x2ef4(%rip)
mov    0x2efd(%rip),%rcx
test   %rcx,%rcx
je     1200 <analyze_times+0xf0>
mov    0x2ef5(%rip),%rdx
test   %rdx,%rdx
je     1200 <analyze_times+0xf0>
mov    0x2eed(%rip),%rsi
test   %rsi,%rsi
je     1200 <analyze_times+0xf0>
mov    0x2ee5(%rip),%rdi
test   %rdi,%rdi
je     1200 <analyze_times+0xf0>
mov    0x2edd(%rip),%r8
test   %r8,%r8
je     1200 <analyze_times+0xf0>
mov    0x2ed9(%rip),%r9
test   %r9,%r9
je     1200 <analyze_times+0xf0>
mov    0x2ed5(%rip),%r10
test   %r10,%r10
je     1200 <analyze_times+0xf0>
mov    0x2ed1(%rip),%r11
test   %r11,%r11
je     1200 <analyze_times+0xf0>
mov    0x2ecd(%rip),%rbx
test   %rbx,%rbx
je     1200 <analyze_times+0xf0>
mov    0x2ec9(%rip),%rax
test   %rax,%rax
je     1200 <analyze_times+0xf0>
add    %rcx,%rdx
add    %rdx,%rsi
add    %rsi,%rdi
add    %rdi,%r8
add    %r8,%r9
add    %r9,%r10
add    %r10,%r11
add    %r11,%rbx
add    %rbx,%rax
movabs $0x6666666666666667,%rcx
66 66 66
imul   %rcx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x2,%rdx
add    %rdx,%rdi
pop    %rbx
jmp    1030 <reset_delays@plt>
pop    %rbx
ret

LLVM IR (-O0):
@analyze_times.cursor = internal global i32 3
@analyze_times.vect = internal global [10 x i64] [i64 120, i64 120, i64 100, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0]
define void @analyze_times(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i64 %0, i64* %2
store i64 0, i64* %3
%6 = load i64, i64* %2
%7 = load i32, i32* @analyze_times.cursor
%8 = add nsw i32 %7, 1
store i32 %8, i32* @analyze_times.cursor
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds [10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 %9
store i64 %6, i64* %10
%11 = load i32, i32* @analyze_times.cursor
%12 = icmp sge i32 %11, 10
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 0, i32* @analyze_times.cursor
br label %14
14: ; preds = %13, %1
store i32 0, i32* %5
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 %20
%22 = load i64, i64* %21
%23 = icmp ne i64 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %18
br label %40
25: ; preds = %18
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 %27
%29 = load i64, i64* %28
%30 = load i64, i64* %3
%31 = add nsw i64 %30, %29
store i64 %31, i64* %3
br label %32
32: ; preds = %25
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %15
35: ; preds = %15
%36 = load i64, i64* %3
%37 = sdiv i64 %36, 10
store i64 %37, i64* %4
%38 = load i64, i64* %4
%39 = call i32 @reset_delays(i64 %38)
br label %40
40: ; preds = %35, %24
ret void
}

LLVM IR (-O2):
@analyze_times.cursor = internal unnamed_addr global i32 3
@analyze_times.vect = internal unnamed_addr global [10 x i64] [i64 120, i64 120, i64 100, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0]
define void @analyze_times(i64 %0) {
%2 = load i32, i32* @analyze_times.cursor
%3 = add nsw i32 %2, 1
store i32 %3, i32* @analyze_times.cursor
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds [10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 %4
store i64 %0, i64* %5
%6 = icmp sgt i32 %2, 8
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* @analyze_times.cursor
br label %8
8: ; preds = %7, %1
%9 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %50, label %11
11: ; preds = %8
%12 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %50, label %14
14: ; preds = %11
%15 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %50, label %17
17: ; preds = %14
%18 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %50, label %20
20: ; preds = %17
%21 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %50, label %23
23: ; preds = %20
%24 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 5)
%25 = icmp eq i64 %24, 0
br i1 %25, label %50, label %26
26: ; preds = %23
%27 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %50, label %29
29: ; preds = %26
%30 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 7)
%31 = icmp eq i64 %30, 0
br i1 %31, label %50, label %32
32: ; preds = %29
%33 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 8)
%34 = icmp eq i64 %33, 0
br i1 %34, label %50, label %35
35: ; preds = %32
%36 = load i64, i64* getelementptr inbounds ([10 x i64], [10 x i64]* @analyze_times.vect, i64 0, i64 9)
%37 = icmp eq i64 %36, 0
br i1 %37, label %50, label %38
38: ; preds = %35
%39 = add nsw i64 %12, %9
%40 = add nsw i64 %15, %39
%41 = add nsw i64 %18, %40
%42 = add nsw i64 %21, %41
%43 = add nsw i64 %24, %42
%44 = add nsw i64 %27, %43
%45 = add nsw i64 %30, %44
%46 = add nsw i64 %33, %45
%47 = add nsw i64 %36, %46
%48 = sdiv i64 %47, 10
%49 = tail call i32 @reset_delays(i64 %48)
br label %50
50: ; preds = %8, %11, %14, %17, %20, %23, %26, %29, %32, %35, %38
ret void
}