// File: /workspace/github_c_makefile_star2_O0/darwin-on-arm[P]darwin-sdk/image3maker/image3maker.c
// Function: create_image_preprocess
static void create_image_preprocess(void)
{
    assert(inputFile && imageTag && outputFile);
    
    bzero((void*)&image3core, sizeof(Image3Struct));
    
    /* Read input file */
    image3core.backingData = map_file(inputFile, &image3core.backingDataSize);
    assert(image3core.backingDataSize);
    
    if(certificateBlob) {
        image3core.backingCertificate = map_file(certificateBlob, &image3core.backingCertificateSize);
        assert(image3core.backingCertificateSize);
    }
    
    /* Image tag */
    image3core.imageType = fourcc_to_uint(imageTag);
    
    /* Other stuff. */
    image3core.imageVersion = imageVersion;

    if(imageSecurityEpoch) {
        /* lol buffer overflow */
        if(!strcasecmp(imageSecurityEpoch, "s5l8920x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8920;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8922x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8922;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8930x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8930;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8940x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8940;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8950x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8950;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8955x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8955;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8947x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8947;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8942x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8942;
        else if(!strcasecmp(imageSecurityEpoch, "s5l8747x"))
            image3core.imageSecurityEpoch = IMAGE3_SEPO_S5L8747;
        else {
            printf("invalid security epoch '%s'\n", imageSecurityEpoch);
            exit(-1);
        }
    }
    
    /* SDOM */
    if(imageDomain) {
        /* lol buffer overflow */
        if(!strcasecmp(imageDomain, "darwin"))
            image3core.imageDomain = IMAGE3_SDOM_DARWIN;
        else if(!strcasecmp(imageDomain, "manufacturer"))
            image3core.imageDomain = IMAGE3_SDOM_FACTORY;
        else {
            printf("invalid domain '%s'\n", imageDomain);
            exit(-1);
        }
    }
    
    /* PROD */
    if(imageProduction) {
        /* lol buffer overflow */
        if(!strcasecmp(imageProduction, "production"))
            image3core.imageProductionType = IMAGE3_PROD_PRODUCTION;
        else if(!strcasecmp(imageProduction, "development"))
            image3core.imageProductionType = IMAGE3_PROD_DEVELOPMENT;
        else {
            printf("invalid production type '%s'\n", imageProduction);
            exit(-1);
        }
    }
    
    /* Other stuff */
    if(hardwareEpoch) {
        image3core.imageHardwareEpoch = (uint32_t)strtoul((const char*)hardwareEpoch, NULL, 16);
    }
    
    if(chipType) {
        image3core.imageChipType = (uint32_t)strtoul((const char*)chipType, NULL, 16);
    }

    if(boardType) {
        image3core.imageBoardType = (uint32_t)strtoul((const char*)boardType, NULL, 16);
    }
    
    if(uniqueIdentifier) {
        image3core.imageUniqueIdentifier = (uint64_t)strtoull((const char*)uniqueIdentifier, NULL, 16);
    }
    
    /* AES key/iv */
    if(aesKey && aesIv) {
        size_t szKey, szIv;
        hex_to_bytes(aesKey, &image3core.imageAESKey, &szKey);
        hex_to_bytes(aesIv, &image3core.imageAESIV, &szIv);
        assert((szKey == 32) && (szIv == 16));
    }
    
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
cmpq $0x0, 0x4e68(%rip)      # 0x6328
je 0x14d8
cmpq $0x0, 0x4e6e(%rip)      # 0x6338
je 0x14d8
cmpq $0x0, 0x4e5c(%rip)      # 0x6330
je 0x14d8
jmp 0x14f7
leaq 0x2205(%rip), %rdi      # 0x36e4
leaq 0x2222(%rip), %rsi      # 0x3708
movl $0x1d6, %edx            # imm = 0x1D6
leaq 0x2224(%rip), %rcx      # 0x3716
callq 0x10a0
leaq 0x4dba(%rip), %rdi      # 0x62b8
xorl %esi, %esi
movl $0x60, %edx
callq 0x10b0
movq 0x4e17(%rip), %rdi      # 0x6328
leaq 0x4da0(%rip), %rsi      # 0x62b8
addq $0x10, %rsi
callq 0x1dd0
movq %rax, 0x4d98(%rip)      # 0x62c0
cmpl $0x0, 0x4d99(%rip)      # 0x62c8
je 0x1533
jmp 0x1552
leaq 0x21ff(%rip), %rdi      # 0x3739
leaq 0x21c7(%rip), %rsi      # 0x3708
movl $0x1dc, %edx            # imm = 0x1DC
leaq 0x21c9(%rip), %rcx      # 0x3716
callq 0x10a0
cmpq $0x0, 0x4dc6(%rip)      # 0x6320
je 0x15a6
movq 0x4dbd(%rip), %rdi      # 0x6320
leaq 0x4d4e(%rip), %rsi      # 0x62b8
addq $0x20, %rsi
callq 0x1dd0
movq %rax, 0x4d56(%rip)      # 0x62d0
cmpl $0x0, 0x4d57(%rip)      # 0x62d8
je 0x1585
jmp 0x15a4
leaq 0x21c8(%rip), %rdi      # 0x3754
leaq 0x2175(%rip), %rsi      # 0x3708
movl $0x1e0, %edx            # imm = 0x1E0
leaq 0x2177(%rip), %rcx      # 0x3716
callq 0x10a0
jmp 0x15a6
movq 0x4d8b(%rip), %rdi      # 0x6338
callq 0x1f30
movl %eax, 0x4d24(%rip)      # 0x62dc
movq 0x4d81(%rip), %rax      # 0x6340
movq %rax, 0x4d1a(%rip)      # 0x62e0
cmpq $0x0, 0x4d4a(%rip)      # 0x6318
je 0x175b
movq 0x4d3d(%rip), %rdi      # 0x6318
leaq 0x2194(%rip), %rsi      # 0x3776
callq 0x1030
cmpl $0x0, %eax
jne 0x15fb
movl $0x4, 0x4cf2(%rip)      # 0x62e8
jmp 0x1759
movq 0x4d16(%rip), %rdi      # 0x6318
leaq 0x2176(%rip), %rsi      # 0x377f
callq 0x1030
cmpl $0x0, %eax
jne 0x1622
movl $0x2, 0x4ccb(%rip)      # 0x62e8
jmp 0x1757
movq 0x4cef(%rip), %rdi      # 0x6318
leaq 0x2158(%rip), %rsi      # 0x3788
callq 0x1030
cmpl $0x0, %eax
jne 0x1649
movl $0x2, 0x4ca4(%rip)      # 0x62e8
jmp 0x1755
movq 0x4cc8(%rip), %rdi      # 0x6318
leaq 0x213a(%rip), %rsi      # 0x3791
callq 0x1030
cmpl $0x0, %eax
jne 0x1670
movl $0x11, 0x4c7d(%rip)     # 0x62e8
jmp 0x1753
movq 0x4ca1(%rip), %rdi      # 0x6318
leaq 0x211c(%rip), %rsi      # 0x379a
callq 0x1030
cmpl $0x0, %eax
jne 0x1697
movl $0x10, 0x4c56(%rip)     # 0x62e8
jmp 0x1751
movq 0x4c7a(%rip), %rdi      # 0x6318
leaq 0x20fe(%rip), %rsi      # 0x37a3
callq 0x1030
cmpl $0x0, %eax
jne 0x16be
movl $0x10, 0x4c2f(%rip)     # 0x62e8
jmp 0x174f
movq 0x4c53(%rip), %rdi      # 0x6318
leaq 0x20e0(%rip), %rsi      # 0x37ac
callq 0x1030
cmpl $0x0, %eax
jne 0x16e2
movl $0x10, 0x4c08(%rip)     # 0x62e8
jmp 0x174d
movq 0x4c2f(%rip), %rdi      # 0x6318
leaq 0x20c5(%rip), %rsi      # 0x37b5
callq 0x1030
cmpl $0x0, %eax
jne 0x1706
movl $0x10, 0x4be4(%rip)     # 0x62e8
jmp 0x174b
movq 0x4c0b(%rip), %rdi      # 0x6318
leaq 0x20aa(%rip), %rsi      # 0x37be
callq 0x1030
cmpl $0x0, %eax
jne 0x172a
movl $0x10, 0x4bc0(%rip)     # 0x62e8
jmp 0x1749
movq 0x4be7(%rip), %rsi      # 0x6318
leaq 0x208f(%rip), %rdi      # 0x37c7
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1150
jmp 0x174b
jmp 0x174d
jmp 0x174f
jmp 0x1751
jmp 0x1753
jmp 0x1755
jmp 0x1757
jmp 0x1759
jmp 0x175b
cmpq $0x0, 0x4be5(%rip)      # 0x6348
je 0x17d0
movq 0x4bdc(%rip), %rdi      # 0x6348
leaq 0x2071(%rip), %rsi      # 0x37e4
callq 0x1030
cmpl $0x0, %eax
jne 0x1789
movl $0x1, 0x4b65(%rip)      # 0x62ec
jmp 0x17ce
movq 0x4bb8(%rip), %rdi      # 0x6348
leaq 0x2054(%rip), %rsi      # 0x37eb
callq 0x1030
cmpl $0x0, %eax
jne 0x17ad
movl $0x0, 0x4b41(%rip)      # 0x62ec
jmp 0x17cc
movq 0x4b94(%rip), %rsi      # 0x6348
leaq 0x203d(%rip), %rdi      # 0x37f8
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1150
jmp 0x17ce
jmp 0x17d0
cmpq $0x0, 0x4b78(%rip)      # 0x6350
je 0x1845
movq 0x4b6f(%rip), %rdi      # 0x6350
leaq 0x2025(%rip), %rsi      # 0x380d
callq 0x1030
cmpl $0x0, %eax
jne 0x17fe
movl $0x1, 0x4af4(%rip)      # 0x62f0
jmp 0x1843
movq 0x4b4b(%rip), %rdi      # 0x6350
leaq 0x200c(%rip), %rsi      # 0x3818
callq 0x1030
cmpl $0x0, %eax
jne 0x1822
movl $0x0, 0x4ad0(%rip)      # 0x62f0
jmp 0x1841
movq 0x4b27(%rip), %rsi      # 0x6350
leaq 0x1ff4(%rip), %rdi      # 0x3824
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1150
jmp 0x1843
jmp 0x1845
cmpq $0x0, 0x4b0b(%rip)      # 0x6358
je 0x186a
movq 0x4b02(%rip), %rdi      # 0x6358
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x1140
movl %eax, 0x4a8a(%rip)      # 0x62f4
cmpq $0x0, 0x4aee(%rip)      # 0x6360
je 0x188f
movq 0x4ae5(%rip), %rdi      # 0x6360
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x1140
movl %eax, 0x4a69(%rip)      # 0x62f8
cmpq $0x0, 0x4ad1(%rip)      # 0x6368
je 0x18b4
movq 0x4ac8(%rip), %rdi      # 0x6368
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x1140
movl %eax, 0x4a48(%rip)      # 0x62fc
cmpq $0x0, 0x4ab4(%rip)      # 0x6370
je 0x18da
movq 0x4aab(%rip), %rdi      # 0x6370
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x10c0
movq %rax, 0x4a26(%rip)      # 0x6300
cmpq $0x0, 0x4a96(%rip)      # 0x6378
je 0x1955
cmpq $0x0, 0x4a94(%rip)      # 0x6380
je 0x1955
movq 0x4a83(%rip), %rdi      # 0x6378
leaq 0x49bc(%rip), %rsi      # 0x62b8
addq $0x50, %rsi
leaq -0x8(%rbp), %rdx
callq 0x1f80
movq 0x4a70(%rip), %rdi      # 0x6380
leaq 0x49a1(%rip), %rsi      # 0x62b8
addq $0x58, %rsi
leaq -0x10(%rbp), %rdx
callq 0x1f80
cmpq $0x20, -0x8(%rbp)
jne 0x1934
cmpq $0x10, -0x10(%rbp)
jne 0x1934
jmp 0x1953
leaq 0x1f07(%rip), %rdi      # 0x3842
leaq 0x1dc6(%rip), %rsi      # 0x3708
movl $0x233, %edx            # imm = 0x233
leaq 0x1dc8(%rip), %rcx      # 0x3716
callq 0x10a0
jmp 0x1955
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)