// File: /workspace/github_cpp_makefile_star2_O2/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, 0x4a89(%rip)     # 0xa104
leaq 0xb0a(%rip), %r12       # 0x618c
movq 0x494f(%rip), %r14      # 0x9fd8
leaq 0xad8(%rip), %r15       # 0x6168
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1050
leal -0x6f(%rax), %ecx
cmpl $0x8, %ecx
ja 0x56bd
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0x10d0
jmp 0x5690
cmpl $0x63, %eax
je 0x56fb
cmpl $0x69, %eax
je 0x5707
cmpl $-0x1, %eax
jne 0x5690
jmp 0x5752
movb $0x1, %r13b
jmp 0x5690
andl $0x0, 0x4a2b(%rip)      # 0xa108
jmp 0x5690
movb $0x1, 0x4a1e(%rip)      # 0xa104
movq (%r14), %rdi
testq %rdi, %rdi
je 0x571c
callq 0x1160
movl %eax, 0x4a07(%rip)      # 0xa100
jmp 0x5690
movl $0x1, 0x4a03(%rip)      # 0xa108
jmp 0x5690
movq (%r14), %rsi
leaq 0x440(%rsp), %rdi
callq 0x10d0
jmp 0x5690
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x1170
cvtsi2sdq 0x8(%rsp), %xmm0
cvtsi2sdq 0x10(%rsp), %xmm1
mulsd 0xa22(%rip), %xmm0      # 0x6160
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x49b3(%rip)      # 0xa100
jmp 0x5690
cmpb $0x0, 0x440(%rsp)
je 0x5855
leaq 0x4999(%rip), %rbx      # 0xa100
leaq 0x8(%rsp), %r14
leaq 0x440(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x258a
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x1170
movq %rbx, %rdi
movq %r14, %rsi
callq 0x28d2
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x1170
testb $0x1, %r13b
je 0x57e8
movq 0x20(%rsp), %rax
subq 0x30(%rsp), %rax
cvtsi2sd %rax, %xmm1
movq 0x28(%rsp), %rax
movsd 0x99c(%rip), %xmm2      # 0x6160
mulsd %xmm2, %xmm1
subq 0x38(%rsp), %rax
cvtsi2sd %rax, %xmm0
addsd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x9b7(%rip), %rdi       # 0x6198
movb $0x1, %al
callq 0x1030
cmpb $0x0, 0x40(%rsp)
je 0x5849
leaq 0x9b1(%rip), %rsi       # 0x61a7
leaq 0x840(%rsp), %rbx
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x48ec(%rip), %rdi      # 0xa100
movq %rbx, %rsi
callq 0x26b8
leaq 0x98c(%rip), %rsi       # 0x61af
leaq 0x840(%rsp), %rbx
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq 0x48bf(%rip), %rdi      # 0xa100
movq %rbx, %rsi
callq 0x276a
leaq 0x8(%rsp), %rdi
callq 0x31cc
jmp 0x5861
leaq 0x95a(%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 0x5877
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x31cc
movq %rbx, %rdi
callq 0x11a0