// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq 0x70(%rsp), %rax
cmpb $0x0, 0xa98(%rax)
je 0x6aa2
movq 0x70(%rsp), %rdi
leaq 0x11b46(%rip), %rsi     # 0x185e3
callq 0x5150
movq 0x70(%rsp), %rax
movq 0xf8(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x100(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rdi
callq 0x16ce0
movq 0x70(%rsp), %rax
movq 0xec0(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x170(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x180(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x178(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x188(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x108(%rax), %rdi
callq 0x16ae0
movq 0x68(%rsp), %rdi
callq 0x16ae0
movq 0x60(%rsp), %rdi
callq 0x16ae0
movq 0x70(%rsp), %rax
movq 0x90(%rax), %rax
movl (%rax), %ecx
andl $0x7fff, %ecx           # imm = 0x7FFF
movl %ecx, (%rax)
movq 0x70(%rsp), %rax
movq $0x0, 0x168(%rax)
movq 0x70(%rsp), %rax
movq 0x90(%rax), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x160(%rax)
movq 0x70(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x54(%rsp)
cmpl $0x0, 0x54(%rsp)
jl 0x6cd3
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x54(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x15d4e(%rip), %rcx     # 0x1c940
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
addq $-0x18, %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rcx
movq 0x20(%rcx), %rcx
movslq 0x54(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
jb 0x6cc1
movq 0x58(%rsp), %rax
movl (%rax), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x6c46
movq 0x58(%rsp), %rax
movl (%rax), %ecx
andl $0x7fff, %ecx           # imm = 0x7FFF
movl %ecx, (%rax)
jmp 0x6cbc
movq 0x58(%rsp), %rax
cmpl $0x0, (%rax)
je 0x6c7f
movq 0x70(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x16d00
movq 0x58(%rsp), %rax
movl $0x0, (%rax)
movq 0x70(%rsp), %rax
movq 0x90(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x70(%rsp), %rax
movq 0x168(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x168(%rax)
movq 0x70(%rsp), %rax
movq 0x160(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x58(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x160(%rax)
jmp 0x6bfe
jmp 0x6cc3
movl 0x54(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x6bce
movq 0x70(%rsp), %rax
cmpb $0x0, 0xa98(%rax)
je 0x6d0b
movq %rsp, %rdi
movq 0x70(%rsp), %rax
movq 0x168(%rax), %rdx
leaq 0x118f2(%rip), %rsi     # 0x185e9
movb $0x0, %al
callq 0x4280
movq 0x70(%rsp), %rdi
movq %rsp, %rsi
callq 0x5150
addq $0x78, %rsp
retq