// File: /workspace/github_cpp_makefile_star2_O1/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 $0x83f8, %rsp           # imm = 0x83F8
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
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)
cmpl $0x2, %edi
jl 0x28ce
movq %rsi, %rbx
movl %edi, %r14d
leal -0x4(%r14), %eax
movl %eax, -0x68(%rbp)
leal -0x1(%r14), %eax
movl %eax, -0x6c(%rbp)
movl $0x1, %r13d
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm0, -0x58(%rbp)
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movslq %r13d, %r12
movq (%rbx,%r12,8), %r15
movq %r15, %rdi
leaq 0xd864(%rip), %rsi      # 0x10004
callq 0x2410
testl %eax, %eax
je 0x2810
movq %r15, %rdi
leaq 0xd854(%rip), %rsi      # 0x10007
callq 0x2410
testl %eax, %eax
sete %al
cmpl -0x68(%rbp), %r13d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x281c
movq 0x8(%rbx,%r12,8), %rdi
callq 0x23a0
movsd %xmm0, -0x38(%rbp)
movq 0x10(%rbx,%r12,8), %rdi
callq 0x23a0
movsd %xmm0, -0x60(%rbp)
movq 0x18(%rbx,%r12,8), %rdi
callq 0x23a0
movsd %xmm0, -0x58(%rbp)
addl $0x4, %r13d
movq 0x20(%rbx,%r12,8), %rdi
callq 0x23a0
movsd %xmm0, -0x50(%rbp)
jmp 0x28a5
movl $0x1, -0x2c(%rbp)
jmp 0x28a5
movq %r15, %rdi
leaq 0xd7e4(%rip), %rsi      # 0x1000a
callq 0x2410
testl %eax, %eax
sete %al
cmpl -0x6c(%rbp), %r13d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2871
incl %r13d
movq 0x8(%rbx,%r12,8), %rdi
callq 0x2490
cmpl $0x7f, %eax
movl $0x7f, %ecx
cmovgel %ecx, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movb $0x1, -0xf0(%rbp,%rax)
movl $0x1, -0x40(%rbp)
jmp 0x28a5
movq %r15, %rdi
leaq 0xd792(%rip), %rsi      # 0x1000d
callq 0x2410
testl %eax, %eax
je 0x289e
cmpb $0x2d, (%r15)
je 0x2cfc
cmpq $0x0, -0x48(%rbp)
movq %r15, -0x48(%rbp)
je 0x28a5
jmp 0x2cfc
movl $0x1, -0x3c(%rbp)
incl %r13d
cmpl %r14d, %r13d
jl 0x278f
cmpl $0x0, -0x40(%rbp)
sete %r14b
cmpl $0x0, -0x2c(%rbp)
sete %bl
cmpl $0x0, -0x3c(%rbp)
sete -0x2c(%rbp)
movq -0x48(%rbp), %rdi
jmp 0x28f0
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movb $0x1, %bl
movb $0x1, %r14b
movb $0x1, -0x2c(%rbp)
movsd %xmm0, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm0, -0x50(%rbp)
xorl %edi, %edi
testq %rdi, %rdi
je 0x2cfc
xorl %esi, %esi
callq 0xe918
testq %rax, %rax
je 0x2d01
movq %rax, %r12
testb %r14b, %r14b
jne 0x291e
movq %r12, %rdi
movl $0x1, %esi
callq 0xea43
movq %r12, %rdi
movsd -0x38(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
movsd -0x58(%rbp), %xmm2
movsd -0x50(%rbp), %xmm3
callq 0xea4a
testb %bl, %bl
movq %r12, -0x38(%rbp)
je 0x2afc
movq %r12, %rdi
callq 0x8f14
testq %rax, %rax
je 0x2ce0
movq %rax, %r14
movq 0x13667(%rip), %rbx     # 0x15fc8
leaq -0x8420(%rbp), %r15
movq (%rbx), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x75a9
movslq 0x14(%r14), %rax
cmpb $0x0, -0xf0(%rbp,%rax)
je 0x2a7b
movq (%rbx), %rdi
movl 0x40(%r14), %edx
movq %rdi, -0x68(%rbp)
leaq 0xd735(%rip), %rsi      # 0x100cf
xorl %eax, %eax
callq 0x2420
cmpl $0x0, 0x40(%r14)
jle 0x2a70
xorl %r13d, %r13d
xorl %r12d, %r12d
testb $0xf, %r13b
jne 0x29d6
xorl %r12d, %r12d
movq %r15, %rdi
leaq 0xd722(%rip), %rsi      # 0x100e7
movl %r13d, %edx
leaq 0xe27e(%rip), %rcx      # 0x10c4d
xorl %eax, %eax
callq 0x20a0
movq 0x48(%r14), %rax
movzbl (%rax,%r13), %edx
movq %r15, %rbx
leaq -0x320(%rbp), %r15
movq %r15, %rdi
leaq 0xea22(%rip), %rsi      # 0x11415
xorl %eax, %eax
callq 0x20a0
leal (%r12,%r12), %eax
movslq %eax, %rdi
leaq -0x8418(%rbp), %rax
addq %rax, %rdi
movl $0x2, %edx
movq %r15, %rsi
movq %rbx, %r15
callq 0x2160
movq 0x48(%r14), %rax
movzbl (%rax,%r13), %eax
cmpb $0x20, %al
movslq %r12d, %rcx
movl $0x2e, %edx
cmovll %edx, %eax
movb %al, 0x2a(%rcx,%rbx)
movl 0x40(%r14), %eax
decl %eax
cmpq %rax, %r13
je 0x2a48
leal 0x1(%r13), %eax
testb $0xf, %al
jne 0x2a5d
movq -0x68(%rbp), %rdi
leaq 0xdb1b(%rip), %rsi      # 0x1056e
movq %r15, %rdx
xorl %eax, %eax
callq 0x2420
incl %r12d
incq %r13
movslq 0x40(%r14), %rax
cmpq %rax, %r13
jl 0x29b2
movq -0x38(%rbp), %r12
movq 0x1354d(%rip), %rbx     # 0x15fc8
cmpb $0x0, -0x2c(%rbp)
jne 0x2ad8
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq -0x320(%rbp), %rcx
callq 0x8c32
testl %eax, %eax
je 0x2ad8
movsd -0x8420(%rbp), %xmm0
movsd -0x8418(%rbp), %xmm1
movsd -0x8410(%rbp), %xmm2
movsd -0x320(%rbp), %xmm3
movsd -0x318(%rbp), %xmm4
movsd -0x310(%rbp), %xmm5
leaq 0xd545(%rip), %rdi      # 0x10016
movb $0x6, %al
callq 0x2050
movq %r12, %rdi
movq %r14, %rsi
callq 0xb0b0
movq %r12, %rdi
callq 0x8f14
movq %rax, %r14
testq %rax, %rax
jne 0x2968
jmp 0x2ce0
leaq -0x120(%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0xb415
movsd (%rbx), %xmm0
movsd 0x18(%rbx), %xmm1
leaq 0xd531(%rip), %rdi      # 0x1004f
movb $0x2, %al
callq 0x2050
movsd 0x8(%rbx), %xmm0
movsd 0x20(%rbx), %xmm1
leaq 0xd530(%rip), %rdi      # 0x10066
movb $0x2, %al
callq 0x2050
movsd 0x10(%rbx), %xmm0
movsd 0x28(%rbx), %xmm1
leaq 0xd52f(%rip), %rdi      # 0x1007d
movb $0x2, %al
callq 0x2050
leaq -0x70(%rbp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0xb3e9
movq %rax, %rbx
movl (%r15), %esi
leaq 0xd523(%rip), %rdi      # 0x10094
xorl %eax, %eax
callq 0x2050
leaq -0x8420(%rbp), %r14
movl $0x8000, %edx           # imm = 0x8000
movq %r14, %rdi
xorl %esi, %esi
callq 0x2170
leaq -0x420(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2170
leaq -0x320(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x2170
movslq (%r15), %rax
testq %rax, %rax
jle 0x2bee
shlq $0x4, %rax
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
movzbl 0x1(%rbx,%rcx), %esi
incl -0x420(%rbp,%rdx,4)
shll $0x7, %edx
addl %esi, %edx
incl -0x8420(%rbp,%rdx,4)
incl -0x320(%rbp,%rsi,4)
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2bc2
movl $0xa, %edi
callq 0x2400
leaq 0xd4f2(%rip), %rdi      # 0x100f1
callq 0x2470
leaq 0xd508(%rip), %rdi      # 0x10113
callq 0x2470
leaq 0xd4ab(%rip), %rbx      # 0x100c2
xorl %r15d, %r15d
movl -0x320(%rbp,%r15,4), %r12d
testl %r12d, %r12d
je 0x2c3f
movl %r15d, %edi
callq 0x846b
movq %rbx, %rdi
movq %rax, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2050
incq %r15
cmpq $0x80, %r15
jne 0x2c1a
movl $0xa, %edi
callq 0x2400
leaq 0xd4a5(%rip), %rdi      # 0x10101
callq 0x2470
leaq 0xd4aa(%rip), %rdi      # 0x10112
callq 0x2470
leaq 0xd44c(%rip), %r15      # 0x100c0
xorl %r12d, %r12d
movl -0x420(%rbp,%r12,4), %edx
testl %edx, %edx
je 0x2ccc
leaq 0xd41e(%rip), %rdi      # 0x100a8
movl %r12d, %esi
xorl %eax, %eax
callq 0x2050
xorl %r13d, %r13d
movl (%r14,%r13,4), %ebx
testl %ebx, %ebx
je 0x2cb6
movl %r13d, %edi
callq 0x846b
movq %r15, %rdi
movq %rax, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2050
incq %r13
cmpq $0x80, %r13
jne 0x2c97
movl $0xa, %edi
callq 0x2400
incq %r12
addq $0x200, %r14            # imm = 0x200
cmpq $0x40, %r12
jne 0x2c77
movq -0x38(%rbp), %r12
movq %r12, %rdi
callq 0xeba1
xorl %eax, %eax
addq $0x83f8, %rsp           # imm = 0x83F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2d0b
movl $0x1, %edi
callq 0x2380