// File: /workspace/github_c_makefile_star2_O3/sisshiki1969[P]monocc/src/monocc.c
// Function: compile
void compile(char *file) {
  ty_int.ty = INT;
  ty_uint.ty = UINT;
  ty_short.ty = SHORT;
  ty_ushort.ty = USHORT;
  ty_long.ty = LONG;
  ty_ulong.ty = ULONG;
  ty_char.ty = CHAR;
  ty_bool.ty = BOOL;
  ty_void.ty = VOID;

  char *s = "__builtin_va_start";
  Token *t = create_token(TK_IDENT, s, strlen(s));
  Function *f = new_func(t, new_type_func(new_type_void()), NULL);
  f->type->variadic = true;

  tokenize(file, source_text, true);
  pp();

  strings = vec_new();
  parse_program();
  if (verbose) {
    print_tokens(output, token);

    print_globals();
    print_funcs();
    print_strings();
    print_structs();
    print_typedefs();
    fprintf(output, "\n");
  }

  fprintf(output, "\t.intel_syntax noprefix\n");

  fprintf(output, "\t.data\n");
  Global *global = globals;

  for (; global; global = global->next) {
    if (global->is_extern) {
      continue;
    }
    fprintf(output, "\t.global %.*s\n", global->token->len, global->token->str);
    fprintf(output, "%.*s:\n", global->token->len, global->token->str);
    emit_global(global->type, global->body);
  };

  int i = 0;
  while (i < vec_len(strings)) {
    Node *node = strings->data[i];
    fprintf(output, ".LS%06d:\n", node->str_id);
    fprintf(output, "\t.string \"");
    for (Token *t = node->token; t; t = t->next) {
      fprintf(output, "%.*s", t->len, t->str);
    }
    fprintf(output, "\"\n");
    i++;
  }
  fprintf(output, "\n");
  if (verbose) {
    for (FileInfo *fi = file_informations; fi; fi = fi->next) {
      int no = fi->no;
      char *name = fi->file_name;
      int len = strlen(name);
      fprintf(output, "\t.file %d \"%.*s\"\n", no, len, name);
    }
  }

  fprintf(output, "\t.text\n");

  int len = vec_len(ext_declarations);
  for (int i = 0; i < len; i++) {
    Node *node = ext_declarations->data[i];
    fprintf(output, "\t.global %.*s\n", node->token->len, node->token->str);
    gen_stmt(node);
  }
  fprintf(stderr, "monocc: compile complete\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x11eef(%rip), %rax     # 0x13288
movl $0x5, (%rax)
leaq 0x11f22(%rip), %rax     # 0x132c8
movl $0x6, (%rax)
leaq 0x11f55(%rip), %rax     # 0x13308
movl $0x3, (%rax)
leaq 0x11f88(%rip), %rax     # 0x13348
movl $0x4, (%rax)
leaq 0x11fbb(%rip), %rax     # 0x13388
movl $0x7, (%rax)
leaq 0x11fee(%rip), %rax     # 0x133c8
movl $0x8, (%rax)
leaq 0x12021(%rip), %rax     # 0x13408
movl $0x1, (%rax)
leaq 0x12054(%rip), %rax     # 0x13448
movl $0x2, (%rax)
leaq 0x12087(%rip), %rax     # 0x13488
andl $0x0, (%rax)
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x10d0
movq %rax, %r14
leaq 0xb122(%rip), %rax      # 0xc53b
movq %rax, 0x20(%r14)
movl $0x12, 0x28(%r14)
xorl %eax, %eax
callq 0xac88
movq %rax, %rdi
callq 0xacdc
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x63b0
movq 0x10(%rax), %rax
movb $0x1, 0x38(%rax)
movq 0x11dc0(%rip), %rsi     # 0x13210
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x970d
xorl %eax, %eax
callq 0x92c4
xorl %eax, %eax
callq 0x3f0c
movq %rax, 0x11da8(%rip)     # 0x13218
xorl %eax, %eax
callq 0x8d51
leaq 0x11d82(%rip), %rax     # 0x13200
cmpb $0x1, (%rax)
jne 0x14c8
movq 0x11d96(%rip), %rdi     # 0x13220
movq 0x11d97(%rip), %rsi     # 0x13228
callq 0x401b
xorl %eax, %eax
callq 0x4c84
xorl %eax, %eax
callq 0x4d07
xorl %eax, %eax
callq 0x4d81
xorl %eax, %eax
callq 0x4e56
xorl %eax, %eax
callq 0x4faf
movq 0x11d60(%rip), %rsi     # 0x13220
pushq $0xa
popq %rdi
callq 0x10c0
movq 0x11d51(%rip), %rcx     # 0x13220
leaq 0xbc17(%rip), %rdi      # 0xd0ed
pushq $0x18
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1190
movq 0x11d35(%rip), %rcx     # 0x13220
leaq 0xbc14(%rip), %rdi      # 0xd106
pushq $0x7
popq %rsi
movq %rbx, %rdx
callq 0x1190
movq 0x11d2c(%rip), %r15     # 0x13230
testq %r15, %r15
je 0x156b
leaq 0xbbfe(%rip), %rbx      # 0xd10e
leaq 0xac7d(%rip), %r14      # 0xc194
cmpb $0x0, 0x20(%r15)
jne 0x1563
movq 0x11cfb(%rip), %rdi     # 0x13220
movq 0x8(%r15), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10f0
movq 0x11cdf(%rip), %rdi     # 0x13220
movq 0x8(%r15), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
movq %r14, %rsi
xorl %eax, %eax
callq 0x10f0
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
callq 0x3b5b
movq (%r15), %r15
testq %r15, %r15
jne 0x1517
movq 0x11ca6(%rip), %rdi     # 0x13218
callq 0x3f3a
testl %eax, %eax
jle 0x162e
pushq $0x1
popq %r12
leaq 0xbbac(%rip), %r13      # 0xd136
pushq $0x2
popq %rbp
leaq 0xb504(%rip), %rbx      # 0xca98
xorl %r14d, %r14d
movq 0x11c7a(%rip), %rax     # 0x13218
movq (%rax), %rax
movq (%rax,%r14,8), %r15
movq 0x11c74(%rip), %rdi     # 0x13220
movl 0x28(%r15), %edx
leaq 0xbb66(%rip), %rsi      # 0xd11d
xorl %eax, %eax
callq 0x10f0
movq 0x11c5b(%rip), %rcx     # 0x13220
leaq 0xb4c1(%rip), %rdi      # 0xca8d
pushq $0xa
popq %rsi
movq %r12, %rdx
callq 0x1190
movq 0x50(%r15), %r15
testq %r15, %r15
je 0x15ff
movq 0x11c39(%rip), %rdi     # 0x13220
movl 0x28(%r15), %edx
movq 0x20(%r15), %rcx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10f0
movq 0x8(%r15), %r15
jmp 0x15db
movq 0x11c1a(%rip), %rcx     # 0x13220
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x1190
incq %r14
movq 0x11bfa(%rip), %rdi     # 0x13218
callq 0x3f3a
cltq
cmpq %rax, %r14
jl 0x1597
movq 0x11beb(%rip), %rsi     # 0x13220
pushq $0xa
popq %rdi
callq 0x10c0
movq 0x11bc4(%rip), %r15     # 0x13208
testq %r15, %r15
setne %al
leaq 0x11baf(%rip), %rcx     # 0x13200
andb (%rcx), %al
cmpb $0x1, %al
jne 0x168e
leaq 0xbac9(%rip), %rbx      # 0xd127
movl 0x20(%r15), %ebp
movq 0x8(%r15), %r14
movq %r14, %rdi
callq 0x1090
movq 0x11bab(%rip), %rdi     # 0x13220
movq %rbx, %rsi
movl %ebp, %edx
movl %eax, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x10f0
movq (%r15), %r15
testq %r15, %r15
jne 0x165e
movq 0x11b8b(%rip), %rcx     # 0x13220
leaq 0xba9d(%rip), %rdi      # 0xd139
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movq 0x11b8a(%rip), %rdi     # 0x13238
callq 0x3f3a
testl %eax, %eax
jle 0x16fe
movl %eax, %r15d
leaq 0xba4d(%rip), %rbx      # 0xd10e
xorl %r12d, %r12d
movq 0x11b6d(%rip), %rax     # 0x13238
movq (%rax), %rax
movq (%rax,%r12,8), %r14
movq 0x11b47(%rip), %rdi     # 0x13220
movq 0x50(%r14), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10f0
movq %r14, %rdi
callq 0x29d8
incq %r12
cmpq %r12, %r15
jne 0x16c4
movq 0x118f3(%rip), %rax     # 0x12ff8
movq (%rax), %rcx
leaq 0xba32(%rip), %rdi      # 0xd141
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1190