#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*/ subcurve(double *, int, double, double);
int /*<<< orphan*/ subline(double *, int, double, double);
void clamp_poles(double *T0, double *T1, int ii, int i, double *pole,
                 int p_offset, int pole_step, int pole_step_i, int order) {
  if (ii < 0) {
    if (order == 3)
      subcurve(pole + p_offset, pole_step_i, T0[i], T1[i]);
    else
      subline(pole + p_offset, pole_step_i, T0[i], T1[i]);
  } else if (i == ii) {
    clamp_poles(T0, T1, ii - 1, i, pole, p_offset, pole_step / 4, pole_step,
                order);
  } else {
    int j, ei = (T0[ii] == T1[ii] ? 1 : order + 1);
    for (j = 0; j < ei; j++)
      clamp_poles(T0, T1, ii - 1, i, pole, p_offset + j * pole_step,
                  pole_step / 4, pole_step_i, order);
  }
}


x86 assembly (clang, -O0):
<clamp_poles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d7 <clamp_poles+0xa7>
cmpl   $0x3,0x20(%rbp)
jne    11a1 <clamp_poles+0x71>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x18(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1050 <subcurve@plt>
jmp    11d2 <clamp_poles+0xa2>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x18(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <subline@plt>
jmp    12ef <clamp_poles+0x1bf>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1230 <clamp_poles+0x100>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    $0x4,%r10d
cltd
idiv   %r10d
mov    -0x30(%rbp),%edx
mov    %eax,%r11d
mov    0x10(%rbp),%r10d
mov    0x20(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <clamp_poles@plt>
jmp    12ea <clamp_poles+0x1ba>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jne    1263 <clamp_poles+0x133>
jp     1263 <clamp_poles+0x133>
mov    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126c <clamp_poles+0x13c>
mov    0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12e5 <clamp_poles+0x1b5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    -0x28(%rbp),%eax
imul   0x10(%rbp),%eax
add    %eax,%r9d
mov    0x10(%rbp),%eax
mov    $0x4,%r10d
cltd
idiv   %r10d
mov    -0x38(%rbp),%edx
mov    %eax,%r11d
mov    0x18(%rbp),%r10d
mov    0x20(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <clamp_poles@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1279 <clamp_poles+0x149>
jmp    12ea <clamp_poles+0x1ba>
jmp    12ef <clamp_poles+0x1bf>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clamp_poles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %rdi,%rbp
mov    0x70(%rsp),%r13d
mov    0x68(%rsp),%r11d
test   %edx,%edx
js     1225 <clamp_poles+0xf5>
mov    0x60(%rsp),%edi
cmp    %r14d,%edx
jne    1182 <clamp_poles+0x52>
test   %r14d,%r14d
jle    1222 <clamp_poles+0xf2>
lea    -0x1(%r14),%edx
lea    0x3(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
sar    $0x2,%eax
mov    %edi,%r11d
mov    %eax,%edi
mov    %edx,%eax
movsd  0x0(%rbp,%rax,8),%xmm0
ucomisd (%rsi,%rax,8),%xmm0
lea    0x1(%r13),%eax
mov    $0x1,%r12d
cmovne %eax,%r12d
cmovp  %eax,%r12d
test   %r12d,%r12d
jle    1213 <clamp_poles+0xe3>
add    $0xffffffff,%edx
lea    0x3(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
sar    $0x2,%eax
mov    %rax,0x8(%rsp)
mov    %rbp,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %edx,0x4(%rsp)
mov    %rdi,0x10(%rsp)
nopl   0x0(%rax)
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    0x20(%rsp),%rsi
mov    %r14d,%ecx
mov    %rbx,%r8
mov    %r15d,%r9d
push   %r13
push   %r11
push   0x20(%rsp)
mov    %r11,%rbp
call   1040 <clamp_poles@plt>
mov    0x30(%rsp),%rdi
mov    %rbp,%r11
mov    0x40(%rsp),%rbp
mov    0x24(%rsp),%edx
add    $0x20,%rsp
add    %edi,%r15d
add    $0xffffffff,%r12d
jne    11d0 <clamp_poles+0xa0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r11d
movslq %r15d,%rax
lea    (%rbx,%rax,8),%rdi
movslq %r14d,%rax
movsd  0x0(%rbp,%rax,8),%xmm0
movsd  (%rsi,%rax,8),%xmm1
mov    %r11d,%esi
add    $0x28,%rsp
cmp    $0x3,%r13d
jne    1256 <clamp_poles+0x126>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <subcurve@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <subline@plt>

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

LLVM IR (-O2):
define void @clamp_poles(double* %0, double* %1, i32 %2, i32 %3, double* %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = icmp slt i32 %2, 0
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = add nsw i32 %3, -1
%13 = icmp eq i32 %2, %3
br i1 %13, label %28, label %32
14: ; preds = %28, %9
%15 = phi i32 [ %7, %9 ], [ %6, %28 ]
%16 = icmp eq i32 %8, 3
%17 = sext i32 %5 to i64
%18 = getelementptr inbounds double, double* %4, i64 %17
%19 = sext i32 %3 to i64
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %1, i64 %19
%23 = load double, double* %22
br i1 %16, label %24, label %26
24: ; preds = %14
%25 = tail call i32 @subcurve(double* %18, i32 %15, double %21, double %23)
br label %54
26: ; preds = %14
%27 = tail call i32 @subline(double* %18, i32 %15, double %21, double %23)
br label %54
28: ; preds = %11
%29 = icmp slt i32 %3, 1
br i1 %29, label %14, label %30
30: ; preds = %28
%31 = sdiv i32 %6, 4
br label %32
32: ; preds = %30, %11
%33 = phi i32 [ %6, %30 ], [ %7, %11 ]
%34 = phi i32 [ %31, %30 ], [ %6, %11 ]
%35 = phi i32 [ %12, %30 ], [ %2, %11 ]
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %1, i64 %36
%40 = load double, double* %39
%41 = fcmp oeq double %38, %40
%42 = add nsw i32 %8, 1
%43 = select i1 %41, i32 1, i32 %42
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %54
45: ; preds = %32
%46 = add nsw i32 %35, -1
%47 = sdiv i32 %34, 4
br label %48
48: ; preds = %45, %48
%49 = phi i32 [ 0, %45 ], [ %52, %48 ]
%50 = mul nsw i32 %49, %34
%51 = add nsw i32 %50, %5
tail call void @clamp_poles(double* %0, double* %1, i32 %46, i32 %3, double* %4, i32 %51, i32 %47, i32 %33, i32 %8)
%52 = add nuw nsw i32 %49, 1
%53 = icmp eq i32 %52, %43
br i1 %53, label %54, label %48
54: ; preds = %48, %32, %24, %26
ret void
}