// File: /workspace/github_cpp_makefile_star2_O1/sunweilun[P]Delaunay/main.cpp
// Function: main
int main(int argc, char** argv)
{
    char path[1024];
    char inputPath[1024];
    char outputPath[1024];
    outputPath[0] = inputPath[0] = 0;
    bool timing = false;
    bool disp = false;
    int seed = 0;
    int c;
    mesh.setRandomizeFlag(false);
    while((c = getopt(argc, argv, "wcdr::ti:o:")) != -1)
    {
        switch(c)
        {
        case 'd':
            disp = true;
            break;
        case 'i':
            sprintf(inputPath, "%s", optarg);
            break;
        case 'o':
            sprintf(outputPath, "%s", optarg);
            break;
        case 't':
            timing = true;
            break;
        case 'r':
            mesh.setRandomizeFlag(true);
            if(optarg == NULL)
            {
                struct timeval t;
                gettimeofday(&t, NULL);
                mesh.setSeed(unsigned(t.tv_sec*1e6+t.tv_usec));
            }
            else
            {
                seed = atoi(optarg);
                mesh.setSeed(unsigned(seed));
            }
            break;
        case 'w':
            mesh.setMethod(WALKING);
            break;
        case 'c':
            mesh.setMethod(CONFLICT_GRAPH);
            break;
        }
    }
	if(strlen(inputPath) == 0)
	{
		printf("Invalid input path. To know how to use it, please refer to the document.\n");
		return 0;
	}
    std::vector<vec3> v = mesh.loadNodes(inputPath);
    struct timeval ts, te;
    gettimeofday(&ts, NULL);
    mesh.delaunay(v);
    gettimeofday(&te, NULL);
    double dt = (te.tv_sec-ts.tv_sec)*1e6;
    dt += (te.tv_usec-ts.tv_usec);
    if(timing)
        printf("time = %0.3fs\n", dt/(1e6));
    if(strlen(outputPath) > 0)
    {
        sprintf(path, "%s.node", outputPath);
        mesh.outputNodes(path);
        sprintf(path, "%s.ele", outputPath);
        mesh.outputElements(path);
    }
	if(disp)
	{
#if DISPLAY    
        glDisplay(argc, argv);
#endif
	}
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc48, %rsp            # imm = 0xC48
movq %rsi, %rbx
movl %edi, %ebp
xorl %r13d, %r13d
leaq 0x440(%rsp), %rax
movb %r13b, (%rax)
leaq 0x40(%rsp), %rax
movb %r13b, (%rax)
movb %r13b, 0x3441(%rip)     # 0x910c
leaq 0x49a(%rip), %r12       # 0x616c
movq 0x32ff(%rip), %r14      # 0x8fd8
leaq 0x468(%rip), %r15       # 0x6148
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1050
cmpl $0x6e, %eax
jle 0x5d12
addl $-0x6f, %eax
cmpl $0x8, %eax
ja 0x5ce0
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0x10e0
jmp 0x5ce0
cmpl $0x63, %eax
je 0x5d5b
cmpl $0x69, %eax
jne 0x5d6a
movq (%r14), %rsi
leaq 0x440(%rsp), %rdi
callq 0x10e0
jmp 0x5ce0
movb $0x1, %r13b
jmp 0x5ce0
movl $0x0, 0x33d3(%rip)      # 0x9110
jmp 0x5ce0
movb $0x1, 0x33c6(%rip)      # 0x910c
movq (%r14), %rdi
testq %rdi, %rdi
je 0x5d75
callq 0x1170
movl %eax, 0x33af(%rip)      # 0x9108
jmp 0x5ce0
movl $0x1, 0x33ab(%rip)      # 0x9110
jmp 0x5ce0
cmpl $-0x1, %eax
jne 0x5ce0
jmp 0x5db1
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x1180
xorps %xmm0, %xmm0
cvtsi2sdq 0x8(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x10(%rsp), %xmm1
mulsd 0x3a3(%rip), %xmm0      # 0x6140
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x335c(%rip)      # 0x9108
jmp 0x5ce0
cmpb $0x0, 0x440(%rsp)
je 0x5ec7
leaq 0x3342(%rip), %rbx      # 0x9108
leaq 0x8(%rsp), %r14
leaq 0x440(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x301c
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x1180
movq %rbx, %rdi
movq %r14, %rsi
callq 0x339c
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x1180
testb $0x1, %r13b
je 0x5e4d
movq 0x20(%rsp), %rax
subq 0x30(%rsp), %rax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movq 0x28(%rsp), %rax
movsd 0x31a(%rip), %xmm2      # 0x6140
mulsd %xmm2, %xmm1
subq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x332(%rip), %rdi       # 0x6178
movb $0x1, %al
callq 0x1030
cmpb $0x0, 0x40(%rsp)
je 0x5eae
leaq 0x32c(%rip), %rsi       # 0x6187
leaq 0x840(%rsp), %rbx
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x328f(%rip), %rdi      # 0x9108
movq %rbx, %rsi
callq 0x315e
leaq 0x307(%rip), %rsi       # 0x618f
leaq 0x840(%rsp), %rbx
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x3262(%rip), %rdi      # 0x9108
movq %rbx, %rsi
callq 0x31fc
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5ed3
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x1110
jmp 0x5ed3
leaq 0x2c8(%rip), %rdi       # 0x6196
callq 0x1160
xorl %eax, %eax
addq $0xc48, %rsp            # imm = 0xC48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5ee9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5f03
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x1110
movq %rbx, %rdi
callq 0x11b0
nop