// File: /workspace/github_cpp_makefile_star2_O3/rurban[P]dgnlib/dgndump.c
// Function: main
int main( int argc, char ** argv )

{
    DGNHandle   hDGN;
    DGNElemCore *psElement;
    const char  *pszFilename = NULL;
    int         bSummary = FALSE, iArg, bRaw = FALSE, bReportExtents = FALSE;
    char        achRaw[128];
    double      dfSFXMin=0.0, dfSFXMax=0.0, dfSFYMin=0.0, dfSFYMax=0.0;

    memset( achRaw, 0, 128 );

    for( iArg = 1; iArg < argc; iArg++ )
    {
        if( strcmp(argv[iArg],"-s") == 0 )
        {
            bSummary = TRUE;
        }
        else if( strcmp(argv[iArg],"-e") == 0 && iArg < argc-4 )
        {
            dfSFXMin = atof(argv[iArg+1]);
            dfSFYMin = atof(argv[iArg+2]);
            dfSFXMax = atof(argv[iArg+3]);
            dfSFYMax = atof(argv[iArg+4]);
            iArg += 4;
        }
        else if( strcmp(argv[iArg],"-r") == 0 && iArg < argc-1 )
        {
            achRaw[MAX(0,MIN(127,atoi(argv[iArg+1])))] = 1;
            bRaw = TRUE;
            iArg++;
        }
        else if( strcmp(argv[iArg],"-extents") == 0 )
        {
            bReportExtents = TRUE;
        }
        else if( argv[iArg][0] == '-' || pszFilename != NULL )
            Usage();
        else 
            pszFilename = argv[iArg];
    }

    if( pszFilename == NULL )
        Usage();

    hDGN = DGNOpen( pszFilename, FALSE );
    if( hDGN == NULL )
        exit( 1 );

    if( bRaw )
        DGNSetOptions( hDGN, DGNO_CAPTURE_RAW_DATA );

    DGNSetSpatialFilter( hDGN, dfSFXMin, dfSFYMin, dfSFXMax, dfSFYMax );

    if( !bSummary )
    {
        while( (psElement=DGNReadElement(hDGN)) != NULL )
        {
            DGNDumpElement( hDGN, psElement, stdout );

            CPLAssert( psElement->type >= 0 && psElement->type < 128 );

            if( achRaw[psElement->type] != 0 )
                DGNDumpRawElement( hDGN, psElement, stdout );

            if( bReportExtents )
            {
                DGNPoint sMin, sMax;
                if( DGNGetElementExtents( hDGN, psElement, &sMin, &sMax ) )
                    printf( "  Extents: (%.6f,%.6f,%.6f)\n"
                            "        to (%.6f,%.6f,%.6f)\n",
                            sMin.x, sMin.y, sMin.z, 
                            sMax.x, sMax.y, sMax.z );
            }

            DGNFreeElement( hDGN, psElement );
        }
    }
    else
    {
        const DGNElementInfo    *pasEI;
        int                     nCount, i, nLevel, nType;
        int                     anLevelTypeCount[128*64];
        int                     anLevelCount[64];
        int                     anTypeCount[128];
        double                  adfExtents[6];

        DGNGetExtents( hDGN, adfExtents );
        printf( "X Range: %.2f to %.2f\n", 
                adfExtents[0], adfExtents[3] );
        printf( "Y Range: %.2f to %.2f\n", 
                adfExtents[1], adfExtents[4] );
        printf( "Z Range: %.2f to %.2f\n", 
                adfExtents[2], adfExtents[5] );

        pasEI = DGNGetElementIndex( hDGN, &nCount );

        printf( "Total Elements: %d\n", nCount );
        
        memset( anLevelTypeCount, 0, 128*64*sizeof(int) );
        memset( anLevelCount, 0, 64*sizeof(int) );
        memset( anTypeCount, 0, 128*sizeof(int) );

        for( i = 0; i < nCount; i++ )
        {
            anLevelTypeCount[pasEI[i].level * 128 + pasEI[i].type]++;
            anLevelCount[pasEI[i].level]++;
            anTypeCount[pasEI[i].type]++;
        }

        printf( "\n" );
        printf( "Per Type Report\n" );
        printf( "===============\n" );

        for( nType = 0; nType < 128; nType++ )
        {
            if( anTypeCount[nType] != 0 )
            {
                printf( "Type %s: %d\n", 
                        DGNTypeToName( nType ), 
                        anTypeCount[nType] );
            }
        }

        printf( "\n" );
        printf( "Per Level Report\n" );
        printf( "================\n" );

        for( nLevel = 0; nLevel < 64; nLevel++ )
        {
            if( anLevelCount[nLevel] == 0 )
                continue;

            printf( "Level %d, %d elements:\n", 
                    nLevel, 
                    anLevelCount[nLevel] );

            for( nType = 0; nType < 128; nType++ )
            {
                if( anLevelTypeCount[nLevel * 128 + nType] != 0 )
                {
                    printf( "  Type %s: %d\n", 
                            DGNTypeToName( nType ), 
                            anLevelTypeCount[nLevel*128 + nType] );
                }
            }

            printf( "\n" );
        }
    }

    DGNClose( hDGN );

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8408, %rsp           # imm = 0x8408
movq %rsi, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
cmpl $0x2, %edi
jl 0x2cc6
leal -0x4(%rdi), %eax
movl %eax, -0x4c(%rbp)
leal -0x1(%rdi), %eax
movl %eax, -0x48(%rbp)
movl $0x1, %r15d
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorl %r12d, %r12d
movsd %xmm0, -0x68(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq %rdi, -0x30(%rbp)
movslq %r15d, %r14
movq -0x38(%rbp), %rax
movq (%rax,%r14,8), %r13
movb (%r13), %bl
cmpb $0x2d, %bl
jne 0x2869
cmpb $0x73, 0x1(%r13)
jne 0x27a7
cmpb $0x0, 0x2(%r13)
je 0x28a3
cmpb $0x65, 0x1(%r13)
jne 0x2811
cmpb $0x0, 0x2(%r13)
sete %al
cmpl -0x4c(%rbp), %r15d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2811
movq -0x38(%rbp), %rbx
movq 0x8(%rbx,%r14,8), %rdi
callq 0x2390
movsd %xmm0, -0x70(%rbp)
movq 0x10(%rbx,%r14,8), %rdi
callq 0x2390
movsd %xmm0, -0x68(%rbp)
movq 0x18(%rbx,%r14,8), %rdi
callq 0x2390
movsd %xmm0, -0x60(%rbp)
addl $0x4, %r15d
movq 0x20(%rbx,%r14,8), %rdi
callq 0x2390
movq -0x30(%rbp), %rdi
movsd %xmm0, -0x58(%rbp)
jmp 0x28aa
cmpb $0x72, 0x1(%r13)
jne 0x2869
cmpb $0x0, 0x2(%r13)
sete %al
cmpl -0x48(%rbp), %r15d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2869
incl %r15d
movq -0x38(%rbp), %rax
movq 0x8(%rax,%r14,8), %rdi
callq 0x2480
movq -0x30(%rbp), %rdi
cmpl $0x7f, %eax
movl $0x7f, %ecx
cmovgel %ecx, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movb $0x1, -0x100(%rbp,%rax)
movl $0x1, -0x3c(%rbp)
jmp 0x28aa
movq %r13, %rdi
leaq 0xc791(%rip), %rsi      # 0xf004
callq 0x2400
testl %eax, %eax
je 0x2896
cmpb $0x2d, %bl
movq -0x30(%rbp), %rdi
je 0x2cc6
testq %r12, %r12
movq %r13, %r12
je 0x28aa
jmp 0x2cc6
movl $0x1, -0x44(%rbp)
movq -0x30(%rbp), %rdi
jmp 0x28aa
movl $0x1, -0x40(%rbp)
incl %r15d
cmpl %edi, %r15d
jl 0x277d
testq %r12, %r12
je 0x2cc6
movq %r12, %rdi
xorl %esi, %esi
callq 0xe0d6
testq %rax, %rax
je 0x2ccb
movq %rax, %r15
cmpl $0x0, -0x3c(%rbp)
je 0x28e8
movq %r15, %rdi
movl $0x1, %esi
callq 0xe247
movq %r15, %rdi
movsd -0x70(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movsd -0x58(%rbp), %xmm3
callq 0xe24e
cmpl $0x0, -0x40(%rbp)
movq %r15, -0x30(%rbp)
je 0x2afb
leaq -0x130(%rbp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0xaefc
movsd (%rbx), %xmm0
movsd 0x18(%rbx), %xmm1
leaq 0xc712(%rip), %rdi      # 0xf046
movb $0x2, %al
callq 0x2050
movsd 0x8(%rbx), %xmm0
movsd 0x20(%rbx), %xmm1
leaq 0xc711(%rip), %rdi      # 0xf05d
movb $0x2, %al
callq 0x2050
movsd 0x10(%rbx), %xmm0
movsd 0x28(%rbx), %xmm1
leaq 0xc710(%rip), %rdi      # 0xf074
movb $0x2, %al
callq 0x2050
movq %r15, %rdi
leaq -0x74(%rbp), %r15
movq %r15, %rsi
callq 0xaed0
movq %rax, %rbx
movl (%r15), %esi
leaq 0xc704(%rip), %rdi      # 0xf08b
xorl %eax, %eax
callq 0x2050
leaq -0x8430(%rbp), %r14
movl $0x8000, %edx           # imm = 0x8000
movq %r14, %rdi
xorl %esi, %esi
callq 0x2160
leaq -0x430(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2160
leaq -0x330(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x2160
movslq (%r15), %rax
testq %rax, %rax
jle 0x2a04
shlq $0x4, %rax
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
movzbl 0x1(%rbx,%rcx), %esi
incl -0x430(%rbp,%rdx,4)
shll $0x7, %edx
addl %esi, %edx
incl -0x8430(%rbp,%rdx,4)
incl -0x330(%rbp,%rsi,4)
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x29d8
movl $0xa, %edi
callq 0x23f0
leaq 0xc6d3(%rip), %rdi      # 0xf0e8
callq 0x2460
leaq 0xc6e9(%rip), %rdi      # 0xf10a
callq 0x2460
leaq 0xc68c(%rip), %rbx      # 0xf0b9
xorl %r15d, %r15d
movl -0x330(%rbp,%r15,4), %r12d
testl %r12d, %r12d
je 0x2a55
movl %r15d, %edi
callq 0x8333
movq %rbx, %rdi
movq %rax, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2050
incq %r15
cmpq $0x80, %r15
jne 0x2a30
movl $0xa, %edi
callq 0x23f0
leaq 0xc686(%rip), %rdi      # 0xf0f8
callq 0x2460
leaq 0xc68b(%rip), %rdi      # 0xf109
callq 0x2460
leaq 0xc62d(%rip), %r15      # 0xf0b7
xorl %r12d, %r12d
movl -0x430(%rbp,%r12,4), %edx
testl %edx, %edx
je 0x2ae2
leaq 0xc5ff(%rip), %rdi      # 0xf09f
movl %r12d, %esi
xorl %eax, %eax
callq 0x2050
xorl %r13d, %r13d
movl (%r14,%r13,4), %ebx
testl %ebx, %ebx
je 0x2acc
movl %r13d, %edi
callq 0x8333
movq %r15, %rdi
movq %rax, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2050
incq %r13
cmpq $0x80, %r13
jne 0x2aad
movl $0xa, %edi
callq 0x23f0
incq %r12
addq $0x200, %r14            # imm = 0x200
cmpq $0x40, %r12
jne 0x2a8d
movq -0x30(%rbp), %r15
jmp 0x2caa
movq %r15, %rdi
callq 0x8db3
testq %rax, %rax
je 0x2caa
movq %rax, %r14
movq 0x124b2(%rip), %rbx     # 0x14fc8
leaq -0x330(%rbp), %r12
movq (%rbx), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x74a5
movslq 0x14(%r14), %rax
cmpb $0x0, -0x100(%rbp,%rax)
je 0x2c2e
movq (%rbx), %rdi
movl 0x40(%r14), %edx
movq %rdi, -0x38(%rbp)
leaq 0xc577(%rip), %rsi      # 0xf0c6
xorl %eax, %eax
callq 0x2410
cmpl $0x0, 0x40(%r14)
jle 0x2c23
xorl %r13d, %r13d
xorl %ebx, %ebx
testb $0xf, %r13b
jne 0x2b8d
xorl %ebx, %ebx
leaq -0x8430(%rbp), %rdi
leaq 0xc562(%rip), %rsi      # 0xf0de
movl %r13d, %edx
leaq 0xd0ff(%rip), %rcx      # 0xfc85
xorl %eax, %eax
callq 0x20a0
movq 0x48(%r14), %rax
movzbl (%rax,%r13), %edx
movq %r12, %rdi
leaq 0xd8ad(%rip), %rsi      # 0x1044d
xorl %eax, %eax
callq 0x20a0
leal (%rbx,%rbx), %eax
movslq %eax, %rdi
leaq -0x8428(%rbp), %rax
addq %rax, %rdi
movl $0x2, %edx
movq %r12, %rsi
callq 0x2150
movq 0x48(%r14), %rax
movzbl (%rax,%r13), %eax
cmpb $0x20, %al
movslq %ebx, %rcx
movl $0x2e, %edx
cmovll %edx, %eax
leaq -0x8430(%rbp), %rdx
movb %al, 0x2a(%rcx,%rdx)
movl 0x40(%r14), %eax
leal -0x1(%rax), %ecx
leaq 0x1(%r13), %r15
cmpq %rcx, %r13
je 0x2bfd
movl %r15d, %ecx
andl $0xf, %ecx
jne 0x2c13
movq -0x38(%rbp), %rdi
leaq 0xc986(%rip), %rsi      # 0xf58e
xorl %eax, %eax
callq 0x2410
movl 0x40(%r14), %eax
incl %ebx
cltq
movq %r15, %r13
cmpq %rax, %r15
jl 0x2b66
movq -0x30(%rbp), %r15
movq 0x1239a(%rip), %rbx     # 0x14fc8
cmpl $0x0, -0x44(%rbp)
je 0x2c8b
movq %r15, %rdi
movq %r14, %rsi
leaq -0x8430(%rbp), %rdx
movq %r12, %rcx
callq 0x8b0d
testl %eax, %eax
je 0x2c8b
movsd -0x8430(%rbp), %xmm0
movsd -0x8428(%rbp), %xmm1
movsd -0x8420(%rbp), %xmm2
movsd -0x330(%rbp), %xmm3
movsd -0x328(%rbp), %xmm4
movsd -0x320(%rbp), %xmm5
leaq 0xc389(%rip), %rdi      # 0xf00d
movb $0x6, %al
callq 0x2050
movq %r15, %rdi
movq %r14, %rsi
callq 0xac11
movq %r15, %rdi
callq 0x8db3
movq %rax, %r14
testq %rax, %rax
jne 0x2b1d
movq %r15, %rdi
callq 0xe38f
xorl %eax, %eax
addq $0x8408, %rsp           # imm = 0x8408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2cd5
movl $0x1, %edi
callq 0x2370