// File: hzeller[P]gcode-multi-shell-extrude/multi-shell-extrude.cc
// Function: ReadPolygon(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, double)
Polygon ReadPolygon(const std::string &filename, double factor) {
  Polygon polygon;
  FILE *in = fopen(filename.c_str(), "r");
  if (!in) {
    fprintf(stderr, "Can't open %s\n", filename.c_str());
    return polygon;
  }
  char buffer[256];
  int line = 0;
  while (fgets(buffer, sizeof(buffer), in)) {
    ++line;
    const char *start = buffer;
    while (*start && isspace(*start))
      start++;
    if (*start == '\0' || *start == '#')
      continue;
    Vector2D p;
    if (sscanf(start, "%lf %lf", &p.x, &p.y) == 2) {
      p.x *= factor;
      p.y *= factor;
      polygon.push_back(p);
    } else {
      for (char *end = buffer + strlen(buffer) - 1; isspace(*end); end--) {
        *end = '\0';
      }
      fprintf(stderr, "%s:%d not a comment and not coordinates: '%s'\n",
              filename.c_str(), line, start);
    }
  }
  fclose(in);
  return polygon;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x180(%rbp)
movq %rdi, %rax
movq %rax, -0x178(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x8360
movq -0x10(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
leaq 0x27b89(%rip), %rsi     # 0x2b40e
callq 0x3330
movq %rax, -0x170(%rbp)
jmp 0x3893
movq -0x170(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3904
movq 0x3772c(%rip), %rax     # 0x3afd8
movq (%rax), %rax
movq %rax, -0x188(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30e0
movq -0x188(%rbp), %rdi
movq %rax, %rdx
leaq 0x27834(%rip), %rsi     # 0x2b104
movb $0x0, %al
callq 0x3390
movb $0x1, -0x19(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0x3b10
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x84c0
jmp 0x3b32
movl $0x0, -0x144(%rbp)
movq -0x28(%rbp), %rdx
leaq -0x140(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x33d0
movq %rax, -0x190(%rbp)
jmp 0x392c
movq -0x190(%rbp), %rax
cmpq $0x0, %rax
je 0x3afa
movl -0x144(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x144(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rcx
xorl %eax, %eax
cmpb $0x0, (%rcx)
movb %al, -0x191(%rbp)
je 0x3989
movq -0x150(%rbp), %rax
movsbl (%rax), %edi
callq 0x3050
cmpl $0x0, %eax
setne %al
movb %al, -0x191(%rbp)
movb -0x191(%rbp), %al
testb $0x1, %al
jne 0x3995
jmp 0x39a9
movq -0x150(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x150(%rbp)
jmp 0x395a
movq -0x150(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x39c7
movq -0x150(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x39cc
jmp 0x390e
leaq -0x160(%rbp), %rdi
callq 0x8520
jmp 0x39da
movq -0x150(%rbp), %rdi
leaq -0x160(%rbp), %rdx
leaq -0x160(%rbp), %rcx
addq $0x8, %rcx
leaq 0x27719(%rip), %rsi     # 0x2b113
movb $0x0, %al
callq 0x3250
cmpl $0x2, %eax
jne 0x3a52
movq -0x180(%rbp), %rdi
movsd -0x18(%rbp), %xmm1
movsd -0x160(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp)
movsd -0x18(%rbp), %xmm1
movsd -0x158(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
leaq -0x160(%rbp), %rsi
callq 0x8540
jmp 0x3a4d
jmp 0x3af5
leaq -0x140(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x3100
movq %rax, %rcx
movq -0x1a0(%rbp), %rax
addq %rcx, %rax
addq $-0x1, %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movsbl (%rax), %edi
callq 0x3050
cmpl $0x0, %eax
je 0x3ab6
movq -0x168(%rbp), %rax
movb $0x0, (%rax)
movq -0x168(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x168(%rbp)
jmp 0x3a84
movq 0x3751b(%rip), %rax     # 0x3afd8
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30e0
movq -0x1a8(%rbp), %rdi
movq %rax, %rdx
movl -0x144(%rbp), %ecx
movq -0x150(%rbp), %r8
leaq 0x2762d(%rip), %rsi     # 0x2b11b
movb $0x0, %al
callq 0x3390
jmp 0x390e
movq -0x28(%rbp), %rdi
callq 0x3270
jmp 0x3b05
movb $0x1, -0x19(%rbp)
movl $0x1, -0x38(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x3b22
movq -0x180(%rbp), %rdi
callq 0x84c0
movq -0x178(%rbp), %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3440
nopl (%rax,%rax)