// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Rectangle.cpp
// Function: gaps::R3Rectangle::Reset(gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Vector const&, double, double)
void R3Rectangle::
Reset(const R3Point& center, 
    const R3Vector& axis0, const R3Vector& axis1, 
    RNLength radius0, RNLength radius1)
{
    // Check axes
    assert(RNIsPositive(axis0.Length()));
    assert(RNIsPositive(axis1.Length()));

    // Normalize and orthogonalize axes
    R3Vector axis[3];
    axis[0] = axis0;
    axis[0].Normalize();
    axis[1] = axis1;
    axis[1].Normalize();
    axis[1] = axis[0] % axis[1];
    axis[1] = axis[1] % axis[0];
    axis[1].Normalize();
    axis[2] = axis[0] % axis[1];
    axis[2].Normalize();

    // Assign radii
    radius[0] = radius0;
    radius[1] = radius1;

    // Sort axes
    R3Vector swap_axis;
    RNScalar swap_radius;
    if (radius[1] > radius[0]) {
      swap_axis = axis[0]; swap_radius = radius[0];
      axis[0] = axis[1]; radius[0] = radius[1];
      axis[1] = swap_axis; radius[1] = swap_radius;
    }

    // Ensure right-handed coordinate system
    axis[2] = axis[0] % axis[1];
    axis[2].Normalize();

    // Set coordinate system
    cs.Reset(center, R3Triad(axis[0], axis[1], axis[2]));
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x170(%rsp)
movq %rsi, 0x168(%rsp)
movq %rdx, 0x160(%rsp)
movq %rcx, 0x158(%rsp)
movsd %xmm0, 0x150(%rsp)
movsd %xmm1, 0x148(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, %rcx
addq $0x48, %rcx
movq %rcx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x6fca0
movq 0x18(%rsp), %rax
movq 0x28(%rsp), %rcx
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, 0x30(%rsp)
jne 0x94ebf
movq 0x160(%rsp), %rsi
leaq 0x100(%rsp), %rdi
callq 0x70970
leaq 0x100(%rsp), %rdi
callq 0x70410
movq 0x158(%rsp), %rsi
leaq 0x100(%rsp), %rdi
addq $0x18, %rdi
callq 0x70970
leaq 0x100(%rsp), %rdi
addq $0x18, %rdi
callq 0x70410
leaq 0x100(%rsp), %rsi
leaq 0x100(%rsp), %rdx
addq $0x18, %rdx
leaq 0xe8(%rsp), %rdi
callq 0x70af0
leaq 0x100(%rsp), %rdi
addq $0x18, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x70970
leaq 0x100(%rsp), %rsi
addq $0x18, %rsi
leaq 0x100(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
callq 0x70af0
leaq 0x100(%rsp), %rdi
addq $0x18, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x70970
leaq 0x100(%rsp), %rdi
addq $0x18, %rdi
callq 0x70410
leaq 0x100(%rsp), %rsi
leaq 0x100(%rsp), %rdx
addq $0x18, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x70af0
leaq 0x100(%rsp), %rdi
addq $0x30, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x70970
leaq 0x100(%rsp), %rdi
addq $0x30, %rdi
callq 0x70410
movq 0x20(%rsp), %rax
movsd 0x150(%rsp), %xmm0
movsd %xmm0, 0x68(%rax)
movsd 0x148(%rsp), %xmm0
movsd %xmm0, 0x70(%rax)
leaq 0xa0(%rsp), %rdi
callq 0x6fca0
movq 0x20(%rsp), %rax
movsd 0x70(%rax), %xmm0
ucomisd 0x68(%rax), %xmm0
jbe 0x950bd
leaq 0x100(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x70970
movq 0x20(%rsp), %rax
movsd 0x68(%rax), %xmm0
movsd %xmm0, 0x98(%rsp)
leaq 0x100(%rsp), %rsi
addq $0x18, %rsi
leaq 0x100(%rsp), %rdi
callq 0x70970
movq 0x20(%rsp), %rax
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x68(%rax)
leaq 0x100(%rsp), %rdi
addq $0x18, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x70970
movq 0x20(%rsp), %rax
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x70(%rax)
leaq 0x100(%rsp), %rsi
leaq 0x100(%rsp), %rdx
addq $0x18, %rdx
leaq 0x80(%rsp), %rdi
callq 0x70af0
leaq 0x100(%rsp), %rdi
addq $0x30, %rdi
leaq 0x80(%rsp), %rsi
callq 0x70970
leaq 0x100(%rsp), %rdi
addq $0x30, %rdi
callq 0x70410
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x100(%rsp), %rsi
leaq 0x100(%rsp), %rdx
addq $0x18, %rdx
leaq 0x100(%rsp), %rcx
addq $0x30, %rcx
leaq 0x38(%rsp), %rdi
callq 0x4ec80
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4e660
addq $0x178, %rsp            # imm = 0x178
retq
nopl (%rax)