// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0xa
popq %r15
cmpl $0x16, 0x24(%rdi)
jne 0x10b6b
movq 0x50(%r12), %rax
movq 0x80(%rax), %rdi
callq 0x4150
cmpq $0x5, %rax
jb 0x10b6b
addl $0x6, %eax
movl %eax, %r15d
movq 0x28(%r12), %rdi
movb $0x1, %bpl
testq %rdi, %rdi
je 0x10ba6
callq 0x10b36
movq %rax, %r14
movq %rax, %rdi
callq 0x4150
addl %eax, %r15d
movq 0x28(%r12), %rax
movl 0x24(%rax), %eax
cmpl $0x14, %eax
ja 0x10ba9
movl $0x1ff440, %ecx         # imm = 0x1FF440
btl %eax, %ecx
jae 0x10ba9
xorl %ebx, %ebx
jmp 0x10bab
xorl %r14d, %r14d
movb $0x1, %bl
movq %r14, (%rsp)
movq 0x30(%r12), %rdi
testq %rdi, %rdi
je 0x10be8
callq 0x10b36
movq %rax, %r14
movq %rax, %rdi
callq 0x4150
addl %eax, %r15d
movq 0x30(%r12), %r13
movl 0x24(%r13), %eax
cmpl $0x14, %eax
ja 0x10bee
movl $0x1ff440, %ecx         # imm = 0x1FF440
btl %eax, %ecx
jae 0x10bee
xorl %ebp, %ebp
jmp 0x10bee
xorl %r13d, %r13d
xorl %r14d, %r14d
movslq %r15d, %rdi
callq 0x4040
movq %rax, %r15
movl 0x24(%r12), %eax
decl %eax
cmpl $0x15, %eax
ja 0x10f48
leaq 0x10df0(%rip), %rcx     # 0x21a00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10eaf(%rip), %rsi     # 0x21acf
jmp 0x1112e
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10f88
leaq 0x10f91(%rip), %rsi     # 0x21bd7
jmp 0x1113e
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10f94
leaq 0x10f7b(%rip), %rsi     # 0x21be7
jmp 0x1113e
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10fa0
leaq 0x10f87(%rip), %rsi     # 0x21c19
jmp 0x1113e
movb $0x1, %al
testb %bl, %bl
je 0x10ca9
movq 0x28(%r12), %rax
cmpl $0x1, 0x24(%rax)
sete %al
testb %bpl, %bpl
je 0x10cc7
movl 0x24(%r13), %ecx
cmpl $0x5, %ecx
ja 0x11151
pushq $0x32
popq %rdx
btl %ecx, %edx
jae 0x11151
testb %al, %al
je 0x11063
leaq 0x10e21(%rip), %rsi     # 0x21af7
jmp 0x1112e
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10fac
leaq 0x10efc(%rip), %rsi     # 0x21bf8
jmp 0x1113e
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10fb8
leaq 0x10e55(%rip), %rsi     # 0x21b77
jmp 0x1113e
movq 0x40(%r12), %rax
movq (%rax), %rdi
jmp 0x10f4f
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10fc4
leaq 0x10e73(%rip), %rsi     # 0x21bc8
jmp 0x1113e
movb $0x1, %al
movb $0x1, %cl
testb %bl, %bl
je 0x10d6e
movq 0x28(%r12), %rcx
cmpl $0x1, 0x24(%rcx)
sete %cl
testb %bpl, %bpl
je 0x10d7b
cmpl $0x1, 0x24(%r13)
sete %al
movl %ecx, %edx
andb %al, %dl
cmpb $0x1, %dl
jne 0x10fd0
leaq 0x10d48(%rip), %rsi     # 0x21ad7
jmp 0x1112e
movb $0x1, %al
testb %bl, %bl
je 0x11085
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x8, %ecx
ja 0x11083
movl $0x172, %eax            # imm = 0x172
shrl %cl, %eax
jmp 0x11085
movsd 0x38(%r12), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10ae8
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x10fe8
leaq 0x10e12(%rip), %rsi     # 0x21c08
jmp 0x1113e
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%r13), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x10ff4
cmpl $-0x3, %eax
ja 0x10ff4
leaq 0x10d82(%rip), %rsi     # 0x21ba8
jmp 0x1112e
movl 0x24(%r13), %eax
cmpl $0x5, %eax
ja 0x11137
pushq $0x32
popq %rcx
btl %eax, %ecx
jae 0x11137
leaq 0x10cb0(%rip), %rsi     # 0x21afb
jmp 0x1113e
movq 0x50(%r12), %rax
movq 0x80(%rax), %rdx
leaq 0x10dc5(%rip), %rsi     # 0x21c28
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x40a0
jmp 0x1114b
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1103f
leaq 0x10d73(%rip), %rsi     # 0x21c09
jmp 0x1113e
movb $0x1, %al
testb %bl, %bl
je 0x110fc
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x8, %ecx
ja 0x110fa
movl $0x172, %eax            # imm = 0x172
shrl %cl, %eax
jmp 0x110fc
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1104b
leaq 0x10d14(%rip), %rsi     # 0x21bf7
jmp 0x1113e
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%r13), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x1100d
cmpl $-0x3, %eax
ja 0x1100d
leaq 0x10c75(%rip), %rsi     # 0x21b88
jmp 0x1112e
movq 0x28(%r12), %rax
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%r13), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x11026
cmpl $-0x3, %eax
ja 0x11026
leaq 0x10c14(%rip), %rsi     # 0x21b57
jmp 0x1112e
leaq 0x10b6c(%rip), %rdi     # 0x21abb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbac0
movl 0x24(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x11057
leaq 0x10c63(%rip), %rsi     # 0x21be6
jmp 0x1113e
leaq 0x10c50(%rip), %rsi     # 0x21bdf
jmp 0x1113e
leaq 0x10c55(%rip), %rsi     # 0x21bf0
jmp 0x1113e
leaq 0x10c7a(%rip), %rsi     # 0x21c21
jmp 0x1113e
leaq 0x10c4e(%rip), %rsi     # 0x21c01
jmp 0x1113e
leaq 0x10bc1(%rip), %rsi     # 0x21b80
jmp 0x1113e
leaq 0x10c05(%rip), %rsi     # 0x21bd0
jmp 0x1113e
testb %cl, %cl
movq (%rsp), %rbx
je 0x1106f
leaq 0x10afe(%rip), %rsi     # 0x21ae1
jmp 0x11184
leaq 0x10c22(%rip), %rsi     # 0x21c11
jmp 0x1113e
cmpl $-0x3, %ecx
movq (%rsp), %rbx
ja 0x110bb
leaq 0x10baa(%rip), %rsi     # 0x21bb2
jmp 0x11184
cmpl $-0x3, %ecx
movq (%rsp), %rbx
ja 0x110d0
leaq 0x10b71(%rip), %rsi     # 0x21b92
jmp 0x11184
cmpl $-0x3, %ecx
movq (%rsp), %rbx
ja 0x110e5
leaq 0x10b27(%rip), %rsi     # 0x21b61
jmp 0x11184
leaq 0x10bcc(%rip), %rsi     # 0x21c12
jmp 0x1113e
leaq 0x10bae(%rip), %rsi     # 0x21c00
jmp 0x1113e
leaq 0x10b91(%rip), %rsi     # 0x21bef
jmp 0x1113e
leaq 0x10a9f(%rip), %rsi     # 0x21b09
jmp 0x1112e
testb %al, %al
je 0x11162
leaq 0x10a6b(%rip), %rsi     # 0x21ae9
jmp 0x11184
xorl %eax, %eax
testb %bpl, %bpl
je 0x110a5
movl 0x24(%r13), %ecx
cmpl $0x8, %ecx
ja 0x111d0
movl $0x1f2, %edx            # imm = 0x1F2
btl %ecx, %edx
jae 0x111d0
testb $0x1, %al
je 0x110b2
leaq 0x10a87(%rip), %rsi     # 0x21b37
jmp 0x1112e
leaq 0x10a90(%rip), %rsi     # 0x21b49
jmp 0x1112e
cmpl $-0x3, %eax
ja 0x1116b
leaq 0x10aef(%rip), %rsi     # 0x21bba
jmp 0x11184
cmpl $-0x3, %eax
ja 0x11174
leaq 0x10aba(%rip), %rsi     # 0x21b9a
jmp 0x11184
cmpl $-0x3, %eax
ja 0x1117d
leaq 0x10a74(%rip), %rsi     # 0x21b69
jmp 0x11184
xorl %eax, %eax
testb %bpl, %bpl
je 0x1111a
movl 0x24(%r13), %ecx
cmpl $0x6, %ecx
ja 0x111c0
pushq $0x72
popq %rdx
btl %ecx, %edx
jae 0x111c0
testb $0x1, %al
je 0x11127
leaq 0x109f2(%rip), %rsi     # 0x21b17
jmp 0x1112e
leaq 0x109fb(%rip), %rsi     # 0x21b29
movq %r15, %rdi
movq (%rsp), %rbx
jmp 0x11187
leaq 0x109c7(%rip), %rsi     # 0x21b05
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x40a0
movq (%rsp), %rbx
jmp 0x11194
testb %al, %al
je 0x111e0
leaq 0x109a1(%rip), %rsi     # 0x21b01
jmp 0x1112e
leaq 0x10988(%rip), %rsi     # 0x21af1
jmp 0x11184
leaq 0x10a50(%rip), %rsi     # 0x21bc2
jmp 0x11184
leaq 0x10a27(%rip), %rsi     # 0x21ba2
jmp 0x11184
leaq 0x109ed(%rip), %rsi     # 0x21b71
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x40a0
testq %rbx, %rbx
je 0x111a1
movq %rbx, %rdi
callq 0x43e0
testq %r14, %r14
je 0x111ae
movq %r14, %rdi
callq 0x43e0
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, %al
je 0x111ec
leaq 0x10956(%rip), %rsi     # 0x21b21
jmp 0x1112e
testb $0x1, %al
je 0x111f8
leaq 0x10966(%rip), %rsi     # 0x21b41
jmp 0x1112e
leaq 0x1092a(%rip), %rsi     # 0x21b11
jmp 0x1112e
leaq 0x1093e(%rip), %rsi     # 0x21b31
jmp 0x1112e
leaq 0x10952(%rip), %rsi     # 0x21b51
jmp 0x1112e