// File: /workspace/github_cpp_makefile_star2_O3/srajangarg[P]raytracer/src/core/mathexpr.cpp
// Function: ROperation::Expr() const
char* ROperation::Expr() const
{
  char*s=NULL,*s1=NULL,*s2=NULL;int n=10;signed char f=0,g=0;
  if(op==Fun)if(strlen(pfunc->name)>4)n+=strlen(pfunc->name)-4;
  if(mmb1!=NULL){s1=mmb1->Expr();n+=strlen(s1);f=IsFunction(mmb1->op);}
  if(mmb2!=NULL){s2=mmb2->Expr();n+=strlen(s2);g=IsFunction(mmb2->op);}
  s=new char[n];
  switch(op){
  case Num:return ValToStr(ValC);
  case Var:return CopyStr(pvar->name);
  case Juxt:sprintf(s,"%s , %s",s1,s2);break;
  case Add:
    f=f||(mmb1->op==Juxt);
    g=g||(mmb2->op==Juxt);
    if(f&&g)sprintf(s,"(%s)+(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)+%s",s1,s2);else
	if(g)sprintf(s,"%s+(%s)",s1,s2);else
	  sprintf(s,"%s+%s",s1,s2);
    break;
  case Sub:
    f=f||(mmb1->op==Juxt);
    g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub);
    if(f&&g)sprintf(s,"(%s)-(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)-%s",s1,s2);else
	if(g)sprintf(s,"%s-(%s)",s1,s2);else
	  sprintf(s,"%s-%s",s1,s2);
    break;
  case Opp:
    if(mmb2->op==Add||mmb2->op==Sub||mmb2->op==Juxt)sprintf(s,"-(%s)",s2);else
      sprintf(s,"-%s",s2);
    break;
  case Mult:
    f=f||(mmb1->op==Juxt||mmb1->op==Add||mmb1->op==Sub||mmb1->op==Opp||mmb1->op==Div);
    g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub||mmb2->op==Opp);
    if(f&&g)sprintf(s,"(%s)*(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)*%s",s1,s2);else
	if(g)sprintf(s,"%s*(%s)",s1,s2);else
	  sprintf(s,"%s*%s",s1,s2);
    break;
  case Div:
    f=f||(mmb1->op==Juxt||mmb1->op==Add||mmb1->op==Sub||mmb1->op==Opp||mmb1->op==Div);
    g=g||(mmb2->op==Juxt||mmb2->op==Add||mmb2->op==Sub||mmb2->op==Opp||mmb2->op==Mult||mmb2->op==Div);
    if(f&&g)sprintf(s,"(%s)/(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)/%s",s1,s2);else
	if(g)sprintf(s,"%s/(%s)",s1,s2);else
	  sprintf(s,"%s/%s",s1,s2);
    break;
  case Pow:
    f=(mmb1->op!=Num&&mmb1->op!=Var);
    g=(mmb2->op!=Num&&mmb2->op!=Var);
    if(f&&g)sprintf(s,"(%s)^(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)^%s",s1,s2);else
	if(g)sprintf(s,"%s^(%s)",s1,s2);else
	  sprintf(s,"%s^%s",s1,s2);
    break;
  case Sqrt:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"sqrt(%s)",s2);
    else sprintf(s,"sqrt %s",s2);
    break;
  case NthRoot:
    f=(mmb1->op!=Num&&mmb1->op!=Var);
    g=(mmb2->op!=Num&&mmb2->op!=Var);
    if(f&&g)sprintf(s,"(%s)#(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)#%s",s1,s2);else
	if(g)sprintf(s,"%s#(%s)",s1,s2);else
	  sprintf(s,"%s#%s",s1,s2);
    break;
  case E10:
    f=(mmb1->op!=Num&&mmb1->op!=Var);
    g=(mmb2->op!=Num&&mmb2->op!=Var);
    if(f&&g)sprintf(s,"(%s)E(%s)",s1,s2);else
      if(f)sprintf(s,"(%s)E%s",s1,s2);else
	if(g)sprintf(s,"%sE(%s)",s1,s2);else
	  sprintf(s,"%sE%s",s1,s2);
    break;
  case Ln:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"log(%s)",s2);
    else sprintf(s,"log %s",s2);
    break;
  case Exp:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"exp(%s)",s2);
    else sprintf(s,"exp %s",s2);
    break;
  case Sin:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"sin(%s)",s2);
    else sprintf(s,"sin %s",s2);
    break;
  case Cos:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"cos(%s)",s2);
    else sprintf(s,"cos %s",s2);
    break;
  case Tg:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"tan(%s)",s2);
    else sprintf(s,"tan %s",s2);
    break;
  case Atan:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"atan(%s)",s2);
    else sprintf(s,"atan %s",s2);
    break;
  case Asin:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"asin(%s)",s2);
    else sprintf(s,"asin %s",s2);
    break;
  case Acos:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"acos(%s)",s2);
    else sprintf(s,"acos %s",s2);
    break;
  case Abs:
    g=(mmb2->op!=Num&&mmb2->op!=Var&&!g);
    if(g)sprintf(s,"abs(%s)",s2);
    else sprintf(s,"abs %s",s2);
    break;
  case Fun:
    sprintf(s,"%s(%s)",pfunc->name,s2);
    break;
  default:return CopyStr("Error");
  };
  if(s1!=NULL)delete[] s1;if(s2!=NULL)delete[] s2;
  return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r12
movl $0xa, %r15d
cmpl $0x16, 0x24(%rdi)
jne 0x12b85
movq 0x50(%r12), %rax
movq 0x80(%rax), %rdi
callq 0x4170
cmpq $0x5, %rax
jb 0x12b85
addl $0x6, %eax
movl %eax, %r15d
movq 0x28(%r12), %rdi
movb $0x1, %bpl
testq %rdi, %rdi
je 0x12bc3
callq 0x12b4e
movq %rax, %r14
movq %rax, %rdi
callq 0x4170
addl %eax, %r15d
movq 0x28(%r12), %rax
movl 0x24(%rax), %eax
xorl %ebx, %ebx
leal -0xc(%rax), %ecx
cmpl $0x9, %ecx
jb 0x12bc8
cmpl $0x6, %eax
je 0x12bc8
cmpl $0xa, %eax
je 0x12bc8
jmp 0x12bc6
xorl %r14d, %r14d
movb $0x1, %bl
movq %r14, (%rsp)
movq 0x30(%r12), %rdi
testq %rdi, %rdi
je 0x12bfe
callq 0x12b4e
movq %rax, %r14
movq %rax, %rdi
callq 0x4170
addl %eax, %r15d
movq 0x30(%r12), %r13
movl 0x24(%r13), %eax
leal -0xc(%rax), %ecx
cmpl $0x9, %ecx
jae 0x12c3b
xorl %ebp, %ebp
jmp 0x12c04
xorl %r13d, %r13d
xorl %r14d, %r14d
movslq %r15d, %rdi
callq 0x4040
movq %rax, %r15
movl 0x24(%r12), %eax
decl %eax
cmpl $0x15, %eax
ja 0x12f6e
leaq 0x18d7a(%rip), %rcx     # 0x2b9a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x18e39(%rip), %rsi     # 0x2ba6f
jmp 0x1314b
cmpl $0x6, %eax
je 0x12bfa
cmpl $0xa, %eax
je 0x12bfa
jmp 0x12c04
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x12fae
leaq 0x18f0f(%rip), %rsi     # 0x2bb77
jmp 0x1315b
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x12fba
leaq 0x18ef9(%rip), %rsi     # 0x2bb87
jmp 0x1315b
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x12fc6
leaq 0x18f05(%rip), %rsi     # 0x2bbb9
jmp 0x1315b
movb $0x1, %al
testb %bl, %bl
je 0x12ccb
movq 0x28(%r12), %rax
cmpl $0x1, 0x24(%rax)
sete %al
testb %bpl, %bpl
je 0x12ceb
movl 0x24(%r13), %ecx
cmpl $0x5, %ecx
ja 0x13188
movl $0x32, %edx
btl %ecx, %edx
jae 0x13188
testb %al, %al
je 0x13089
leaq 0x18d9d(%rip), %rsi     # 0x2ba97
jmp 0x1314b
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x12fd2
leaq 0x18e78(%rip), %rsi     # 0x2bb98
jmp 0x1315b
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x12fde
leaq 0x18dd1(%rip), %rsi     # 0x2bb17
jmp 0x1315b
movq 0x40(%r12), %rax
movq (%rax), %rdi
jmp 0x12f75
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x12fea
leaq 0x18def(%rip), %rsi     # 0x2bb68
jmp 0x1315b
movb $0x1, %al
movb $0x1, %cl
testb %bl, %bl
je 0x12d92
movq 0x28(%r12), %rcx
cmpl $0x1, 0x24(%rcx)
sete %cl
testb %bpl, %bpl
je 0x12d9f
cmpl $0x1, 0x24(%r13)
sete %al
movl %ecx, %edx
andb %al, %dl
cmpb $0x1, %dl
jne 0x12ff6
leaq 0x18cc4(%rip), %rsi     # 0x2ba77
jmp 0x1314b
movb $0x1, %al
testb %bl, %bl
je 0x130ab
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x8, %ecx
ja 0x130a9
movl $0x172, %eax            # imm = 0x172
shrl %cl, %eax
jmp 0x130ab
movsd 0x38(%r12), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12afe
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1300e
leaq 0x18d8e(%rip), %rsi     # 0x2bba8
jmp 0x1315b
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%r13), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x1301a
cmpl $-0x3, %eax
ja 0x1301a
leaq 0x18cfe(%rip), %rsi     # 0x2bb48
jmp 0x1314b
movl 0x24(%r13), %eax
cmpl $0x5, %eax
ja 0x13154
movl $0x32, %ecx
btl %eax, %ecx
jae 0x13154
leaq 0x18c2a(%rip), %rsi     # 0x2ba9b
jmp 0x1315b
movq 0x50(%r12), %rax
movq 0x80(%rax), %rdx
leaq 0x18d3f(%rip), %rsi     # 0x2bbc8
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x40b0
jmp 0x13168
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x13065
leaq 0x18ced(%rip), %rsi     # 0x2bba9
jmp 0x1315b
movb $0x1, %al
testb %bl, %bl
je 0x13117
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x8, %ecx
ja 0x13115
movl $0x172, %eax            # imm = 0x172
shrl %cl, %eax
jmp 0x13117
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x13071
leaq 0x18c8e(%rip), %rsi     # 0x2bb97
jmp 0x1315b
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%r13), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x13033
cmpl $-0x3, %eax
ja 0x13033
leaq 0x18bef(%rip), %rsi     # 0x2bb28
jmp 0x1314b
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%r13), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x1304c
cmpl $-0x3, %eax
ja 0x1304c
leaq 0x18b8e(%rip), %rsi     # 0x2baf7
jmp 0x1314b
leaq 0x18ae6(%rip), %rdi     # 0x2ba5b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xce11
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1307d
leaq 0x18bdd(%rip), %rsi     # 0x2bb86
jmp 0x1315b
leaq 0x18bca(%rip), %rsi     # 0x2bb7f
jmp 0x1315b
leaq 0x18bcf(%rip), %rsi     # 0x2bb90
jmp 0x1315b
leaq 0x18bf4(%rip), %rsi     # 0x2bbc1
jmp 0x1315b
leaq 0x18bc8(%rip), %rsi     # 0x2bba1
jmp 0x1315b
leaq 0x18b3b(%rip), %rsi     # 0x2bb20
jmp 0x1315b
leaq 0x18b7f(%rip), %rsi     # 0x2bb70
jmp 0x1315b
testb %cl, %cl
movq (%rsp), %rbx
je 0x13095
leaq 0x18a78(%rip), %rsi     # 0x2ba81
jmp 0x131b7
leaq 0x18b9c(%rip), %rsi     # 0x2bbb1
jmp 0x1315b
cmpl $-0x3, %ecx
movq (%rsp), %rbx
ja 0x130d6
leaq 0x18b24(%rip), %rsi     # 0x2bb52
jmp 0x131b7
cmpl $-0x3, %ecx
movq (%rsp), %rbx
ja 0x130eb
leaq 0x18aeb(%rip), %rsi     # 0x2bb32
jmp 0x131b7
cmpl $-0x3, %ecx
movq (%rsp), %rbx
ja 0x13100
leaq 0x18aa1(%rip), %rsi     # 0x2bb01
jmp 0x131b7
leaq 0x18b46(%rip), %rsi     # 0x2bbb2
jmp 0x1315b
leaq 0x18b28(%rip), %rsi     # 0x2bba0
jmp 0x1315b
leaq 0x18b0b(%rip), %rsi     # 0x2bb8f
jmp 0x1315b
leaq 0x18a19(%rip), %rsi     # 0x2baa9
jmp 0x1314b
testb %al, %al
je 0x13195
leaq 0x189e5(%rip), %rsi     # 0x2ba89
jmp 0x131b7
xorl %eax, %eax
testb %bpl, %bpl
je 0x130c0
movl 0x24(%r13), %ecx
leal -0x4(%rcx), %edx
cmpl $0x5, %edx
jae 0x1316e
testb $0x1, %al
je 0x130cd
leaq 0x18a0c(%rip), %rsi     # 0x2bad7
jmp 0x1314b
leaq 0x18a15(%rip), %rsi     # 0x2bae9
jmp 0x1314b
cmpl $-0x3, %eax
ja 0x1319e
leaq 0x18a74(%rip), %rsi     # 0x2bb5a
jmp 0x131b7
cmpl $-0x3, %eax
ja 0x131a7
leaq 0x18a3f(%rip), %rsi     # 0x2bb3a
jmp 0x131b7
cmpl $-0x3, %eax
ja 0x131b0
leaq 0x189f9(%rip), %rsi     # 0x2bb09
jmp 0x131b7
xorl %eax, %eax
testb %bpl, %bpl
je 0x13137
movl 0x24(%r13), %ecx
cmpl $0x6, %ecx
ja 0x131f3
movl $0x72, %edx
btl %ecx, %edx
jae 0x131f3
testb $0x1, %al
je 0x13144
leaq 0x18975(%rip), %rsi     # 0x2bab7
jmp 0x1314b
leaq 0x1897e(%rip), %rsi     # 0x2bac9
movq %r15, %rdi
movq (%rsp), %rbx
jmp 0x131ba
leaq 0x1894a(%rip), %rsi     # 0x2baa5
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x40b0
movq (%rsp), %rbx
jmp 0x131c7
cmpl $0x1, %ecx
je 0x130c0
testb $0x1, %al
je 0x1321b
leaq 0x1895b(%rip), %rsi     # 0x2bae1
jmp 0x1314b
testb %al, %al
je 0x13203
leaq 0x1890e(%rip), %rsi     # 0x2baa1
jmp 0x1314b
leaq 0x188f5(%rip), %rsi     # 0x2ba91
jmp 0x131b7
leaq 0x189bd(%rip), %rsi     # 0x2bb62
jmp 0x131b7
leaq 0x18994(%rip), %rsi     # 0x2bb42
jmp 0x131b7
leaq 0x1895a(%rip), %rsi     # 0x2bb11
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x40b0
testq %rbx, %rbx
je 0x131d4
movq %rbx, %rdi
callq 0x43c0
testq %r14, %r14
je 0x131e1
movq %r14, %rdi
callq 0x43c0
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, %al
je 0x1320f
leaq 0x188c3(%rip), %rsi     # 0x2bac1
jmp 0x1314b
leaq 0x188a7(%rip), %rsi     # 0x2bab1
jmp 0x1314b
leaq 0x188bb(%rip), %rsi     # 0x2bad1
jmp 0x1314b
leaq 0x188cf(%rip), %rsi     # 0x2baf1
jmp 0x1314b