// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x0, 0xa98(%rdi)
je 0x55b2
leaq 0x7cdd(%rip), %rsi      # 0xd287
movq %rbx, %rdi
callq 0x4a19
movq 0xf8(%rbx), %rdi
callq 0xb8bd
movq 0x100(%rbx), %rdi
callq 0xb8bd
movq 0x30(%rbx), %rdi
callq 0xb8bd
movq 0x38(%rbx), %rdi
callq 0xb8bd
movq 0x40(%rbx), %rdi
callq 0xb8bd
movq 0x48(%rbx), %rdi
callq 0xb8bd
movq 0xec0(%rbx), %rdi
callq 0xb8bd
movq 0x170(%rbx), %rdi
callq 0xb8bd
movq 0x180(%rbx), %rdi
callq 0xb8bd
movq 0x178(%rbx), %rdi
callq 0xb8bd
movq 0x188(%rbx), %rdi
callq 0xb8bd
movq 0x70(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0xb8bd
movq 0x108(%rbx), %rdi
callq 0xb8bd
movq %r15, %rdi
callq 0xb8bd
movq %r14, %rdi
callq 0xb8bd
movq 0x90(%rbx), %rax
andl $0x7fff, (%rax)         # imm = 0x7FFF
andq $0x0, 0x168(%rbx)
movq %rax, 0x160(%rbx)
movl 0x28(%rbx), %r15d
pushq $0x30
popq %rbp
testl %r15d, %r15d
js 0x572e
movq 0x20(%rbx), %rcx
movl %r15d, %r12d
movq (%rcx,%r12,8), %rcx
movslq 0xcb0b(%rip), %rdx      # 0x1219c
imulq $0x18, %rdx, %r14
addq %rcx, %r14
addq $-0x18, %r14
cmpq %rcx, %r14
jb 0x5726
movl (%r14), %edx
testw %dx, %dx
jns 0x56b8
andl $0x7fff, %edx           # imm = 0x7FFF
movl %edx, (%r14)
jmp 0x5698
testl %edx, %edx
je 0x5704
andl $0x1f, %edx
cmpl $0xa, %edx
je 0x56cb
cmpl $0x1, %edx
je 0x56e7
jmp 0x56ee
movq 0x8(%r14), %rdi
testb $0x1, (%rdi)
je 0x56eb
cmpl $0x0, 0x10(%rdi)
je 0x56eb
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0xaa1a
movq 0x8(%r14), %rdi
callq *0x8(%rbx)
andl $0x0, (%r14)
movq 0x90(%rbx), %rax
movq %rax, 0x8(%r14)
movq 0x160(%rbx), %rax
incq 0x168(%rbx)
movq %rax, 0x10(%r14)
movq %r14, 0x160(%rbx)
movq 0x20(%rbx), %rax
movq (%rax,%r12,8), %rcx
movq %r14, %rax
jmp 0x5698
decl %r15d
jmp 0x5676
cmpb $0x0, 0xa98(%rbx)
je 0x575d
movq 0x168(%rbx), %rdx
leaq 0x7b48(%rip), %rsi      # 0xd28d
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4a19
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq