#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__ fabs(double const);
int igraph_chebyshev_init(const double *dos, int nos, double eta) {
  int i, ii;
  double err;
  if (nos < 1)
    return 0;
  err = 0.0;
  i = 0;
  for (ii = 1; ii <= nos; ii++) {
    i = nos - ii;
    err += fabs(dos[i]);
    if (err > eta) {
      return i;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<igraph_chebyshev_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    113a <igraph_chebyshev_init+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11ba <igraph_chebyshev_init+0xaa>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11b4 <igraph_chebyshev_init+0xa4>
mov    -0x14(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11a1 <igraph_chebyshev_init+0x91>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ba <igraph_chebyshev_init+0xaa>
jmp    11a6 <igraph_chebyshev_init+0x96>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1150 <igraph_chebyshev_init+0x40>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<igraph_chebyshev_init>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
test   %esi,%esi
jle    1180 <igraph_chebyshev_init+0x70>
mov    %esi,%r14d
mov    %esi,%eax
lea    0x1(%r14),%ecx
lea    (%rdi,%rax,8),%r15
add    $0xfffffffffffffff8,%r15
mov    $0x1,%r12d
sub    %rcx,%r12
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x10(%rsp)
movsd  (%r15,%rbx,8),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
ja     1184 <igraph_chebyshev_init+0x74>
add    $0xffffffffffffffff,%rbx
cmp    %rbx,%r12
jne    1150 <igraph_chebyshev_init+0x40>
xor    %eax,%eax
jmp    118b <igraph_chebyshev_init+0x7b>
lea    (%r14,%rbx,1),%eax
add    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @igraph_chebyshev_init(double* %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %43
14: ; preds = %3
store double 0.000000e+00, double* %10
store i32 0, i32* %8
store i32 1, i32* %9
br label %15
15: ; preds = %38, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %6
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = load i32, i32* %6
%21 = load i32, i32* %9
%22 = sub nsw i32 %20, %21
store i32 %22, i32* %8
%23 = load double*, double** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = call i64 @fabs(double %27)
%29 = sitofp i64 %28 to double
%30 = load double, double* %10
%31 = fadd double %30, %29
store double %31, double* %10
%32 = load double, double* %10
%33 = load double, double* %7
%34 = fcmp ogt double %32, %33
br i1 %34, label %35, label %37
35: ; preds = %19
%36 = load i32, i32* %8
store i32 %36, i32* %4
br label %43
37: ; preds = %19
br label %38
38: ; preds = %37
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %15
41: ; preds = %15
%42 = load i32, i32* %8
store i32 %42, i32* %4
br label %43
43: ; preds = %41, %35, %13
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
define i32 @igraph_chebyshev_init(double* nocapture %0, i32 %1, double %2) {
%4 = icmp slt i32 %1, 1
br i1 %4, label %24, label %5
5: ; preds = %3
%6 = zext i32 %1 to i64
%7 = add nuw i32 %1, 1
%8 = zext i32 %7 to i64
br label %12
9: ; preds = %12
%10 = add nuw nsw i64 %13, 1
%11 = icmp eq i64 %10, %8
br i1 %11, label %24, label %12
12: ; preds = %5, %9
%13 = phi i64 [ 1, %5 ], [ %10, %9 ]
%14 = phi double [ 0.000000e+00, %5 ], [ %20, %9 ]
%15 = sub nsw i64 %6, %13
%16 = getelementptr inbounds double, double* %0, i64 %15
%17 = load double, double* %16
%18 = tail call i64 @fabs(double %17)
%19 = sitofp i64 %18 to double
%20 = fadd double %14, %19
%21 = fcmp ogt double %20, %2
br i1 %21, label %22, label %9
22: ; preds = %12
%23 = trunc i64 %15 to i32
br label %24
24: ; preds = %9, %22, %3
%25 = phi i32 [ 0, %3 ], [ %23, %22 ], [ 0, %9 ]
ret i32 %25
}