// File: /workspace/github_cpp_makefile_star2_O3/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, 0x35a5(%rip)     # 0x9104
leaq 0x626(%rip), %r12       # 0x618c
movq 0x346b(%rip), %r14      # 0x8fd8
leaq 0x5f4(%rip), %r15       # 0x6168
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1050
cmpl $0x6e, %eax
jle 0x5ba6
addl $-0x6f, %eax
cmpl $0x8, %eax
ja 0x5b74
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0x10d0
jmp 0x5b74
cmpl $0x63, %eax
je 0x5bef
cmpl $0x69, %eax
jne 0x5bfe
movq (%r14), %rsi
leaq 0x440(%rsp), %rdi
callq 0x10d0
jmp 0x5b74
movb $0x1, %r13b
jmp 0x5b74
movl $0x0, 0x3537(%rip)      # 0x9108
jmp 0x5b74
movb $0x1, 0x352a(%rip)      # 0x9104
movq (%r14), %rdi
testq %rdi, %rdi
je 0x5c09
callq 0x1160
movl %eax, 0x3513(%rip)      # 0x9100
jmp 0x5b74
movl $0x1, 0x350f(%rip)      # 0x9108
jmp 0x5b74
cmpl $-0x1, %eax
jne 0x5b74
jmp 0x5c45
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x1170
xorps %xmm0, %xmm0
cvtsi2sdq 0x8(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x10(%rsp), %xmm1
mulsd 0x52f(%rip), %xmm0      # 0x6160
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x34c0(%rip)      # 0x9100
jmp 0x5b74
cmpb $0x0, 0x440(%rsp)
je 0x5d5b
leaq 0x34a6(%rip), %rbx      # 0x9100
leaq 0x8(%rsp), %r14
leaq 0x440(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e8c
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x1170
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31f6
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x1170
testb $0x1, %r13b
je 0x5ce1
movq 0x20(%rsp), %rax
subq 0x30(%rsp), %rax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movq 0x28(%rsp), %rax
movsd 0x4a6(%rip), %xmm2      # 0x6160
mulsd %xmm2, %xmm1
subq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x4be(%rip), %rdi       # 0x6198
movb $0x1, %al
callq 0x1030
cmpb $0x0, 0x40(%rsp)
je 0x5d42
leaq 0x4b8(%rip), %rsi       # 0x61a7
leaq 0x840(%rsp), %rbx
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x33f3(%rip), %rdi      # 0x9100
movq %rbx, %rsi
callq 0x2fc8
leaq 0x493(%rip), %rsi       # 0x61af
leaq 0x840(%rsp), %rbx
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x33c6(%rip), %rdi      # 0x9100
movq %rbx, %rsi
callq 0x3066
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5d67
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
jmp 0x5d67
leaq 0x454(%rip), %rdi       # 0x61b6
callq 0x1150
xorl %eax, %eax
addq $0xc48, %rsp            # imm = 0xC48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5d7d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5d97
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq %rbx, %rdi
callq 0x11a0
nop