// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_savehome(int, block_struct*, setup_struct*)
int Interp::convert_savehome(int code, block_pointer block, setup_pointer s) {
    double *p = s->parameters;
    
    if(s->cutter_comp_side != OFF) {
        ERS("Cannot set reference point with cutter compensation in effect");
    }

    double x = PROGRAM_TO_USER_LEN(s->current_x + s->tool_offset.tran.x + s->origin_offset_x + s->axis_offset_x);
    double y = PROGRAM_TO_USER_LEN(s->current_y + s->tool_offset.tran.y + s->origin_offset_y + s->axis_offset_y);
    double z = PROGRAM_TO_USER_LEN(s->current_z + s->tool_offset.tran.z + s->origin_offset_z + s->axis_offset_z);
    double a = PROGRAM_TO_USER_ANG(s->AA_current + s->tool_offset.a + s->AA_origin_offset + s->AA_axis_offset);
    double b = PROGRAM_TO_USER_ANG(s->BB_current + s->tool_offset.b + s->BB_origin_offset + s->BB_axis_offset);
    double c = PROGRAM_TO_USER_ANG(s->CC_current + s->tool_offset.c + s->CC_origin_offset + s->CC_axis_offset);
    double u = PROGRAM_TO_USER_LEN(s->u_current + s->tool_offset.u + s->u_origin_offset + s->u_axis_offset);
    double v = PROGRAM_TO_USER_LEN(s->v_current + s->tool_offset.v + s->v_origin_offset + s->v_axis_offset);
    double w = PROGRAM_TO_USER_LEN(s->w_current + s->tool_offset.w + s->w_origin_offset + s->w_axis_offset);

    if(s->a_axis_wrapped) {
        a = fmod(a, 360.0);
        if(a<0) a += 360.0;
    }

    if(s->b_axis_wrapped) {
        b = fmod(b, 360.0);
        if(b<0) b += 360.0;
    }

    if(s->c_axis_wrapped) {
        c = fmod(c, 360.0);
        if(c<0) c += 360.0;
    }

    if(code == G_28_1) {
        p[5161] = x;
        p[5162] = y;
        p[5163] = z;
        p[5164] = a;
        p[5165] = b;
        p[5166] = c;
        p[5167] = u;
        p[5168] = v;
        p[5169] = w;
    } else if(code == G_30_1) {
        p[5181] = x;
        p[5182] = y;
        p[5183] = z;
        p[5184] = a;
        p[5185] = b;
        p[5186] = c;
        p[5187] = u;
        p[5188] = v;
        p[5189] = w;
    } else {
        ERS("BUG: Code not G28.1 or G38.1");
    }
    return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rdi, %r14
cmpl $0x0, 0x624(%rcx)
je 0x13478
leaq 0x1e5b5(%rip), %rsi     # 0x319ec
movq %r14, %rdi
xorl %eax, %eax
callq 0xb8e0
movq 0x29b18(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0x1d38f(%rip), %rsi     # 0x307e5
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %rax
jmp 0x1399f
movq %rcx, %rbx
movl %esi, %r15d
movsd 0x600(%rcx), %xmm1
addsd 0xd678(%rcx), %xmm1
movq 0x29acb(%rip), %r12     # 0x3cf60
movl 0x1690(%r12), %eax
movsd 0x1ca1b(%rip), %xmm0    # 0x2fec0
movsd %xmm0, -0x30(%rbp)
cmpl $0x3, %eax
je 0x134b7
movsd 0x1c9e9(%rip), %xmm0    # 0x2fea0
addsd 0x17a0(%rbx), %xmm1
movsd 0x1ca01(%rip), %xmm2    # 0x2fec8
movsd %xmm2, -0x70(%rbp)
cmpl $0x1, %eax
je 0x134d4
movaps %xmm0, %xmm2
movsd %xmm2, -0xc8(%rbp)
addsd 0x118(%rbx), %xmm1
movsd %xmm1, -0x68(%rbp)
callq 0xba40
movsd 0x608(%rbx), %xmm1
addsd 0xd680(%rbx), %xmm1
movsd %xmm0, -0xd8(%rbp)
movl 0x1690(%r12), %eax
movsd 0x1c9aa(%rip), %xmm0    # 0x2fec0
cmpl $0x3, %eax
je 0x13523
movsd 0x1c97d(%rip), %xmm0    # 0x2fea0
addsd 0x17a8(%rbx), %xmm1
movsd 0x1c995(%rip), %xmm2    # 0x2fec8
cmpl $0x1, %eax
je 0x1353b
movaps %xmm0, %xmm2
movsd %xmm2, -0xb0(%rbp)
addsd 0x120(%rbx), %xmm1
movsd %xmm1, -0x60(%rbp)
callq 0xba40
movsd 0x610(%rbx), %xmm2
addsd 0xd688(%rbx), %xmm2
movl 0x1690(%r12), %eax
movsd 0x1c94b(%rip), %xmm1    # 0x2fec0
cmpl $0x3, %eax
je 0x13582
movsd 0x1c91e(%rip), %xmm1    # 0x2fea0
movsd %xmm0, -0xd0(%rbp)
addsd 0x17b0(%rbx), %xmm2
movsd 0x1c92e(%rip), %xmm0    # 0x2fec8
cmpl $0x1, %eax
je 0x135a2
movaps %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
addsd 0x128(%rbx), %xmm2
movsd %xmm2, -0x58(%rbp)
callq 0xba40
movsd %xmm0, -0xc0(%rbp)
movsd 0x8(%rbx), %xmm0
addsd 0xd690(%rbx), %xmm0
addsd 0x10(%rbx), %xmm0
addsd (%rbx), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0xc090
movsd %xmm0, -0x38(%rbp)
movsd 0x20(%rbx), %xmm0
addsd 0xd698(%rbx), %xmm0
addsd 0x28(%rbx), %xmm0
addsd 0x18(%rbx), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0xc090
movsd %xmm0, -0x80(%rbp)
movsd 0x38(%rbx), %xmm0
addsd 0xd6a0(%rbx), %xmm0
addsd 0x40(%rbx), %xmm0
addsd 0x30(%rbx), %xmm0
movsd %xmm0, -0xb8(%rbp)
callq 0xc090
movsd 0x50(%rbx), %xmm2
addsd 0xd6a8(%rbx), %xmm2
movsd %xmm0, -0x90(%rbp)
movl 0x1690(%r12), %eax
movsd 0x1c868(%rip), %xmm0    # 0x2fec0
cmpl $0x3, %eax
je 0x13665
movsd 0x1c83b(%rip), %xmm0    # 0x2fea0
addsd 0x58(%rbx), %xmm2
movsd 0x1c856(%rip), %xmm1    # 0x2fec8
cmpl $0x1, %eax
je 0x1367a
movaps %xmm0, %xmm1
movsd %xmm1, -0x88(%rbp)
addsd 0x48(%rbx), %xmm2
movsd %xmm2, -0x48(%rbp)
callq 0xba40
movsd 0x68(%rbx), %xmm2
addsd 0xd6b0(%rbx), %xmm2
movaps %xmm0, %xmm1
movl 0x1690(%r12), %eax
movsd 0x1c80f(%rip), %xmm0    # 0x2fec0
cmpl $0x3, %eax
je 0x136be
movsd 0x1c7e2(%rip), %xmm0    # 0x2fea0
movsd %xmm1, -0xa0(%rbp)
addsd 0x70(%rbx), %xmm2
movsd 0x1c7f5(%rip), %xmm1    # 0x2fec8
cmpl $0x1, %eax
je 0x136dc
movapd %xmm0, %xmm1
movsd %xmm1, -0x78(%rbp)
addsd 0x60(%rbx), %xmm2
movsd %xmm2, -0x40(%rbp)
callq 0xba40
movapd %xmm0, %xmm1
movsd 0x80(%rbx), %xmm2
addsd 0xd6b8(%rbx), %xmm2
movl 0x1690(%r12), %eax
cmpl $0x3, %eax
je 0x1371e
movsd 0x1c787(%rip), %xmm0    # 0x2fea0
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x98(%rbp)
addsd 0x88(%rbx), %xmm2
cmpl $0x1, %eax
movsd -0x28(%rbp), %xmm0
je 0x13742
movsd -0x30(%rbp), %xmm1
movsd %xmm1, -0x70(%rbp)
addsd 0x78(%rbx), %xmm2
movsd %xmm2, -0x30(%rbp)
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0xba40
movsd %xmm0, -0x38(%rbp)
cmpl $0x0, 0x1e6cc(%rbx)
je 0x1378f
movsd 0x1c747(%rip), %xmm1    # 0x2feb8
movsd -0x28(%rbp), %xmm0
callq 0xbf20
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x13794
addsd 0x1c72b(%rip), %xmm0    # 0x2feb8
jmp 0x13794
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x50(%rbp), %xmm4
mulsd -0x80(%rbp), %xmm4
cmpl $0x0, 0x1e6d0(%rbx)
je 0x137d3
movsd 0x1c704(%rip), %xmm1    # 0x2feb8
movapd %xmm4, %xmm0
callq 0xbf20
movapd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm0
jbe 0x137d3
addsd 0x1c6e5(%rip), %xmm4    # 0x2feb8
movsd -0x68(%rbp), %xmm1
mulsd -0xc8(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
mulsd -0xb0(%rbp), %xmm2
movsd -0x58(%rbp), %xmm3
mulsd -0xa8(%rbp), %xmm3
movsd -0x48(%rbp), %xmm6
mulsd -0x88(%rbp), %xmm6
movsd -0x40(%rbp), %xmm7
mulsd -0x78(%rbp), %xmm7
movsd -0x30(%rbp), %xmm8
mulsd -0x70(%rbp), %xmm8
movsd -0xb8(%rbp), %xmm5
mulsd -0x90(%rbp), %xmm5
cmpl $0x0, 0x1e6d4(%rbx)
je 0x138a5
movsd %xmm1, -0x68(%rbp)
movsd 0x1c675(%rip), %xmm1    # 0x2feb8
movapd %xmm5, %xmm0
movsd %xmm2, -0x60(%rbp)
movsd %xmm3, -0x58(%rbp)
movsd %xmm4, -0x50(%rbp)
movsd %xmm6, -0x48(%rbp)
movsd %xmm7, -0x40(%rbp)
movsd %xmm8, -0x30(%rbp)
callq 0xbf20
movsd -0x30(%rbp), %xmm8
movsd -0x40(%rbp), %xmm7
movsd -0x48(%rbp), %xmm6
movsd -0x50(%rbp), %xmm4
movsd -0x58(%rbp), %xmm3
movsd -0x60(%rbp), %xmm2
movsd -0x68(%rbp), %xmm1
movapd %xmm0, %xmm5
xorpd %xmm0, %xmm0
ucomisd %xmm5, %xmm0
jbe 0x138a5
addsd 0x1c613(%rip), %xmm5    # 0x2feb8
movsd -0xd8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd -0xd0(%rbp), %xmm1
mulsd %xmm2, %xmm1
movsd -0xc0(%rbp), %xmm2
mulsd %xmm3, %xmm2
movsd -0xa0(%rbp), %xmm3
mulsd %xmm6, %xmm3
movsd -0x98(%rbp), %xmm6
mulsd %xmm7, %xmm6
movsd -0x38(%rbp), %xmm7
mulsd %xmm8, %xmm7
cmpl $0x12d, %r15d           # imm = 0x12D
je 0x13950
cmpl $0x119, %r15d           # imm = 0x119
jne 0x139af
movsd %xmm0, 0xb908(%rbx)
movsd %xmm1, 0xb910(%rbx)
movsd %xmm2, 0xb918(%rbx)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, 0xb920(%rbx)
movsd %xmm4, 0xb928(%rbx)
movsd %xmm5, 0xb930(%rbx)
movsd %xmm3, 0xb938(%rbx)
movsd %xmm6, 0xb940(%rbx)
movsd %xmm7, 0xb948(%rbx)
jmp 0x1399d
movsd %xmm0, 0xb9a8(%rbx)
movsd %xmm1, 0xb9b0(%rbx)
movsd %xmm2, 0xb9b8(%rbx)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, 0xb9c0(%rbx)
movsd %xmm4, 0xb9c8(%rbx)
movsd %xmm5, 0xb9d0(%rbx)
movsd %xmm3, 0xb9d8(%rbx)
movsd %xmm6, 0xb9e0(%rbx)
movsd %xmm7, 0xb9e8(%rbx)
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e074(%rip), %rsi     # 0x31a2a
movq %r14, %rdi
xorl %eax, %eax
callq 0xb8e0
leaq 0xc6d0(%r12), %rdi
leaq 0x1ce16(%rip), %rsi     # 0x307e5
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%r12)
movl $0x1, 0xd670(%r12)
jmp 0x13470