// File: Mulan-Szechuan-Sauce[P]javelin/src/node.cpp
// Function: NList::NList(NExpressionArgs*)
NList::NList(NExpressionArgs *contents) : contents(contents) {
  // Validate the type of the list - for now, you must have at least one element.
  if (contents == NULL) {
    throw std::runtime_error("No type associated with list declaration");
  } else {
    type = new ListType(contents->expr->get_type());
  }

  Type *itr_type = type->get_itr_type();
  for (contents = contents->next; contents != NULL; contents = contents->next) {
    Type *content_type = contents->expr->get_type();
    if (content_type->cpp_type_string() != itr_type->cpp_type_string()) {
      throw std::runtime_error("Type mismatch in " + itr_type->cpp_type_string() + " list");
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xc9b0
movq -0xe0(%rbp), %rax
leaq 0xbc97(%rip), %rcx      # 0x1ec18
addq $0x10, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x10(%rax)
cmpq $0x0, -0x10(%rbp)
jne 0x12ff3
movl $0x10, %edi
callq 0x5130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
leaq 0x3e26(%rip), %rsi      # 0x16ddb
callq 0x50e0
jmp 0x12fbc
movq -0xe8(%rbp), %rdi
movq 0xc01e(%rip), %rsi      # 0x1efe8
movq 0xbfe7(%rip), %rdx      # 0x1efb8
callq 0x53d0
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x51b0
jmp 0x13240
movl $0x10, %edi
callq 0x5220
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movq %rax, -0xf0(%rbp)
jmp 0x1301c
movq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x10070
jmp 0x13031
movq -0xe0(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x13062
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x5200
jmp 0x13240
movq -0xe0(%rbp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x13237
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x50(%rbp), %rdi
callq *%rax
movq -0x28(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x70(%rbp), %rdi
callq *%rax
jmp 0x130c3
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xcbe0
movb %al, -0xf9(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5190
leaq -0x50(%rbp), %rdi
callq 0x5190
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x130f7
jmp 0x13224
movb $0x1, -0xd1(%rbp)
movl $0x10, %edi
callq 0x5130
movq %rax, -0x108(%rbp)
movq -0x28(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0xd0(%rbp), %rdi
callq *%rax
jmp 0x13124
leaq 0x3cd9(%rip), %rsi      # 0x16e04
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0xcc10
jmp 0x13140
leaq 0x3ccf(%rip), %rdx      # 0x16e16
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xd590
jmp 0x1315c
movq -0x108(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x5390
jmp 0x13171
movq -0x108(%rbp), %rdi
movb $0x0, -0xd1(%rbp)
movq 0xbe62(%rip), %rsi      # 0x1efe8
movq 0xbe2b(%rip), %rdx      # 0x1efb8
callq 0x53d0
jmp 0x13249
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5190
jmp 0x13240
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x1320b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x131ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x131f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5190
leaq -0xb0(%rbp), %rdi
callq 0x5190
leaq -0xd0(%rbp), %rdi
callq 0x5190
testb $0x1, -0xd1(%rbp)
jne 0x13216
jmp 0x13222
movq -0x108(%rbp), %rdi
callq 0x51b0
jmp 0x13240
jmp 0x13226
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x13083
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x5400
nopl (%rax)