// File: /workspace/github_cpp_makefile_star2_O3/rofl0r[P]ascc/cs_prepro.cpp
// Function: remove_comments(char*)
void remove_comments(char*trf) {
  char tbuffer[MAX_LINE_LENGTH];
  if (in_comment) {  // already in a multi-line comment
    char*cmend=strstr(trf,"*/");
    if (cmend!=NULL) {
      cmend+=2;
      strcpy(tbuffer,cmend);
      strcpy(trf,tbuffer);
      in_comment=0;
      }
    else {
      trf[0]=0;
      return;   // still in the comment
      }
    }
  char*strpt = trf;
  char*comment_start = trf;
  while (strpt[0]!=0) {
    if ((strpt[0] == '\"') && (in_comment == 0)) {
      strpt++;
      while ((strpt[0] != '\"') && (strpt[0]!=0)) strpt++;
      if (strpt[0]==0) break;
      }

    if ((strncmp(strpt,"//",2)==0) && (in_comment == 0)) {
      strpt[0]=0;  // chop off the end of the line
      break;
      }
    if ((strncmp(strpt,"/*",2)==0) && (in_comment == 0)) {
      in_comment = 1;
      comment_start = strpt;
      strpt += 2;
    }
    if ((strncmp(strpt,"*/",2)==0) && (in_comment == 1)) {
      comment_start[0]=0;
      strcpy(tbuffer,trf);
      int carryonat = strlen(tbuffer);
      strcat(tbuffer,&strpt[2]);
      strcpy(trf,tbuffer);
      strpt = &trf[carryonat];
      in_comment = 0;
    }
    else if (strpt[0] != 0)
      strpt++;
  }
  if (in_comment) comment_start[0] = 0;

  // remove leading spaces and tabs on line
  strpt = trf;
  while ((strpt[0] == ' ') || (strpt[0] == '\t'))
    strpt++;
  strcpy(tbuffer,strpt);
  strcpy(trf,tbuffer);

  // remove trailing spaces on line
  if (strlen(trf) > 0) {
    while (trf[strlen(trf)-1]==' ') trf[strlen(trf)-1]=0;
    }
  }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdi, %rbx
cmpl $0x0, 0x1a08a(%rip)     # 0x31494
je 0x1744b
leaq 0x5e7e(%rip), %rsi      # 0x1d291
movq %rbx, %rdi
callq 0x30e0
testq %rax, %rax
je 0x17571
addq $0x2, %rax
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x32d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
movl $0x0, 0x1a049(%rip)     # 0x31494
movb (%rbx), %dl
testb %dl, %dl
je 0x17588
xorl %eax, %eax
movq %rsp, %r14
movq %rbx, %rcx
movq %rbx, %r13
cmpb $0x22, %dl
sete %sil
testl %eax, %eax
sete %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x1748f
movzbl 0x1(%r13), %edx
testl %edx, %edx
je 0x17588
incq %r13
cmpl $0x22, %edx
jne 0x17476
movb $0x2a, %dl
jmp 0x174e1
cmpb $0x2f, %dl
jne 0x174e6
testl %eax, %eax
sete %dl
cmpb $0x2f, 0x1(%r13)
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
je 0x17576
testl %eax, %eax
sete %dl
cmpb $0x2a, 0x1(%r13)
sete %sil
andb %dl, %sil
movb $0x2a, %dl
cmpb $0x1, %sil
jne 0x174e1
movl $0x1, 0x19fc2(%rip)     # 0x31494
leaq 0x2(%r13), %r15
movb 0x2(%r13), %dl
movl $0x1, %eax
jmp 0x174ec
movq %r13, %r15
jmp 0x1755a
movq %r13, %r15
movq %rcx, %r13
cmpb $0x2a, %dl
jne 0x17557
cmpb $0x2f, 0x1(%r15)
sete %cl
cmpl $0x1, %eax
sete %sil
andb %cl, %sil
movb $0x2a, %dl
cmpb $0x1, %sil
jne 0x17557
movb $0x0, (%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x31a0
movq %rax, %r12
addq $0x2, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3570
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
movslq %r12d, %r15
addq %rbx, %r15
movl $0x0, 0x19f44(%rip)     # 0x31494
xorl %eax, %eax
movq %r13, %rcx
jmp 0x17561
movq %r13, %rcx
cmpb $0x1, %dl
sbbq $-0x1, %r15
movb (%r15), %dl
movq %r15, %r13
testb %dl, %dl
jne 0x17460
jmp 0x17581
movb $0x0, (%rbx)
jmp 0x175e8
movb $0x0, (%r13)
movl 0x19f13(%rip), %eax     # 0x31494
testl %eax, %eax
je 0x17588
movb $0x0, (%rcx)
movq %rbx, %rsi
movzbl (%rsi), %eax
cmpl $0x20, %eax
je 0x17598
cmpl $0x9, %eax
jne 0x1759d
incq %rsi
jmp 0x1758b
movq %rsp, %r14
movq %r14, %rdi
callq 0x32d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
cmpb $0x0, (%rbx)
je 0x175e8
movq %rbx, %rdi
callq 0x31a0
cmpb $0x20, -0x1(%rbx,%rax)
jne 0x175e8
leaq -0x1(%rbx), %r14
leaq (%rbx,%rax), %rcx
decq %rcx
movb $0x0, (%rcx)
movq %rbx, %rdi
callq 0x31a0
leaq (%r14,%rax), %rcx
cmpb $0x20, -0x1(%rbx,%rax)
je 0x175d2
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq