// File: /workspace/github_c_makefile_star2_O1/RodionGork[P]tinyscheme/scheme.c
// Function: gc
static void gc(scheme * sc, pointer a, pointer b) {
  pointer p;
  int i;

  if (sc->gc_verbose) {
    putstr(sc, "gc...");
  }

  /* mark system globals */
  mark(sc->oblist);
  mark(sc->global_env);

  /* mark current registers */
  mark(sc->args);
  mark(sc->envir);
  mark(sc->code);
  dump_stack_mark(sc);
  mark(sc->value);
  mark(sc->inport);
  mark(sc->save_inport);
  mark(sc->outport);
  mark(sc->loadport);

  /* Mark recent objects the interpreter doesn't know about yet. */
  mark(car(sc->sink));
  /* Mark any older stuff above nested C calls */
  mark(sc->c_nest);

  /* mark variables a, b */
  mark(a);
  mark(b);

  /* garbage collect */
  clrmark(sc->NIL);
  sc->fcells = 0;
  sc->free_cell = sc->NIL;
  /* free-list is kept sorted by address so as to maintain consecutive
     ranges, if possible, for use with vectors. Here we scan the cells
     (which are also kept sorted by address) downwards to build the
     free-list in sorted order.
   */
  for (i = sc->last_cell_seg; i >= 0; i--) {
    p = sc->cell_seg[i] + cell_segsize;
    while (--p >= sc->cell_seg[i]) {
      if (is_mark(p)) {
        clrmark(p);
      } else {
        /* reclaim cell */
        if (typeflag(p) != 0) {
          finalize_cell(sc, p);
          typeflag(p) = 0;
          car(p) = sc->NIL;
        }
        ++sc->fcells;
        cdr(p) = sc->free_cell;
        sc->free_cell = p;
      }
    }
  }

  if (sc->gc_verbose) {
    char msg[80];
    sprintf(msg, "done: %ld cells were recovered.\n", sc->fcells);
    putstr(sc, msg);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x0, 0xa98(%rdi)
je 0x57e8
leaq 0x8ade(%rip), %rsi      # 0xe2be
movq %rbx, %rdi
callq 0x4b29
movq 0xf8(%rbx), %rdi
callq 0xcae2
movq 0x100(%rbx), %rdi
callq 0xcae2
movq 0x30(%rbx), %rdi
callq 0xcae2
movq 0x38(%rbx), %rdi
callq 0xcae2
movq 0x40(%rbx), %rdi
callq 0xcae2
movq 0x48(%rbx), %rdi
callq 0xcae2
movq 0xec0(%rbx), %rdi
callq 0xcae2
movq 0x170(%rbx), %rdi
callq 0xcae2
movq 0x180(%rbx), %rdi
callq 0xcae2
movq 0x178(%rbx), %rdi
callq 0xcae2
movq 0x188(%rbx), %rdi
callq 0xcae2
movq 0x70(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0xcae2
movq 0x108(%rbx), %rdi
callq 0xcae2
movq %r15, %rdi
callq 0xcae2
movq %r14, %rdi
callq 0xcae2
movq 0x90(%rbx), %rax
andl $0x7fff, (%rax)         # imm = 0x7FFF
movq $0x0, 0x168(%rbx)
movq %rax, 0x160(%rbx)
movslq 0x28(%rbx), %r15
testq %r15, %r15
js 0x5985
movq 0x20(%rbx), %rax
movq (%rax,%r15,8), %rcx
movslq 0xd8d8(%rip), %rax      # 0x1319c
leaq (%rax,%rax,2), %rdx
leaq (%rcx,%rdx,8), %rax
addq $-0x18, %rax
cmpq %rcx, %rax
jb 0x5975
leaq (%rcx,%rdx,8), %r12
movq %rax, %r14
movl -0x18(%r12), %eax
testw %ax, %ax
js 0x5901
testl %eax, %eax
je 0x5947
andl $0x1f, %eax
cmpl $0xa, %eax
je 0x590b
cmpl $0x1, %eax
jne 0x5935
addq $-0x10, %r12
jmp 0x592e
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, (%r14)
jmp 0x5960
leaq 0x8(%r14), %r12
movq 0x8(%r14), %rax
testb $0x1, (%rax)
je 0x592e
cmpl $0x0, 0x10(%rax)
je 0x592e
movq %rbx, %rdi
movq %r14, %rsi
movl $0x30, %edx
callq 0xb56f
movq (%r12), %rdi
callq *0x8(%rbx)
movl $0x0, (%r14)
movq 0x90(%rbx), %rax
movq %rax, 0x8(%r14)
incq 0x168(%rbx)
movq 0x160(%rbx), %rax
movq %rax, 0x10(%r14)
movq %r14, 0x160(%rbx)
leaq -0x18(%r14), %rax
movq 0x20(%rbx), %rcx
movq %r14, %r12
cmpq (%rcx,%r15,8), %rax
jae 0x58dd
leaq -0x1(%r15), %rax
testq %r15, %r15
movq %rax, %r15
jg 0x58b5
cmpb $0x0, 0xa98(%rbx)
je 0x59b4
movq 0x168(%rbx), %rdx
leaq 0x8928(%rip), %rsi      # 0xe2c4
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4b29
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq