// File: /workspace/github_cpp_makefile_star2_O3/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 0x1290b
leaq 0x2311d(%rip), %rsi     # 0x359e2
movq %r14, %rdi
xorl %eax, %eax
callq 0xa850
movq 0x2e68a(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0x21f01(%rip), %rsi     # 0x347e5
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %eax
jmp 0x12e32
movq %rcx, %rbx
movl %esi, %r15d
movsd 0x600(%rcx), %xmm1
addsd 0xd678(%rcx), %xmm1
movq 0x2e638(%rip), %r12     # 0x40f60
movl 0x1690(%r12), %eax
movsd 0x21588(%rip), %xmm0    # 0x33ec0
movsd %xmm0, -0x30(%rbp)
cmpl $0x3, %eax
je 0x1294a
movsd 0x21556(%rip), %xmm0    # 0x33ea0
addsd 0x17a0(%rbx), %xmm1
movsd 0x2156e(%rip), %xmm2    # 0x33ec8
movsd %xmm2, -0x70(%rbp)
cmpl $0x1, %eax
je 0x12967
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 0x21517(%rip), %xmm0    # 0x33ec0
cmpl $0x3, %eax
je 0x129b6
movsd 0x214ea(%rip), %xmm0    # 0x33ea0
addsd 0x17a8(%rbx), %xmm1
movsd 0x21502(%rip), %xmm2    # 0x33ec8
cmpl $0x1, %eax
je 0x129ce
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 0x214b8(%rip), %xmm1    # 0x33ec0
cmpl $0x3, %eax
je 0x12a15
movsd 0x2148b(%rip), %xmm1    # 0x33ea0
movsd %xmm0, -0xd0(%rbp)
addsd 0x17b0(%rbx), %xmm2
movsd 0x2149b(%rip), %xmm0    # 0x33ec8
cmpl $0x1, %eax
je 0x12a35
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 0x213d5(%rip), %xmm0    # 0x33ec0
cmpl $0x3, %eax
je 0x12af8
movsd 0x213a8(%rip), %xmm0    # 0x33ea0
addsd 0x58(%rbx), %xmm2
movsd 0x213c3(%rip), %xmm1    # 0x33ec8
cmpl $0x1, %eax
je 0x12b0d
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 0x2137c(%rip), %xmm0    # 0x33ec0
cmpl $0x3, %eax
je 0x12b51
movsd 0x2134f(%rip), %xmm0    # 0x33ea0
movsd %xmm1, -0xa0(%rbp)
addsd 0x70(%rbx), %xmm2
movsd 0x21362(%rip), %xmm1    # 0x33ec8
cmpl $0x1, %eax
je 0x12b6f
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 0x12bb1
movsd 0x212f4(%rip), %xmm0    # 0x33ea0
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x98(%rbp)
addsd 0x88(%rbx), %xmm2
cmpl $0x1, %eax
movsd -0x28(%rbp), %xmm0
je 0x12bd5
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 0x12c22
movsd 0x212b4(%rip), %xmm1    # 0x33eb8
movsd -0x28(%rbp), %xmm0
callq 0xae10
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x12c27
addsd 0x21298(%rip), %xmm0    # 0x33eb8
jmp 0x12c27
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x50(%rbp), %xmm4
mulsd -0x80(%rbp), %xmm4
cmpl $0x0, 0x1e6d0(%rbx)
je 0x12c66
movsd 0x21271(%rip), %xmm1    # 0x33eb8
movapd %xmm4, %xmm0
callq 0xae10
movapd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm0
jbe 0x12c66
addsd 0x21252(%rip), %xmm4    # 0x33eb8
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 0x12d38
movsd %xmm1, -0x68(%rbp)
movsd 0x211e2(%rip), %xmm1    # 0x33eb8
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 0x12d38
addsd 0x21180(%rip), %xmm5    # 0x33eb8
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 0x12de3
cmpl $0x119, %r15d           # imm = 0x119
jne 0x12e42
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 0x12e30
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 0x22bd7(%rip), %rsi     # 0x35a20
movq %r14, %rdi
xorl %eax, %eax
callq 0xa850
leaq 0xc6d0(%r12), %rdi
leaq 0x21983(%rip), %rsi     # 0x347e5
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%r12)
movl $0x1, 0xd670(%r12)
jmp 0x12901