#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*/ SetTransferMatrix(double, double, double, double, double,
                                     double);
int /*<<< orphan*/ ZigZagHelp(double *, double);
double sqrt(double);
void ZigZag(double *args) {
  double dx = args[2] - args[0];
  double dy = args[3] - args[1];
  double dr = sqrt(dx * dx + dy * dy);
  SetTransferMatrix(1, 0, 0, 1, args[0], args[1]);
  SetTransferMatrix(dx / dr, dy / dr, -dy / dr, dx / dr, 0, 0);
  ZigZagHelp(args, dr);
}


x86 assembly (clang, -O0):
<ZigZag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm4
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm5
movsd  0xe58(%rip),%xmm3
xorps  %xmm2,%xmm2
movaps %xmm3,%xmm0
movaps %xmm2,%xmm1
call   1040 <SetTransferMatrix@plt>
movsd  -0x10(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
divsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
divsd  -0x20(%rbp),%xmm3
xorps  %xmm5,%xmm5
movaps %xmm5,%xmm4
call   1040 <SetTransferMatrix@plt>
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1030 <ZigZagHelp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ZigZag>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  0x10(%rdi),%xmm0
movsd  0x18(%rdi),%xmm1
subsd  (%rdi),%xmm0
subsd  0x8(%rdi),%xmm1
movapd %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1173 <ZigZag+0x43>
sqrtsd %xmm0,%xmm0
jmp    1178 <ZigZag+0x48>
call   1050 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  (%rbx),%xmm4
movsd  0x8(%rbx),%xmm5
movsd  0xe72(%rip),%xmm0
xorpd  %xmm1,%xmm1
xorps  %xmm2,%xmm2
movaps %xmm0,%xmm3
call   1040 <SetTransferMatrix@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm3
divsd  %xmm3,%xmm0
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm3,%xmm1
xorpd  0xe4e(%rip),%xmm2
divsd  %xmm3,%xmm2
xorps  %xmm4,%xmm4
xorps  %xmm5,%xmm5
movapd %xmm0,%xmm3
call   1040 <SetTransferMatrix@plt>
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
jmp    1030 <ZigZagHelp@plt>

LLVM IR (-O0):
define void @ZigZag(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double* %0, double** %2
%6 = load double*, double** %2
%7 = getelementptr inbounds double, double* %6, i64 2
%8 = load double, double* %7
%9 = load double*, double** %2
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = fsub double %8, %11
store double %12, double* %3
%13 = load double*, double** %2
%14 = getelementptr inbounds double, double* %13, i64 3
%15 = load double, double* %14
%16 = load double*, double** %2
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = fsub double %15, %18
store double %19, double* %4
%20 = load double, double* %3
%21 = load double, double* %3
%22 = load double, double* %4
%23 = load double, double* %4
%24 = fmul double %22, %23
%25 = call double @llvm.fmuladd.f64(double %20, double %21, double %24)
%26 = call double @sqrt(double %25)
store double %26, double* %5
%27 = load double*, double** %2
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = load double*, double** %2
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = call i32 @SetTransferMatrix(double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double %29, double %32)
%34 = load double, double* %3
%35 = load double, double* %5
%36 = fdiv double %34, %35
%37 = load double, double* %4
%38 = load double, double* %5
%39 = fdiv double %37, %38
%40 = load double, double* %4
%41 = fneg double %40
%42 = load double, double* %5
%43 = fdiv double %41, %42
%44 = load double, double* %3
%45 = load double, double* %5
%46 = fdiv double %44, %45
%47 = call i32 @SetTransferMatrix(double %36, double %39, double %43, double %46, double 0.000000e+00, double 0.000000e+00)
%48 = load double*, double** %2
%49 = load double, double* %5
%50 = call i32 @ZigZagHelp(double* %48, double %49)
ret void
}

LLVM IR (-O2):
define void @ZigZag(double* %0) {
%2 = getelementptr inbounds double, double* %0, i64 2
%3 = load double, double* %2
%4 = load double, double* %0
%5 = fsub double %3, %4
%6 = getelementptr inbounds double, double* %0, i64 3
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = fsub double %7, %9
%11 = fmul double %10, %10
%12 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %11)
%13 = tail call double @sqrt(double %12)
%14 = load double, double* %0
%15 = load double, double* %8
%16 = tail call i32 @SetTransferMatrix(double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double %14, double %15)
%17 = fdiv double %5, %13
%18 = fdiv double %10, %13
%19 = fneg double %10
%20 = fdiv double %19, %13
%21 = tail call i32 @SetTransferMatrix(double %17, double %18, double %20, double %17, double 0.000000e+00, double 0.000000e+00)
%22 = tail call i32 @ZigZagHelp(double* %0, double %13)
ret void
}