// File: /workspace/github_cpp_makefile_star2_O1/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 0x12fc1
movq 0x50(%r12), %rax
movq 0x80(%rax), %rdi
callq 0x4170
cmpq $0x5, %rax
jb 0x12fc1
addl $0x6, %eax
movl %eax, %r15d
movq 0x28(%r12), %rdi
movb $0x1, %bpl
testq %rdi, %rdi
je 0x13000
callq 0x12f8a
movq %rax, %rbx
movq %rax, %rdi
callq 0x4170
addl %eax, %r15d
movq 0x28(%r12), %rax
movl 0x24(%rax), %eax
xorl %r13d, %r13d
leal -0xc(%rax), %ecx
cmpl $0x9, %ecx
jb 0x13005
cmpl $0x6, %eax
je 0x13005
cmpl $0xa, %eax
je 0x13005
jmp 0x13002
xorl %ebx, %ebx
movb $0x1, %r13b
movq 0x30(%r12), %rdi
testq %rdi, %rdi
je 0x13036
callq 0x12f8a
movq %rax, %r14
movq %rax, %rdi
callq 0x4170
addl %eax, %r15d
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
leal -0xc(%rax), %ecx
cmpl $0x9, %ecx
jae 0x13070
xorl %ebp, %ebp
jmp 0x13039
xorl %r14d, %r14d
movslq %r15d, %rdi
callq 0x4040
movq %rax, %r15
movl 0x24(%r12), %eax
decl %eax
cmpl $0x15, %eax
ja 0x133ca
leaq 0x19975(%rip), %rcx     # 0x2c9d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x19a44(%rip), %rsi     # 0x2caaf
jmp 0x1365c
cmpl $0x6, %eax
je 0x13032
cmpl $0xa, %eax
je 0x13032
jmp 0x13039
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1340e
leaq 0x19b16(%rip), %rsi     # 0x2cbb7
jmp 0x13610
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1341a
leaq 0x19afc(%rip), %rsi     # 0x2cbc7
jmp 0x13610
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x13426
leaq 0x19b04(%rip), %rsi     # 0x2cbf9
jmp 0x13610
movb $0x1, %al
movb $0x1, %dl
testb %r13b, %r13b
je 0x1310f
movq 0x28(%r12), %rcx
cmpl $0x1, 0x24(%rcx)
sete %dl
testb %bpl, %bpl
je 0x134db
movq 0x30(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x5, %ecx
ja 0x134d9
movb $0x32, %al
shrb %cl, %al
jmp 0x134db
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x13432
leaq 0x19a81(%rip), %rsi     # 0x2cbd8
jmp 0x13610
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1343e
leaq 0x199d6(%rip), %rsi     # 0x2cb57
jmp 0x13610
movq 0x40(%r12), %rax
movq (%rax), %rdi
jmp 0x133d1
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1344a
leaq 0x199f0(%rip), %rsi     # 0x2cba8
jmp 0x13610
movb $0x1, %al
movb $0x1, %cl
testb %r13b, %r13b
je 0x131d2
movq 0x28(%r12), %rcx
cmpl $0x1, 0x24(%rcx)
sete %cl
testb %bpl, %bpl
je 0x131e3
movq 0x30(%r12), %rax
cmpl $0x1, 0x24(%rax)
sete %al
movl %ecx, %edx
andb %al, %dl
cmpb $0x1, %dl
jne 0x13456
leaq 0x198c0(%rip), %rsi     # 0x2cab7
jmp 0x1365c
movb $0x1, %al
movb $0x1, %dl
testb %r13b, %r13b
je 0x1352a
movq 0x28(%r12), %rcx
movl 0x24(%rcx), %ecx
cmpl $0x8, %ecx
ja 0x13528
movl $0x172, %edx            # imm = 0x172
shrl %cl, %edx
jmp 0x1352a
movsd 0x38(%r12), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12f3b
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1346a
leaq 0x19983(%rip), %rsi     # 0x2cbe8
jmp 0x13610
movq 0x28(%r12), %rax
movq 0x30(%r12), %rdx
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%rdx), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x13476
cmpl $-0x3, %eax
ja 0x13476
leaq 0x198ef(%rip), %rsi     # 0x2cb88
jmp 0x1365c
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
cmpl $0x5, %eax
ja 0x13609
movl $0x32, %ecx
btl %eax, %ecx
jae 0x13609
leaq 0x19817(%rip), %rsi     # 0x2cadb
jmp 0x13610
movq 0x50(%r12), %rax
movq 0x80(%rax), %rdx
leaq 0x1992c(%rip), %rsi     # 0x2cc08
movq %r15, %rdi
jmp 0x13662
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x134b5
leaq 0x198e0(%rip), %rsi     # 0x2cbe9
jmp 0x13610
movb $0x1, %al
movb $0x1, %dl
testb %r13b, %r13b
je 0x135c2
movq 0x28(%r12), %rcx
movl 0x24(%rcx), %ecx
cmpl $0x8, %ecx
ja 0x135c0
movl $0x172, %edx            # imm = 0x172
shrl %cl, %edx
jmp 0x135c2
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x134c1
leaq 0x1987a(%rip), %rsi     # 0x2cbd7
jmp 0x13610
movq 0x28(%r12), %rax
movq 0x30(%r12), %rdx
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%rdx), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x1348b
cmpl $-0x3, %eax
ja 0x1348b
leaq 0x197d7(%rip), %rsi     # 0x2cb68
jmp 0x1365c
movq 0x28(%r12), %rax
movq 0x30(%r12), %rdx
movl 0x24(%rax), %ecx
addl $-0x4, %ecx
movl 0x24(%rdx), %eax
addl $-0x4, %eax
cmpl $-0x3, %ecx
ja 0x134a0
cmpl $-0x3, %eax
ja 0x134a0
leaq 0x19772(%rip), %rsi     # 0x2cb37
jmp 0x1365c
leaq 0x196ca(%rip), %rdi     # 0x2ca9b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd1e5
movq 0x30(%r12), %rax
movl 0x24(%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x134cd
leaq 0x197bd(%rip), %rsi     # 0x2cbc6
jmp 0x13610
leaq 0x197aa(%rip), %rsi     # 0x2cbbf
jmp 0x13610
leaq 0x197af(%rip), %rsi     # 0x2cbd0
jmp 0x13610
leaq 0x197d4(%rip), %rsi     # 0x2cc01
jmp 0x13610
leaq 0x197a8(%rip), %rsi     # 0x2cbe1
jmp 0x13610
leaq 0x1971b(%rip), %rsi     # 0x2cb60
jmp 0x13610
leaq 0x1975f(%rip), %rsi     # 0x2cbb0
jmp 0x13610
testb %cl, %cl
je 0x13514
leaq 0x1965c(%rip), %rsi     # 0x2cac1
jmp 0x1365c
leaq 0x19780(%rip), %rsi     # 0x2cbf1
jmp 0x13610
cmpl $-0x3, %ecx
ja 0x13581
leaq 0x1970c(%rip), %rsi     # 0x2cb92
jmp 0x1365c
cmpl $-0x3, %ecx
ja 0x13596
leaq 0x196d7(%rip), %rsi     # 0x2cb72
jmp 0x1365c
cmpl $-0x3, %ecx
ja 0x135ab
leaq 0x19691(%rip), %rsi     # 0x2cb41
jmp 0x1365c
leaq 0x19736(%rip), %rsi     # 0x2cbf2
jmp 0x13610
leaq 0x19718(%rip), %rsi     # 0x2cbe0
jmp 0x13610
leaq 0x196fb(%rip), %rsi     # 0x2cbcf
jmp 0x13610
xorl %eax, %eax
movl %edx, %ecx
andb %al, %cl
cmpb $0x1, %cl
jne 0x134f0
leaq 0x195ec(%rip), %rsi     # 0x2cad7
jmp 0x1365c
testb %dl, %dl
je 0x13500
leaq 0x195e6(%rip), %rsi     # 0x2cae1
jmp 0x1365c
testb $0x1, %al
je 0x1361f
leaq 0x195da(%rip), %rsi     # 0x2cae9
jmp 0x1365c
testb %al, %al
je 0x13628
leaq 0x195a6(%rip), %rsi     # 0x2cac9
jmp 0x1365c
xorl %edx, %edx
testb %bpl, %bpl
je 0x13547
movq 0x30(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x8, %ecx
ja 0x13545
movl $0x1f2, %eax            # imm = 0x1F2
shrl %cl, %eax
jmp 0x13547
xorl %eax, %eax
movl %edx, %ecx
andb %al, %cl
testb $0x1, %cl
je 0x1355c
leaq 0x195c0(%rip), %rsi     # 0x2cb17
jmp 0x1365c
testb $0x1, %dl
je 0x1356d
leaq 0x195b9(%rip), %rsi     # 0x2cb21
jmp 0x1365c
testb $0x1, %al
je 0x13631
leaq 0x195ad(%rip), %rsi     # 0x2cb29
jmp 0x1365c
cmpl $-0x3, %eax
ja 0x1363a
leaq 0x19609(%rip), %rsi     # 0x2cb9a
jmp 0x1365c
cmpl $-0x3, %eax
ja 0x13643
leaq 0x195d4(%rip), %rsi     # 0x2cb7a
jmp 0x1365c
cmpl $-0x3, %eax
ja 0x1364c
leaq 0x1958e(%rip), %rsi     # 0x2cb49
jmp 0x1365c
xorl %edx, %edx
testb %bpl, %bpl
je 0x135dc
movq 0x30(%r12), %rax
movl 0x24(%rax), %ecx
cmpl $0x6, %ecx
ja 0x135da
movb $0x72, %al
shrb %cl, %al
jmp 0x135dc
xorl %eax, %eax
movl %edx, %ecx
andb %al, %cl
testb $0x1, %cl
je 0x135ee
leaq 0x1950b(%rip), %rsi     # 0x2caf7
jmp 0x1365c
testb $0x1, %dl
je 0x135fc
leaq 0x19507(%rip), %rsi     # 0x2cb01
jmp 0x1365c
testb $0x1, %al
je 0x13655
leaq 0x19502(%rip), %rsi     # 0x2cb09
jmp 0x1365c
leaq 0x194d5(%rip), %rsi     # 0x2cae5
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x40b0
jmp 0x1366c
leaq 0x194cb(%rip), %rsi     # 0x2caf1
jmp 0x1365c
leaq 0x194a2(%rip), %rsi     # 0x2cad1
jmp 0x1365c
leaq 0x194f9(%rip), %rsi     # 0x2cb31
jmp 0x1365c
leaq 0x19561(%rip), %rsi     # 0x2cba2
jmp 0x1365c
leaq 0x19538(%rip), %rsi     # 0x2cb82
jmp 0x1365c
leaq 0x194fe(%rip), %rsi     # 0x2cb51
jmp 0x1365c
leaq 0x194b5(%rip), %rsi     # 0x2cb11
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x40b0
testq %rbx, %rbx
je 0x13679
movq %rbx, %rdi
callq 0x43d0
testq %r14, %r14
je 0x13686
movq %r14, %rdi
callq 0x43d0
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq