// File: /workspace/github_cpp_makefile_star2_O1/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 0x132cd
leaq 0x25765(%rip), %rsi     # 0x389e2
movq %r14, %rdi
xorl %eax, %eax
callq 0xa850
movq 0x30cd2(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x2453f(%rip), %rsi     # 0x377e5
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %eax
jmp 0x137f4
movq %rcx, %rbx
movl %esi, %r15d
movsd 0x600(%rcx), %xmm1
addsd 0xd678(%rcx), %xmm1
movq 0x30c76(%rip), %r12     # 0x43f60
movl 0x1690(%r12), %eax
movsd 0x23bc6(%rip), %xmm0    # 0x36ec0
movsd %xmm0, -0x30(%rbp)
cmpl $0x3, %eax
je 0x1330c
movsd 0x23b94(%rip), %xmm0    # 0x36ea0
addsd 0x17a0(%rbx), %xmm1
movsd 0x23bac(%rip), %xmm2    # 0x36ec8
movsd %xmm2, -0x70(%rbp)
cmpl $0x1, %eax
je 0x13329
movaps %xmm0, %xmm2
movsd %xmm2, -0xc8(%rbp)
addsd 0x118(%rbx), %xmm1
movsd %xmm1, -0x68(%rbp)
callq 0xa990
movsd 0x608(%rbx), %xmm1
addsd 0xd680(%rbx), %xmm1
movsd %xmm0, -0xd8(%rbp)
movl 0x1690(%r12), %eax
movsd 0x23b55(%rip), %xmm0    # 0x36ec0
cmpl $0x3, %eax
je 0x13378
movsd 0x23b28(%rip), %xmm0    # 0x36ea0
addsd 0x17a8(%rbx), %xmm1
movsd 0x23b40(%rip), %xmm2    # 0x36ec8
cmpl $0x1, %eax
je 0x13390
movaps %xmm0, %xmm2
movsd %xmm2, -0xb0(%rbp)
addsd 0x120(%rbx), %xmm1
movsd %xmm1, -0x60(%rbp)
callq 0xa990
movsd 0x610(%rbx), %xmm2
addsd 0xd688(%rbx), %xmm2
movl 0x1690(%r12), %eax
movsd 0x23af6(%rip), %xmm1    # 0x36ec0
cmpl $0x3, %eax
je 0x133d7
movsd 0x23ac9(%rip), %xmm1    # 0x36ea0
movsd %xmm0, -0xd0(%rbp)
addsd 0x17b0(%rbx), %xmm2
movsd 0x23ad9(%rip), %xmm0    # 0x36ec8
cmpl $0x1, %eax
je 0x133f7
movaps %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
addsd 0x128(%rbx), %xmm2
movsd %xmm2, -0x58(%rbp)
callq 0xa990
movsd %xmm0, -0xc0(%rbp)
movsd 0x8(%rbx), %xmm0
addsd 0xd690(%rbx), %xmm0
addsd 0x10(%rbx), %xmm0
addsd (%rbx), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0xaf60
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 0xaf60
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 0xaf60
movsd 0x50(%rbx), %xmm2
addsd 0xd6a8(%rbx), %xmm2
movsd %xmm0, -0x90(%rbp)
movl 0x1690(%r12), %eax
movsd 0x23a13(%rip), %xmm0    # 0x36ec0
cmpl $0x3, %eax
je 0x134ba
movsd 0x239e6(%rip), %xmm0    # 0x36ea0
addsd 0x58(%rbx), %xmm2
movsd 0x23a01(%rip), %xmm1    # 0x36ec8
cmpl $0x1, %eax
je 0x134cf
movaps %xmm0, %xmm1
movsd %xmm1, -0x88(%rbp)
addsd 0x48(%rbx), %xmm2
movsd %xmm2, -0x48(%rbp)
callq 0xa990
movsd 0x68(%rbx), %xmm2
addsd 0xd6b0(%rbx), %xmm2
movaps %xmm0, %xmm1
movl 0x1690(%r12), %eax
movsd 0x239ba(%rip), %xmm0    # 0x36ec0
cmpl $0x3, %eax
je 0x13513
movsd 0x2398d(%rip), %xmm0    # 0x36ea0
movsd %xmm1, -0xa0(%rbp)
addsd 0x70(%rbx), %xmm2
movsd 0x239a0(%rip), %xmm1    # 0x36ec8
cmpl $0x1, %eax
je 0x13531
movapd %xmm0, %xmm1
movsd %xmm1, -0x78(%rbp)
addsd 0x60(%rbx), %xmm2
movsd %xmm2, -0x40(%rbp)
callq 0xa990
movapd %xmm0, %xmm1
movsd 0x80(%rbx), %xmm2
addsd 0xd6b8(%rbx), %xmm2
movl 0x1690(%r12), %eax
cmpl $0x3, %eax
je 0x13573
movsd 0x23932(%rip), %xmm0    # 0x36ea0
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x98(%rbp)
addsd 0x88(%rbx), %xmm2
cmpl $0x1, %eax
movsd -0x28(%rbp), %xmm0
je 0x13597
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 0xa990
movsd %xmm0, -0x38(%rbp)
cmpl $0x0, 0x1e6cc(%rbx)
je 0x135e4
movsd 0x238f2(%rip), %xmm1    # 0x36eb8
movsd -0x28(%rbp), %xmm0
callq 0xae10
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x135e9
addsd 0x238d6(%rip), %xmm0    # 0x36eb8
jmp 0x135e9
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x50(%rbp), %xmm4
mulsd -0x80(%rbp), %xmm4
cmpl $0x0, 0x1e6d0(%rbx)
je 0x13628
movsd 0x238af(%rip), %xmm1    # 0x36eb8
movapd %xmm4, %xmm0
callq 0xae10
movapd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm0
jbe 0x13628
addsd 0x23890(%rip), %xmm4    # 0x36eb8
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 0x136fa
movsd %xmm1, -0x68(%rbp)
movsd 0x23820(%rip), %xmm1    # 0x36eb8
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 0xae10
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 0x136fa
addsd 0x237be(%rip), %xmm5    # 0x36eb8
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 0x137a5
cmpl $0x119, %r15d           # imm = 0x119
jne 0x13804
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 0x137f2
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 0x25215(%rip), %rsi     # 0x38a20
movq %r14, %rdi
xorl %eax, %eax
callq 0xa850
movl $0x0, 0xd670(%r12)
leaq 0xc6d0(%r12), %rdi
leaq 0x23fb5(%rip), %rsi     # 0x377e5
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%r12)
movl $0x1, 0xd670(%r12)
jmp 0x132c3