#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*/ error_handler(char *);
double fabs(double);
int inside_edge(double, double, double, double, double, double);
int clip_2dx2d(const double lon1_in[], const double lat1_in[], int n1_in,
               const double lon2_in[], const double lat2_in[], int n2_in,
               double lon_out[], double lat_out[]) {
  double lon_tmp[50], lat_tmp[50];
  double x1_0, y1_0, x1_1, y1_1, x2_0, y2_0, x2_1, y2_1;
  double dx1, dy1, dx2, dy2, determ, ds1, ds2;
  int i_out, n_out, inside_last, inside, i1, i2;
  n_out = n1_in;
  for (i1 = 0; i1 < n1_in; i1++) {
    lon_tmp[i1] = lon1_in[i1];
    lat_tmp[i1] = lat1_in[i1];
  }
  x2_0 = lon2_in[n2_in - 1];
  y2_0 = lat2_in[n2_in - 1];
  for (i2 = 0; i2 < n2_in; i2++) {
    x2_1 = lon2_in[i2];
    y2_1 = lat2_in[i2];
    x1_0 = lon_tmp[n_out - 1];
    y1_0 = lat_tmp[n_out - 1];
    inside_last = inside_edge(x2_0, y2_0, x2_1, y2_1, x1_0, y1_0);
    for (i1 = 0, i_out = 0; i1 < n_out; i1++) {
      x1_1 = lon_tmp[i1];
      y1_1 = lat_tmp[i1];
      if ((inside = inside_edge(x2_0, y2_0, x2_1, y2_1, x1_1, y1_1)) !=
          inside_last) {
        dy1 = y1_1 - y1_0;
        dy2 = y2_1 - y2_0;
        dx1 = x1_1 - x1_0;
        dx2 = x2_1 - x2_0;
        ds1 = y1_0 * x1_1 - y1_1 * x1_0;
        ds2 = y2_0 * x2_1 - y2_1 * x2_0;
        determ = dy2 * dx1 - dy1 * dx2;
        if (fabs(determ) < (1.0e-30)) {
          error_handler("the line between <x1_0,y1_0> and  <x1_1,y1_1> should "
                        "not parallel to "
                        "the line between <x2_0,y2_0> and  <x2_1,y2_1>");
        }
        lon_out[i_out] = (dx2 * ds1 - dx1 * ds2) / determ;
        lat_out[i_out++] = (dy2 * ds1 - dy1 * ds2) / determ;
      }
      if (inside) {
        lon_out[i_out] = x1_1;
        lat_out[i_out++] = y1_1;
      }
      x1_0 = x1_1;
      y1_0 = y1_1;
      inside_last = inside;
    }
    if (!(n_out = i_out))
      return 0;
    for (i1 = 0; i1 < n_out; i1++) {
      lon_tmp[i1] = lon_out[i1];
      lat_tmp[i1] = lat_out[i1];
    }
    x2_0 = x2_1;
    y2_0 = y2_1;
  }
  return (n_out);
}


x86 assembly (clang, -O0):
<clip_2dx2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3e0(%rbp)
movl   $0x0,-0x3ec(%rbp)
mov    -0x3ec(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c0 <clip_2dx2d+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x3ec(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3ec(%rbp),%rax
movsd  %xmm0,-0x1d0(%rbp,%rax,8)
ff ff
mov    -0x18(%rbp),%rax
movslq -0x3ec(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3ec(%rbp),%rax
movsd  %xmm0,-0x360(%rbp,%rax,8)
ff ff
mov    -0x3ec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ec(%rbp)
jmp    115d <clip_2dx2d+0x3d>
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x388(%rbp)
ff
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x390(%rbp)
ff
movl   $0x0,-0x3f0(%rbp)
mov    -0x3f0(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    16bd <clip_2dx2d+0x59d>
mov    -0x28(%rbp),%rax
movslq -0x3f0(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x398(%rbp)
ff
mov    -0x30(%rbp),%rax
movslq -0x3f0(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x3a0(%rbp)
ff
mov    -0x3e0(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x1d0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x368(%rbp)
ff
mov    -0x3e0(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x360(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x370(%rbp)
ff
movsd  -0x388(%rbp),%xmm0
ff
movsd  -0x390(%rbp),%xmm1
ff
movsd  -0x398(%rbp),%xmm2
ff
movsd  -0x3a0(%rbp),%xmm3
ff
movsd  -0x368(%rbp),%xmm4
ff
movsd  -0x370(%rbp),%xmm5
ff
call   1040 <inside_edge@plt>
mov    %eax,-0x3e4(%rbp)
movl   $0x0,-0x3ec(%rbp)
movl   $0x0,-0x3dc(%rbp)
mov    -0x3ec(%rbp),%eax
cmp    -0x3e0(%rbp),%eax
jge    15f8 <clip_2dx2d+0x4d8>
movslq -0x3ec(%rbp),%rax
movsd  -0x1d0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x378(%rbp)
ff
movslq -0x3ec(%rbp),%rax
movsd  -0x360(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x380(%rbp)
ff
movsd  -0x388(%rbp),%xmm0
ff
movsd  -0x390(%rbp),%xmm1
ff
movsd  -0x398(%rbp),%xmm2
ff
movsd  -0x3a0(%rbp),%xmm3
ff
movsd  -0x378(%rbp),%xmm4
ff
movsd  -0x380(%rbp),%xmm5
ff
call   1040 <inside_edge@plt>
mov    %eax,-0x3e8(%rbp)
cmp    -0x3e4(%rbp),%eax
je     156e <clip_2dx2d+0x44e>
movsd  -0x380(%rbp),%xmm0
ff
subsd  -0x370(%rbp),%xmm0
ff
movsd  %xmm0,-0x3b0(%rbp)
ff
movsd  -0x3a0(%rbp),%xmm0
ff
subsd  -0x390(%rbp),%xmm0
ff
movsd  %xmm0,-0x3c0(%rbp)
ff
movsd  -0x378(%rbp),%xmm0
ff
subsd  -0x368(%rbp),%xmm0
ff
movsd  %xmm0,-0x3a8(%rbp)
ff
movsd  -0x398(%rbp),%xmm0
ff
subsd  -0x388(%rbp),%xmm0
ff
movsd  %xmm0,-0x3b8(%rbp)
ff
movsd  -0x370(%rbp),%xmm0
ff
movsd  -0x378(%rbp),%xmm2
ff
movsd  -0x380(%rbp),%xmm1
ff
mulsd  -0x368(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x3d0(%rbp)
ff
movsd  -0x390(%rbp),%xmm0
ff
movsd  -0x398(%rbp),%xmm2
ff
movsd  -0x3a0(%rbp),%xmm1
ff
mulsd  -0x388(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x3d8(%rbp)
ff
movsd  -0x3c0(%rbp),%xmm0
ff
movsd  -0x3a8(%rbp),%xmm2
ff
movsd  -0x3b0(%rbp),%xmm1
ff
mulsd  -0x3b8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x3c8(%rbp)
ff
movsd  -0x3c8(%rbp),%xmm1
ff
movaps 0xb7f(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xb63(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    14b3 <clip_2dx2d+0x393>
lea    0xb72(%rip),%rdi
call   1030 <error_handler@plt>
movsd  -0x3b8(%rbp),%xmm0
ff
movsd  -0x3d0(%rbp),%xmm2
ff
movsd  -0x3a8(%rbp),%xmm1
ff
mulsd  -0x3d8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x3c8(%rbp),%xmm0
ff
mov    0x10(%rbp),%rax
movslq -0x3dc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x3c0(%rbp),%xmm0
ff
movsd  -0x3d0(%rbp),%xmm2
ff
movsd  -0x3b0(%rbp),%xmm1
ff
mulsd  -0x3d8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x3c8(%rbp),%xmm0
ff
mov    0x18(%rbp),%rax
mov    -0x3dc(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x3dc(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x3e8(%rbp)
je     15b8 <clip_2dx2d+0x498>
movsd  -0x378(%rbp),%xmm0
ff
mov    0x10(%rbp),%rax
movslq -0x3dc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x380(%rbp),%xmm0
ff
mov    0x18(%rbp),%rax
mov    -0x3dc(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x3dc(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x378(%rbp),%xmm0
ff
movsd  %xmm0,-0x368(%rbp)
ff
movsd  -0x380(%rbp),%xmm0
ff
movsd  %xmm0,-0x370(%rbp)
ff
mov    -0x3e8(%rbp),%eax
mov    %eax,-0x3e4(%rbp)
mov    -0x3ec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ec(%rbp)
jmp    12c4 <clip_2dx2d+0x1a4>
mov    -0x3dc(%rbp),%eax
mov    %eax,-0x3e0(%rbp)
cmp    $0x0,%eax
jne    1619 <clip_2dx2d+0x4f9>
movl   $0x0,-0x4(%rbp)
jmp    16c6 <clip_2dx2d+0x5a6>
movl   $0x0,-0x3ec(%rbp)
mov    -0x3ec(%rbp),%eax
cmp    -0x3e0(%rbp),%eax
jge    1689 <clip_2dx2d+0x569>
mov    0x10(%rbp),%rax
movslq -0x3ec(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3ec(%rbp),%rax
movsd  %xmm0,-0x1d0(%rbp,%rax,8)
ff ff
mov    0x18(%rbp),%rax
movslq -0x3ec(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3ec(%rbp),%rax
movsd  %xmm0,-0x360(%rbp,%rax,8)
ff ff
mov    -0x3ec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ec(%rbp)
jmp    1623 <clip_2dx2d+0x503>
movsd  -0x398(%rbp),%xmm0
ff
movsd  %xmm0,-0x388(%rbp)
ff
movsd  -0x3a0(%rbp),%xmm0
ff
movsd  %xmm0,-0x390(%rbp)
ff
mov    -0x3f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f0(%rbp)
jmp    11fe <clip_2dx2d+0xde>
mov    -0x3e0(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clip_2dx2d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3c8,%rsp
mov    %r9d,%r14d
mov    %r8,0x48(%rsp)
mov    %rcx,0x40(%rsp)
mov    %edx,%ebp
test   %edx,%edx
jle    1183 <clip_2dx2d+0x53>
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %ebp,%ebx
shl    $0x3,%rbx
lea    0x230(%rsp),%rdi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
lea    0xa0(%rsp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
test   %r14d,%r14d
jle    14ee <clip_2dx2d+0x3be>
mov    0x408(%rsp),%rbx
lea    -0x1(%r14),%eax
cltq
mov    0x48(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm3
mov    0x40(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
mov    %r14d,%eax
mov    %rax,0x60(%rsp)
xor    %r12d,%r12d
jmp    11d7 <clip_2dx2d+0xa7>
nopl   0x0(%rax,%rax,1)
mov    0x68(%rsp),%r12
add    $0x1,%r12
movaps %xmm2,%xmm0
cmp    0x60(%rsp),%r12
je     14ee <clip_2dx2d+0x3be>
movsd  %xmm0,0x18(%rsp)
mov    %rbx,%r15
mov    0x40(%rsp),%rax
movsd  (%rax,%r12,8),%xmm2
mov    0x48(%rsp),%rax
movsd  (%rax,%r12,8),%xmm6
movslq %ebp,%rbx
movsd  0x228(%rsp,%rbx,8),%xmm4
movsd  0x98(%rsp,%rbx,8),%xmm5
movaps %xmm3,%xmm1
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm6,(%rsp)
movaps %xmm6,%xmm3
movsd  %xmm4,0x20(%rsp)
movsd  %xmm5,0x28(%rsp)
call   1050 <inside_edge@plt>
test   %ebx,%ebx
jle    14ec <clip_2dx2d+0x3bc>
mov    %eax,%r14d
mov    %r12,0x68(%rsp)
movsd  (%rsp),%xmm3
movapd %xmm3,%xmm0
movsd  0x10(%rsp),%xmm4
subsd  %xmm4,%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm0
movsd  0x18(%rsp),%xmm5
subsd  %xmm5,%xmm0
movsd  %xmm0,0x50(%rsp)
movapd %xmm5,%xmm0
mulsd  %xmm3,%xmm0
movapd %xmm4,%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x78(%rsp)
mov    %ebp,%r13d
xor    %r12d,%r12d
xor    %ebp,%ebp
mov    %r15,%rbx
movapd %xmm5,%xmm0
movapd %xmm4,%xmm1
jmp    135b <clip_2dx2d+0x22b>
nopl   0x0(%rax,%rax,1)
mulsd  %xmm6,%xmm7
mulsd  %xmm10,%xmm4
subsd  %xmm7,%xmm4
xorpd  0xd3b(%rip),%xmm2
movsd  0x78(%rsp),%xmm1
mulsd  %xmm1,%xmm5
movapd %xmm9,%xmm0
mulsd  %xmm4,%xmm0
subsd  %xmm5,%xmm0
divsd  %xmm3,%xmm0
movslq %ebp,%rax
mov    0x400(%rsp),%rcx
movsd  %xmm0,(%rcx,%rax,8)
mulsd  %xmm1,%xmm2
mulsd  %xmm8,%xmm4
addsd  %xmm2,%xmm4
divsd  %xmm3,%xmm4
lea    0x1(%rax),%ebp
movsd  %xmm4,(%rbx,%rax,8)
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm3
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
test   %r15d,%r15d
je     133e <clip_2dx2d+0x20e>
movslq %ebp,%rax
mov    0x400(%rsp),%rcx
movsd  %xmm10,(%rcx,%rax,8)
lea    0x1(%rax),%ebp
movsd  %xmm6,(%rbx,%rax,8)
add    $0x1,%r12
mov    %r15d,%r14d
movsd  %xmm10,0x20(%rsp)
movsd  %xmm6,0x28(%rsp)
cmp    %r12,%r13
je     14a0 <clip_2dx2d+0x370>
movsd  0x230(%rsp,%r12,8),%xmm4
movsd  0xa0(%rsp,%r12,8),%xmm5
movsd  %xmm4,0x38(%rsp)
movsd  %xmm5,0x30(%rsp)
call   1050 <inside_edge@plt>
mov    %eax,%r15d
cmp    %r14d,%eax
jne    13c0 <clip_2dx2d+0x290>
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm3
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x38(%rsp),%xmm10
movsd  0x30(%rsp),%xmm6
test   %r15d,%r15d
jne    1325 <clip_2dx2d+0x1f5>
jmp    133e <clip_2dx2d+0x20e>
nopw   0x0(%rax,%rax,1)
movsd  0x30(%rsp),%xmm6
movapd %xmm6,%xmm2
movsd  0x28(%rsp),%xmm4
subsd  %xmm4,%xmm2
movsd  0x38(%rsp),%xmm10
movapd %xmm10,%xmm5
movsd  0x20(%rsp),%xmm7
subsd  %xmm7,%xmm5
movsd  0x50(%rsp),%xmm9
movapd %xmm9,%xmm0
mulsd  %xmm2,%xmm0
movsd  0x58(%rsp),%xmm8
movapd %xmm8,%xmm3
mulsd  %xmm5,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
andpd  0xbf6(%rip),%xmm0
movsd  0xbfe(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12b0 <clip_2dx2d+0x180>
lea    0xbf5(%rip),%rdi
movapd %xmm2,0x90(%rsp)
movapd %xmm3,0x80(%rsp)
movsd  %xmm5,0x70(%rsp)
call   1030 <error_handler@plt>
movsd  0x70(%rsp),%xmm5
movapd 0x80(%rsp),%xmm3
movapd 0x90(%rsp),%xmm2
movsd  0x20(%rsp),%xmm7
movsd  0x30(%rsp),%xmm6
movsd  0x38(%rsp),%xmm10
movsd  0x28(%rsp),%xmm4
movsd  0x50(%rsp),%xmm9
movsd  0x58(%rsp),%xmm8
jmp    12b0 <clip_2dx2d+0x180>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
je     14ec <clip_2dx2d+0x3bc>
jle    11c0 <clip_2dx2d+0x90>
mov    %ebp,%r14d
shl    $0x3,%r14
lea    0x230(%rsp),%rdi
mov    0x400(%rsp),%rsi
mov    %r14,%rdx
call   1040 <memcpy@plt>
lea    0xa0(%rsp),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <memcpy@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
jmp    11c0 <clip_2dx2d+0x90>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x3c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [115 x i8] c"the line between <x1_0,y1_0> and <x1_1,y1_1> should not parallel to the line between <x2_0,y2_0> and <x2_1,y2_1>\00"
define i32 @clip_2dx2d(double* %0, double* %1, i32 %2, double* %3, double* %4, i32 %5, double* %6, double* %7) {
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca double*
%17 = alloca double*
%18 = alloca [50 x double]
%19 = alloca [50 x double]
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca i32
%40 = alloca i32
store double* %0, double** %10
store double* %1, double** %11
store i32 %2, i32* %12
store double* %3, double** %13
store double* %4, double** %14
store i32 %5, i32* %15
store double* %6, double** %16
store double* %7, double** %17
%41 = load i32, i32* %12
store i32 %41, i32* %36
store i32 0, i32* %39
br label %42
42: ; preds = %63, %8
%43 = load i32, i32* %39
%44 = load i32, i32* %12
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %66
46: ; preds = %42
%47 = load double*, double** %10
%48 = load i32, i32* %39
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = load i32, i32* %39
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 %53
store double %51, double* %54
%55 = load double*, double** %11
%56 = load i32, i32* %39
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = load i32, i32* %39
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 %61
store double %59, double* %62
br label %63
63: ; preds = %46
%64 = load i32, i32* %39
%65 = add nsw i32 %64, 1
store i32 %65, i32* %39
br label %42
66: ; preds = %42
%67 = load double*, double** %13
%68 = load i32, i32* %15
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %67, i64 %70
%72 = load double, double* %71
store double %72, double* %24
%73 = load double*, double** %14
%74 = load i32, i32* %15
%75 = sub nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %73, i64 %76
%78 = load double, double* %77
store double %78, double* %25
store i32 0, i32* %40
br label %79
79: ; preds = %254, %66
%80 = load i32, i32* %40
%81 = load i32, i32* %15
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %257
83: ; preds = %79
%84 = load double*, double** %13
%85 = load i32, i32* %40
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
store double %88, double* %26
%89 = load double*, double** %14
%90 = load i32, i32* %40
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
store double %93, double* %27
%94 = load i32, i32* %36
%95 = sub nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 %96
%98 = load double, double* %97
store double %98, double* %20
%99 = load i32, i32* %36
%100 = sub nsw i32 %99, 1
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 %101
%103 = load double, double* %102
store double %103, double* %21
%104 = load double, double* %24
%105 = load double, double* %25
%106 = load double, double* %26
%107 = load double, double* %27
%108 = load double, double* %20
%109 = load double, double* %21
%110 = call i32 @inside_edge(double %104, double %105, double %106, double %107, double %108, double %109)
store i32 %110, i32* %37
store i32 0, i32* %39
store i32 0, i32* %35
br label %111
111: ; preds = %219, %83
%112 = load i32, i32* %39
%113 = load i32, i32* %36
%114 = icmp slt i32 %112, %113
br i1 %114, label %115, label %222
115: ; preds = %111
%116 = load i32, i32* %39
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 %117
%119 = load double, double* %118
store double %119, double* %22
%120 = load i32, i32* %39
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 %121
%123 = load double, double* %122
store double %123, double* %23
%124 = load double, double* %24
%125 = load double, double* %25
%126 = load double, double* %26
%127 = load double, double* %27
%128 = load double, double* %22
%129 = load double, double* %23
%130 = call i32 @inside_edge(double %124, double %125, double %126, double %127, double %128, double %129)
store i32 %130, i32* %38
%131 = load i32, i32* %37
%132 = icmp ne i32 %130, %131
br i1 %132, label %133, label %200
133: ; preds = %115
%134 = load double, double* %23
%135 = load double, double* %21
%136 = fsub double %134, %135
store double %136, double* %29
%137 = load double, double* %27
%138 = load double, double* %25
%139 = fsub double %137, %138
store double %139, double* %31
%140 = load double, double* %22
%141 = load double, double* %20
%142 = fsub double %140, %141
store double %142, double* %28
%143 = load double, double* %26
%144 = load double, double* %24
%145 = fsub double %143, %144
store double %145, double* %30
%146 = load double, double* %21
%147 = load double, double* %22
%148 = load double, double* %23
%149 = load double, double* %20
%150 = fmul double %148, %149
%151 = fneg double %150
%152 = call double @llvm.fmuladd.f64(double %146, double %147, double %151)
store double %152, double* %33
%153 = load double, double* %25
%154 = load double, double* %26
%155 = load double, double* %27
%156 = load double, double* %24
%157 = fmul double %155, %156
%158 = fneg double %157
%159 = call double @llvm.fmuladd.f64(double %153, double %154, double %158)
store double %159, double* %34
%160 = load double, double* %31
%161 = load double, double* %28
%162 = load double, double* %29
%163 = load double, double* %30
%164 = fmul double %162, %163
%165 = fneg double %164
%166 = call double @llvm.fmuladd.f64(double %160, double %161, double %165)
store double %166, double* %32
%167 = load double, double* %32
%168 = call double @llvm.fabs.f64(double %167)
%169 = fcmp olt double %168, 1.000000e-30
br i1 %169, label %170, label %172
170: ; preds = %133
%171 = call i32 @error_handler(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0))
br label %172
172: ; preds = %170, %133
%173 = load double, double* %30
%174 = load double, double* %33
%175 = load double, double* %28
%176 = load double, double* %34
%177 = fmul double %175, %176
%178 = fneg double %177
%179 = call double @llvm.fmuladd.f64(double %173, double %174, double %178)
%180 = load double, double* %32
%181 = fdiv double %179, %180
%182 = load double*, double** %16
%183 = load i32, i32* %35
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds double, double* %182, i64 %184
store double %181, double* %185
%186 = load double, double* %31
%187 = load double, double* %33
%188 = load double, double* %29
%189 = load double, double* %34
%190 = fmul double %188, %189
%191 = fneg double %190
%192 = call double @llvm.fmuladd.f64(double %186, double %187, double %191)
%193 = load double, double* %32
%194 = fdiv double %192, %193
%195 = load double*, double** %17
%196 = load i32, i32* %35
%197 = add nsw i32 %196, 1
store i32 %197, i32* %35
%198 = sext i32 %196 to i64
%199 = getelementptr inbounds double, double* %195, i64 %198
store double %194, double* %199
br label %200
200: ; preds = %172, %115
%201 = load i32, i32* %38
%202 = icmp ne i32 %201, 0
br i1 %202, label %203, label %215
203: ; preds = %200
%204 = load double, double* %22
%205 = load double*, double** %16
%206 = load i32, i32* %35
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds double, double* %205, i64 %207
store double %204, double* %208
%209 = load double, double* %23
%210 = load double*, double** %17
%211 = load i32, i32* %35
%212 = add nsw i32 %211, 1
store i32 %212, i32* %35
%213 = sext i32 %211 to i64
%214 = getelementptr inbounds double, double* %210, i64 %213
store double %209, double* %214
br label %215
215: ; preds = %203, %200
%216 = load double, double* %22
store double %216, double* %20
%217 = load double, double* %23
store double %217, double* %21
%218 = load i32, i32* %38
store i32 %218, i32* %37
br label %219
219: ; preds = %215
%220 = load i32, i32* %39
%221 = add nsw i32 %220, 1
store i32 %221, i32* %39
br label %111
222: ; preds = %111
%223 = load i32, i32* %35
store i32 %223, i32* %36
%224 = icmp ne i32 %223, 0
br i1 %224, label %226, label %225
225: ; preds = %222
store i32 0, i32* %9
br label %259
226: ; preds = %222
store i32 0, i32* %39
br label %227
227: ; preds = %248, %226
%228 = load i32, i32* %39
%229 = load i32, i32* %36
%230 = icmp slt i32 %228, %229
br i1 %230, label %231, label %251
231: ; preds = %227
%232 = load double*, double** %16
%233 = load i32, i32* %39
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds double, double* %232, i64 %234
%236 = load double, double* %235
%237 = load i32, i32* %39
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 %238
store double %236, double* %239
%240 = load double*, double** %17
%241 = load i32, i32* %39
%242 = sext i32 %241 to i64
%243 = getelementptr inbounds double, double* %240, i64 %242
%244 = load double, double* %243
%245 = load i32, i32* %39
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 %246
store double %244, double* %247
br label %248
248: ; preds = %231
%249 = load i32, i32* %39
%250 = add nsw i32 %249, 1
store i32 %250, i32* %39
br label %227
251: ; preds = %227
%252 = load double, double* %26
store double %252, double* %24
%253 = load double, double* %27
store double %253, double* %25
br label %254
254: ; preds = %251
%255 = load i32, i32* %40
%256 = add nsw i32 %255, 1
store i32 %256, i32* %40
br label %79
257: ; preds = %79
%258 = load i32, i32* %36
store i32 %258, i32* %9
br label %259
259: ; preds = %257, %225
%260 = load i32, i32* %9
ret i32 %260
}

LLVM IR (-O2):
@.str = [115 x i8] c"the line between <x1_0,y1_0> and <x1_1,y1_1> should not parallel to the line between <x2_0,y2_0> and <x2_1,y2_1>\00"
define i32 @clip_2dx2d(double* nocapture %0, double* nocapture %1, i32 %2, double* nocapture %3, double* nocapture %4, i32 %5, double* nocapture %6, double* nocapture %7) {
%9 = bitcast double* %6 to i8*
%10 = bitcast double* %7 to i8*
%11 = alloca [50 x double]
%12 = bitcast [50 x double]* %11 to i8*
%13 = alloca [50 x double]
%14 = bitcast [50 x double]* %13 to i8*
%15 = icmp sgt i32 %2, 0
br i1 %15, label %16, label %21
16: ; preds = %8
%17 = bitcast double* %1 to i8*
%18 = bitcast double* %0 to i8*
%19 = zext i32 %2 to i64
%20 = shl nuw nsw i64 %19, 3
br label %21
21: ; preds = %16, %8
%22 = add nsw i32 %5, -1
%23 = sext i32 %22 to i64
%24 = icmp sgt i32 %5, 0
br i1 %24, label %25, label %114
25: ; preds = %21
%26 = getelementptr inbounds double, double* %4, i64 %23
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %3, i64 %23
%29 = load double, double* %28
%30 = zext i32 %5 to i64
br label %31
31: ; preds = %25, %111
%32 = phi i64 [ 0, %25 ], [ %112, %111 ]
%33 = phi i32 [ %2, %25 ], [ %101, %111 ]
%34 = phi double [ %29, %25 ], [ %37, %111 ]
%35 = phi double [ %27, %25 ], [ %39, %111 ]
%36 = getelementptr inbounds double, double* %3, i64 %32
%37 = load double, double* %36
%38 = getelementptr inbounds double, double* %4, i64 %32
%39 = load double, double* %38
%40 = add nsw i32 %33, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [50 x double], [50 x double]* %11, i64 0, i64 %41
%43 = load double, double* %42
%44 = getelementptr inbounds [50 x double], [50 x double]* %13, i64 0, i64 %41
%45 = load double, double* %44
%46 = tail call i32 @inside_edge(double %34, double %35, double %37, double %39, double %43, double %45)
%47 = icmp sgt i32 %33, 0
br i1 %47, label %48, label %114
48: ; preds = %31
%49 = fsub double %39, %35
%50 = fsub double %37, %34
%51 = fneg double %39
%52 = fmul double %34, %51
%53 = tail call double @llvm.fmuladd.f64(double %35, double %37, double %52)
%54 = zext i32 %33 to i64
br label %55
55: ; preds = %48, %100
%56 = phi i64 [ 0, %48 ], [ %102, %100 ]
%57 = phi i32 [ %46, %48 ], [ %65, %100 ]
%58 = phi i32 [ 0, %48 ], [ %101, %100 ]
%59 = phi double [ %43, %48 ], [ %62, %100 ]
%60 = phi double [ %45, %48 ], [ %64, %100 ]
%61 = getelementptr inbounds [50 x double], [50 x double]* %11, i64 0, i64 %56
%62 = load double, double* %61
%63 = getelementptr inbounds [50 x double], [50 x double]* %13, i64 0, i64 %56
%64 = load double, double* %63
%65 = tail call i32 @inside_edge(double %34, double %35, double %37, double %39, double %62, double %64)
%66 = icmp eq i32 %65, %57
br i1 %66, label %92, label %67
67: ; preds = %55
%68 = fsub double %64, %60
%69 = fsub double %62, %59
%70 = fneg double %64
%71 = fmul double %59, %70
%72 = tail call double @llvm.fmuladd.f64(double %60, double %62, double %71)
%73 = fneg double %68
%74 = fmul double %50, %73
%75 = tail call double @llvm.fmuladd.f64(double %49, double %69, double %74)
%76 = tail call double @llvm.fabs.f64(double %75)
%77 = fcmp olt double %76, 1.000000e-30
br i1 %77, label %78, label %80
78: ; preds = %67
%79 = tail call i32 @error_handler(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0))
br label %80
80: ; preds = %78, %67
%81 = fneg double %69
%82 = fmul double %53, %81
%83 = tail call double @llvm.fmuladd.f64(double %50, double %72, double %82)
%84 = fdiv double %83, %75
%85 = sext i32 %58 to i64
%86 = getelementptr inbounds double, double* %6, i64 %85
store double %84, double* %86
%87 = fmul double %53, %73
%88 = tail call double @llvm.fmuladd.f64(double %49, double %72, double %87)
%89 = fdiv double %88, %75
%90 = add nsw i32 %58, 1
%91 = getelementptr inbounds double, double* %7, i64 %85
store double %89, double* %91
br label %92
92: ; preds = %80, %55
%93 = phi i32 [ %90, %80 ], [ %58, %55 ]
%94 = icmp eq i32 %65, 0
br i1 %94, label %100, label %95
95: ; preds = %92
%96 = sext i32 %93 to i64
%97 = getelementptr inbounds double, double* %6, i64 %96
store double %62, double* %97
%98 = add nsw i32 %93, 1
%99 = getelementptr inbounds double, double* %7, i64 %96
store double %64, double* %99
br label %100
100: ; preds = %95, %92
%101 = phi i32 [ %98, %95 ], [ %93, %92 ]
%102 = add nuw nsw i64 %56, 1
%103 = icmp eq i64 %102, %54
br i1 %103, label %104, label %55
104: ; preds = %100
%105 = icmp eq i32 %101, 0
br i1 %105, label %114, label %106
106: ; preds = %104
%107 = icmp sgt i32 %101, 0
br i1 %107, label %108, label %111
108: ; preds = %106
%109 = zext i32 %101 to i64
%110 = shl nuw nsw i64 %109, 3
br label %111
111: ; preds = %108, %106
%112 = add nuw nsw i64 %32, 1
%113 = icmp eq i64 %112, %30
br i1 %113, label %114, label %31
114: ; preds = %31, %104, %111, %21
%115 = phi i32 [ %2, %21 ], [ 0, %31 ], [ %101, %111 ], [ 0, %104 ]
ret i32 %115
}