// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_bitcode_parser.c
// Function: module_globalvar
static void
module_globalvar(ir_unit_t *iu, unsigned int argc, const int64_t *argv)
{
  if(argc < 6)
    parser_error(iu, "Bad number of args for global var def");

  int explicit_type = argv[3] & 2;
  unsigned int type, pointee;


  if(explicit_type) {
    pointee = argv[2];
    type = type_make_pointer(iu, pointee, 0);
    if(type == -1)
      parser_error(iu, "No pointer type for pointee '%s'",
                   type_str_index(iu, pointee));
  } else {
    type = argv[2];
    pointee = type_get_pointee(iu, type);
  }

  // TODO(add the name for global var)
  const int val_id =
    value_create_global(iu, pointee, type, vmir_llvm_alignment(argv[6], 4), argv[0], argv[1]);

  const unsigned int initializer = argv[4];
  if(initializer > 0) {
    ir_initializer_t ii = {val_id, initializer - 1};
    VECTOR_PUSH_BACK(&iu->iu_initializers, ii);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x6, -0xc(%rbp)
jae 0x35907
movq -0x8(%rbp), %rdi
leaq 0xaf70(%rip), %rsi      # 0x40864
movl $0x76, %edx
leaq 0xb0aa(%rip), %rcx      # 0x409aa
movb $0x0, %al
callq 0x18220
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
andq $0x2, %rax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x35975
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
xorl %edx, %edx
callq 0x1e6e0
movl %eax, -0x20(%rbp)
cmpl $-0x1, -0x20(%rbp)
jne 0x35973
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x22560
movq -0x50(%rbp), %rdi
movq %rax, %r8
leaq 0xaf04(%rip), %rsi      # 0x40864
movl $0x81, %edx
leaq 0xb064(%rip), %rcx      # 0x409d0
movb $0x0, %al
callq 0x18220
jmp 0x3598f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x291c0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %edi
movl $0x4, %esi
callq 0x35e50
movq -0x60(%rbp), %rdi
movl -0x58(%rbp), %esi
movl -0x54(%rbp), %edx
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %r8d
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %r9d
callq 0x1e840
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jbe 0x35a9f
movl -0x28(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x2f8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
cmpq 0x300(%rcx), %rax
jbe 0x35a73
movq -0x40(%rbp), %rcx
addq $0x1, %rcx
shlq %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x300(%rax)
movq -0x8(%rbp), %rax
movq 0x300(%rax), %rax
shlq $0x3, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x2f0(%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x3390
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x2f0(%rax)
movq -0x40(%rbp), %rcx
addq $0x1, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x2f8(%rax)
movq -0x8(%rbp), %rax
movq 0x2f0(%rax), %rax
movq -0x40(%rbp), %rcx
movq -0x34(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x35a9f
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)