// File: /workspace/github_c_makefile_star2_O1/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 0xa0dc
movq %rsi, %r15
cmpb $0x0, (%rsi)
je 0xa0dc
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x5150
testq %rax, %rax
je 0x9f6b
movq %rax, %r14
movb $0x0, (%rax)
incq %r14
jmp 0x9f72
leaq 0x157cb(%rip), %r14     # 0x1f73d
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x5120
testq %rax, %rax
je 0x9f87
movb $0x0, (%rax)
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x50a0
movq %r12, %rdi
movl $0x2f, %esi
callq 0x5150
testq %rax, %rax
je 0x9fb2
movq %rax, %r15
movb $0x0, (%rax)
incq %r15
jmp 0x9fb9
leaq 0x15784(%rip), %r15     # 0x1f73d
movq %rsp, %r12
movq %r12, %rdi
movl $0x2f, %esi
callq 0x5120
testq %rax, %rax
je 0x9fd1
movb $0x0, (%rax)
leaq 0x1a0(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x50a0
movq %rbp, %rdi
movl $0x2f, %esi
callq 0x5150
testq %rax, %rax
je 0xa001
movq %rax, %rbp
movb $0x0, (%rax)
incq %rbp
jmp 0xa008
leaq 0x15735(%rip), %rbp     # 0x1f73d
leaq 0x1a0(%rsp), %r13
movq %r13, %rdi
movl $0x2f, %esi
callq 0x5120
testq %rax, %rax
je 0xa025
movb $0x0, (%rax)
cmpb $0x0, (%r15)
je 0xa05d
movq %r15, %rdi
movl $0x3a, %esi
callq 0x5120
testq %rax, %rax
jne 0xa05d
movq %r15, %rdi
callq 0x50c0
ucomisd 0xafbb(%rip), %xmm0     # 0x15008
cmovaq %rbp, %r15
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovaeq %rbp, %r15
cmpb $0x0, (%rsp)
je 0xa09b
movq %rsp, %r12
movq %r12, %rdi
movl $0x3a, %esi
callq 0x5120
testq %rax, %rax
jne 0xa09b
movq %rsp, %r12
movq %r12, %rdi
callq 0x50c0
ucomisd 0xaf7d(%rip), %xmm0     # 0x15008
cmovaq %r13, %r12
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovaeq %r13, %r12
cmpb $0x0, (%r12)
cmoveq %rbx, %r12
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x50a0
movq %r13, %rdi
callq 0x5100
movw $0x2f, 0xd0(%rsp,%rax)
cmpb $0x0, (%r15)
cmovneq %r15, %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x52e0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x50a0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq