#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 */
double c_in_truncated_cylinder(double *, double *, double *, double *, double *,
                               double);
void c_in_fiber(double *points, int nb_points, double *fiber_points,
                double *fiber_tangents, int fiber_nb_points,
                double fiber_radius, signed int *segment_indices) {
  int i, j, k;
  double n1[3], n2[3];
  double min_dst, dst;
  for (j = 0; j < nb_points; j++) {
    min_dst = fiber_radius;
    for (i = 0; i < fiber_nb_points - 1; i++) {
      for (k = 0; k < 3; k++) {
        n1[k] = fiber_tangents[i * 3 + k];
        n2[k] = -fiber_tangents[(i + 1) * 3 + k];
      }
      dst = c_in_truncated_cylinder(&points[j * 3], &fiber_points[i * 3],
                                    &fiber_points[(i + 1) * 3], n1, n2,
                                    fiber_radius);
      if (dst > -1 && dst <= min_dst) {
        segment_indices[j] = i;
        min_dst = dst;
      }
    }
  }
  return;
}


x86 assembly (clang, -O0):
<c_in_fiber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12ae <c_in_fiber+0x19e>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    129b <c_in_fiber+0x18b>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    11e4 <c_in_fiber+0xd4>
mov    -0x20(%rbp),%rax
imul   $0x3,-0x3c(%rbp),%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x44(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
imul   $0x3,%ecx,%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movslq -0x44(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1176 <c_in_fiber+0x66>
mov    -0x8(%rbp),%rdi
imul   $0x3,-0x40(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
imul   $0x3,-0x3c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
imul   $0x3,%eax,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    -0x60(%rbp),%rcx
lea    -0x80(%rbp),%r8
movsd  -0x30(%rbp),%xmm0
call   1030 <c_in_truncated_cylinder@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xdba(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1288 <c_in_fiber+0x178>
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jb     1288 <c_in_fiber+0x178>
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
jmp    128d <c_in_fiber+0x17d>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115e <c_in_fiber+0x4e>
jmp    12a0 <c_in_fiber+0x190>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    113e <c_in_fiber+0x2e>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_in_fiber>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9,0x38(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,0x48(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rdi,0x28(%rsp)
test   %esi,%esi
jle    12d5 <c_in_fiber+0x1c5>
mov    0x8(%rsp),%rax
add    $0xffffffff,%eax
mov    %rax,0x40(%rsp)
mov    %esi,%eax
mov    %rax,0x30(%rsp)
xor    %eax,%eax
mov    %rax,(%rsp)
jmp    118a <c_in_fiber+0x7a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,(%rsp)
cmp    0x30(%rsp),%rcx
je     12d5 <c_in_fiber+0x1c5>
cmpl   $0x2,0x8(%rsp)
jl     1170 <c_in_fiber+0x60>
mov    (%rsp),%rax
lea    (%rax,%rax,2),%eax
mov    0x28(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
mov    %rax,0x50(%rsp)
mov    $0x3,%r15d
mov    0x10(%rsp),%r12
movabs $0x300000000,%rbp
movabs $0x400000000,%r14
movabs $0x500000000,%r13
xor    %ebx,%ebx
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
jmp    1206 <c_in_fiber+0xf6>
nop
movabs $0x300000000,%rax
add    %rax,%r13
add    %rax,%r14
add    %rax,%rbp
add    $0x18,%r12
add    $0x3,%r15
cmp    %rbx,0x40(%rsp)
je     1170 <c_in_fiber+0x60>
mov    0x48(%rsp),%rdx
mov    -0x8(%rdx,%r15,8),%rax
mov    %rax,0x90(%rsp)
movups -0x18(%rdx,%r15,8),%xmm0
movaps %xmm0,0x80(%rsp)
mov    %rbp,%rax
sar    $0x1d,%rax
mov    %r14,%rcx
sar    $0x1d,%rcx
movsd  (%rdx,%rax,1),%xmm0
movhpd (%rdx,%rcx,1),%xmm0
movapd 0xdba(%rip),%xmm1
xorpd  %xmm1,%xmm0
movapd %xmm0,0x60(%rsp)
mov    %r13,%rax
sar    $0x1d,%rax
movsd  (%rdx,%rax,1),%xmm0
xorpd  %xmm1,%xmm0
movlpd %xmm0,0x70(%rsp)
mov    %rbx,0x58(%rsp)
add    $0x1,%rbx
mov    %r15d,%eax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rdx
mov    0x50(%rsp),%rdi
mov    %r12,%rsi
lea    0x80(%rsp),%rcx
lea    0x60(%rsp),%r8
movsd  0x18(%rsp),%xmm0
call   1030 <c_in_truncated_cylinder@plt>
ucomisd 0xd6d(%rip),%xmm0
jbe    11e0 <c_in_fiber+0xd0>
movsd  0x20(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jb     11e0 <c_in_fiber+0xd0>
mov    0x38(%rsp),%rax
mov    (%rsp),%rcx
mov    0x58(%rsp),%rdx
mov    %edx,(%rax,%rcx,4)
movsd  %xmm0,0x20(%rsp)
jmp    11e0 <c_in_fiber+0xd0>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @c_in_fiber(double* %0, i32 %1, double* %2, double* %3, i32 %4, double %5, i32* %6) {
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [3 x double]
%19 = alloca [3 x double]
%20 = alloca double
%21 = alloca double
store double* %0, double** %8
store i32 %1, i32* %9
store double* %2, double** %10
store double* %3, double** %11
store i32 %4, i32* %12
store double %5, double* %13
store i32* %6, i32** %14
store i32 0, i32* %16
br label %22
22: ; preds = %104, %7
%23 = load i32, i32* %16
%24 = load i32, i32* %9
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %107
26: ; preds = %22
%27 = load double, double* %13
store double %27, double* %20
store i32 0, i32* %15
br label %28
28: ; preds = %100, %26
%29 = load i32, i32* %15
%30 = load i32, i32* %12
%31 = sub nsw i32 %30, 1
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %103
33: ; preds = %28
store i32 0, i32* %17
br label %34
34: ; preds = %62, %33
%35 = load i32, i32* %17
%36 = icmp slt i32 %35, 3
br i1 %36, label %37, label %65
37: ; preds = %34
%38 = load double*, double** %11
%39 = load i32, i32* %15
%40 = mul nsw i32 %39, 3
%41 = load i32, i32* %17
%42 = add nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %38, i64 %43
%45 = load double, double* %44
%46 = load i32, i32* %17
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 %47
store double %45, double* %48
%49 = load double*, double** %11
%50 = load i32, i32* %15
%51 = add nsw i32 %50, 1
%52 = mul nsw i32 %51, 3
%53 = load i32, i32* %17
%54 = add nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %49, i64 %55
%57 = load double, double* %56
%58 = fneg double %57
%59 = load i32, i32* %17
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %60
store double %58, double* %61
br label %62
62: ; preds = %37
%63 = load i32, i32* %17
%64 = add nsw i32 %63, 1
store i32 %64, i32* %17
br label %34
65: ; preds = %34
%66 = load double*, double** %8
%67 = load i32, i32* %16
%68 = mul nsw i32 %67, 3
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %66, i64 %69
%71 = load double*, double** %10
%72 = load i32, i32* %15
%73 = mul nsw i32 %72, 3
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %71, i64 %74
%76 = load double*, double** %10
%77 = load i32, i32* %15
%78 = add nsw i32 %77, 1
%79 = mul nsw i32 %78, 3
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %76, i64 %80
%82 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%83 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%84 = load double, double* %13
%85 = call double @c_in_truncated_cylinder(double* %70, double* %75, double* %81, double* %82, double* %83, double %84)
store double %85, double* %21
%86 = load double, double* %21
%87 = fcmp ogt double %86, -1.000000e+00
br i1 %87, label %88, label %99
88: ; preds = %65
%89 = load double, double* %21
%90 = load double, double* %20
%91 = fcmp ole double %89, %90
br i1 %91, label %92, label %99
92: ; preds = %88
%93 = load i32, i32* %15
%94 = load i32*, i32** %14
%95 = load i32, i32* %16
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %94, i64 %96
store i32 %93, i32* %97
%98 = load double, double* %21
store double %98, double* %20
br label %99
99: ; preds = %92, %88, %65
br label %100
100: ; preds = %99
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
store i32 %102, i32* %15
br label %28
103: ; preds = %28
br label %104
104: ; preds = %103
%105 = load i32, i32* %16
%106 = add nsw i32 %105, 1
store i32 %106, i32* %16
br label %22
107: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @c_in_fiber(double* %0, i32 %1, double* %2, double* nocapture %3, i32 %4, double %5, i32* nocapture writeonly %6) {
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %8 to i8*
%10 = alloca [3 x double]
%11 = bitcast [3 x double]* %10 to i8*
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %71
13: ; preds = %7
%14 = add i32 %4, -1
%15 = icmp sgt i32 %4, 1
%16 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%17 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%18 = zext i32 %1 to i64
%19 = zext i32 %14 to i64
%20 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%21 = bitcast [3 x double]* %10 to <2 x double>*
br label %22
22: ; preds = %13, %68
%23 = phi i64 [ 0, %13 ], [ %69, %68 ]
br i1 %15, label %24, label %68
24: ; preds = %22
%25 = mul i64 %23, 3
%26 = and i64 %25, 4294967295
%27 = getelementptr inbounds double, double* %0, i64 %26
%28 = getelementptr inbounds i32, i32* %6, i64 %23
br label %29
29: ; preds = %24, %65
%30 = phi i64 [ 0, %24 ], [ %55, %65 ]
%31 = phi double [ %5, %24 ], [ %66, %65 ]
%32 = mul nuw nsw i64 %30, 3
%33 = getelementptr double, double* %3, i64 %32
%34 = bitcast double* %33 to i8*
%35 = mul i64 %30, 12884901888
%36 = add i64 %35, 12884901888
%37 = ashr exact i64 %36, 32
%38 = getelementptr inbounds double, double* %3, i64 %37
%39 = load double, double* %38
%40 = mul i64 %30, 12884901888
%41 = add i64 %40, 17179869184
%42 = ashr exact i64 %41, 32
%43 = getelementptr inbounds double, double* %3, i64 %42
%44 = load double, double* %43
%45 = insertelement <2 x double> poison, double %39, i64 0
%46 = insertelement <2 x double> %45, double %44, i64 1
%47 = fneg <2 x double> %46
store <2 x double> %47, <2 x double>* %21
%48 = mul i64 %30, 12884901888
%49 = add i64 %48, 21474836480
%50 = ashr exact i64 %49, 32
%51 = getelementptr inbounds double, double* %3, i64 %50
%52 = load double, double* %51
%53 = fneg double %52
store double %53, double* %20
%54 = getelementptr inbounds double, double* %2, i64 %32
%55 = add nuw nsw i64 %30, 1
%56 = mul i64 %55, 3
%57 = and i64 %56, 4294967295
%58 = getelementptr inbounds double, double* %2, i64 %57
%59 = call double @c_in_truncated_cylinder(double* %27, double* %54, double* %58, double* %16, double* %17, double %5)
%60 = fcmp ule double %59, -1.000000e+00
%61 = fcmp ugt double %59, %31
%62 = select i1 %60, i1 true, i1 %61
br i1 %62, label %65, label %63
63: ; preds = %29
%64 = trunc i64 %30 to i32
store i32 %64, i32* %28
br label %65
65: ; preds = %29, %63
%66 = phi double [ %59, %63 ], [ %31, %29 ]
%67 = icmp eq i64 %55, %19
br i1 %67, label %68, label %29
68: ; preds = %65, %22
%69 = add nuw nsw i64 %23, 1
%70 = icmp eq i64 %69, %18
br i1 %70, label %71, label %22
71: ; preds = %68, %7
ret void
}