// File: /workspace/github_c_makefile_star2_O2/mmayer[P]pcal/src/pcalutil.c
// Function: define_shading
void define_shading (char *orig_shading, char *new_shading, char *dflt_shading)
{
   char *odate, *ndate, *ddate, *ofill, *nfill, *dfill;
   char tmp1[STRSIZ], tmp2[STRSIZ], tmp3[STRSIZ];
   double v;
   
   /* use default date/fill if new _shading is null */
   if (new_shading == NULL || new_shading[0] == '\0') {
      strcpy(orig_shading, dflt_shading);
      return;
   }

   /* split old, new, and default shadings into date/fill components */
   SPLIT(orig_shading, odate, ofill, '/');
   
   new_shading = strcpy(tmp1, new_shading);
   SPLIT(new_shading, ndate, nfill, '/');
   
   dflt_shading = strcpy(tmp2, dflt_shading);
   SPLIT(dflt_shading, ddate, dfill, '/');

   /* replace invalid fields from new shading with default values */
   if (nfill[0] && strchr(nfill, RGB_CHAR) == NULL && ((v = atof(nfill)) <= 0.0 || v > 1.0)) {
      nfill = dfill;
   }
   if (ndate[0] && strchr(ndate, RGB_CHAR) == NULL && ((v = atof(ndate)) <= 0.0 || v > 1.0)) {
      ndate = ddate;
   }
   
   /* replace fields of old shading with specified fields from new */
   
   strcpy(tmp3, ndate[0] ? ndate : odate);
   strcat(tmp3, "/");
   strcat(tmp3, nfill[0] ? nfill : ofill);
   
   strcpy(orig_shading, tmp3);

   return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdx, %r13
movq %rdi, %rbx
testq %rsi, %rsi
je 0x9853
movq %rsi, %r15
cmpb $0x0, (%rsi)
je 0x9853
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x5150
testq %rax, %rax
je 0x986f
movq %rax, %r14
movb $0x0, (%rax)
incq %r14
jmp 0x9876
movq %rbx, %rdi
movq %r13, %rsi
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x50a0
leaq 0x14ee7(%rip), %r14     # 0x1e75d
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x5120
testq %rax, %rax
je 0x9889
movb $0x0, (%rax)
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x50a0
pushq $0x2f
popq %rsi
movq %r12, %rdi
callq 0x5150
testq %rax, %rax
je 0x98b2
movq %rax, %r15
movb $0x0, (%rax)
incq %r15
jmp 0x98b9
leaq 0x14ea4(%rip), %r15     # 0x1e75d
movq %rsp, %r12
pushq $0x2f
popq %rsi
movq %r12, %rdi
callq 0x5120
testq %rax, %rax
je 0x98cf
movb $0x0, (%rax)
leaq 0x1a0(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x50a0
pushq $0x2f
popq %rsi
movq %rbp, %rdi
callq 0x5150
testq %rax, %rax
je 0x98fd
movq %rax, %rbp
movb $0x0, (%rax)
incq %rbp
jmp 0x9904
leaq 0x14e59(%rip), %rbp     # 0x1e75d
leaq 0x1a0(%rsp), %r13
pushq $0x2f
popq %rsi
movq %r13, %rdi
callq 0x5120
testq %rax, %rax
je 0x991f
movb $0x0, (%rax)
cmpb $0x0, (%r15)
je 0x9955
pushq $0x3a
popq %rsi
movq %r15, %rdi
callq 0x5120
testq %rax, %rax
jne 0x9955
movq %r15, %rdi
callq 0x50c0
ucomisd 0xa6c3(%rip), %xmm0     # 0x14008
cmovaq %rbp, %r15
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovaeq %rbp, %r15
cmpb $0x0, (%rsp)
movq %rbx, %rbp
je 0x999c
pushq $0x3a
popq %rsi
movq %r12, %rdi
callq 0x5120
movq %r12, %rbp
testq %rax, %rax
jne 0x999c
movq %rsp, %rbp
movq %rbp, %rdi
callq 0x50c0
ucomisd 0xa684(%rip), %xmm0     # 0x14008
cmovaq %r13, %rbp
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovaeq %r13, %rbp
cmpb $0x0, (%rbp)
cmoveq %rbx, %rbp
leaq 0xd0(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x50a0
movq %r12, %rdi
callq 0x5100
movw $0x2f, 0xd0(%rsp,%rax)
cmpb $0x0, (%r15)
cmovneq %r15, %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x52d0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x50a0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq