// File: /workspace/github_c_makefile_star2_O1/mishun[P]plantri/plantri.c
// Function: open_output_file
static void
open_output_file(void)

/* Open the output file, and write a header if one is called for.
   All the needed information is in global vars.  Also check if
   maxn is too large for this format, and set the global procedure
   variables write_graph() and write_dual_graph().
*/
{
    int nvf;

    if (aswitch + gswitch + sswitch + uswitch + Eswitch >= 2)
    {
        fprintf(stderr,">E %s: -a, -g, -s, -u, -E are incompatible\n",cmdname);
        exit(1);
    }

    if (!uswitch)   /*UPDATE for -E and reconconsider */
    {
        nvf = dswitch ? 2*(maxnv-(polygonsize>=0))-4 : maxnv-(polygonsize>=0);
        if ((aswitch && nvf > 99) ||
            (gswitch && nvf > 255) ||
            (sswitch && nvf > 255) ||
           (!aswitch && !gswitch && !sswitch && nvf > 255))
        {
            fprintf(stderr,">E %s: n is too large for that output format\n",
                cmdname);
            exit(1);
        }
    }

    msgfile = stderr;
    if (outfilename == NULL)
    {
        outfilename = "stdout";
        outfile = stdout;
    }
    else if ((outfile = fopen(outfilename,
        zeroswitch || aswitch || gswitch || sswitch ? "w" : "wb")) == NULL)
    {
        fprintf(stderr,
          ">E %s: can't open %s for writing\n",cmdname,outfilename);
        perror(">E ");
        exit(1);
    }

    if (zeroswitch)  /* implied by oneswitch */
        write_graph = write_dual_graph = write_digits;
    else if (aswitch)
    {
        write_graph = write_alpha;
        write_dual_graph = write_dual_alpha;
    }
    else if (gswitch)
    {
        write_graph = write_graph6;
        write_dual_graph = write_dual_graph6;
    }
    else if (sswitch)
    {
        write_graph = write_sparse6;
        write_dual_graph = write_dual_sparse6;
    }
    else if (Eswitch)
    {
        write_graph = write_edgecode;
        write_dual_graph = write_dual_edgecode;
    }
    else
    {
        write_graph = write_planar_code;
        write_dual_graph = write_dual_planar_code;
    }

    if (!uswitch && !aswitch)
    {
        if ((!zeroswitch && !hswitch && !gswitch && !sswitch && !Eswitch &&
	     fwrite(PCODE,(size_t)1,PCODELEN,outfile) != PCODELEN)
          || (!hswitch && Eswitch &&
	      fwrite(ECODE,(size_t)1,ECODELEN,outfile) != ECODELEN)
          || (hswitch && gswitch &&
	      fwrite(G6CODE,(size_t)1,G6CODELEN,outfile) != G6CODELEN)
          || (hswitch && sswitch &&
	      fwrite(S6CODE,(size_t)1,S6CODELEN,outfile) != S6CODELEN))
        {
            fprintf(stderr,">E %s: error writing header\n",cmdname);
            perror(">E ");
            exit(1);
        }
    }
}

// Assembly:
pushq %rax
movzbl 0x203ad(%rip), %edx     # 0x26234
movzbl 0x203aa(%rip), %eax     # 0x26238
movzbl 0x203a7(%rip), %ecx     # 0x2623c
movzbl 0x20388(%rip), %esi     # 0x26224
leal (%rcx,%rsi), %r8d
addl %eax, %r8d
addl %edx, %r8d
movzbl 0x20393(%rip), %edi     # 0x26240
addl %r8d, %edi
cmpl $0x2, %edi
jae 0x6166
testb %sil, %sil
jne 0x5f1d
movl 0x202ec(%rip), %edi     # 0x261b0
notl %edi
sarl $0x1f, %edi
addl 0x203a1(%rip), %edi     # 0x26270
leal -0x4(,%rdi,2), %esi
cmpb $0x0, 0x2036f(%rip)     # 0x2624c
cmovel %edi, %esi
cmpl $0x64, %esi
setge %dil
testb %dil, %dl
jne 0x6161
movl %eax, %edi
orb %cl, %dil
cmpb $0x1, %dil
jne 0x5f07
cmpl $0xff, %esi
jg 0x6161
movl %edx, %edi
orb %al, %dil
orb %cl, %dil
jne 0x5f1d
cmpl $0x100, %esi            # imm = 0x100
jge 0x6161
movq 0x200d4(%rip), %rsi     # 0x25ff8
movq (%rsi), %rsi
movq %rsi, 0x202ba(%rip)     # 0x261e8
movq 0x202f3(%rip), %rdi     # 0x26228
testq %rdi, %rdi
je 0x5f7b
leaq 0x1a6a6(%rip), %r8      # 0x205e7
leaq 0x1a50b(%rip), %rsi     # 0x20453
cmpb $0x0, 0x20301(%rip)     # 0x26250
cmovneq %r8, %rsi
testb %dl, %dl
cmovneq %r8, %rsi
testb %al, %al
cmovneq %r8, %rsi
testb %cl, %cl
cmovneq %r8, %rsi
callq 0x10b0
movq %rax, 0x23e67f(%rip)    # 0x2445f0
testq %rax, %rax
jne 0x5f9a
callq 0x2415
leaq 0x1a4ca(%rip), %rax     # 0x2044c
movq %rax, 0x2029f(%rip)     # 0x26228
movq 0x20048(%rip), %rax     # 0x25fd8
movq (%rax), %rax
movq %rax, 0x23e656(%rip)    # 0x2445f0
movb 0x202b0(%rip), %al      # 0x26250
cmpb $0x1, %al
jne 0x5fbe
leaq 0x4447(%rip), %rcx      # 0xa3f2
movq %rcx, 0x23e646(%rip)    # 0x2445f8
movq %rcx, 0x23e647(%rip)    # 0x244600
jmp 0x605a
cmpb $0x1, 0x2026f(%rip)     # 0x26234
jne 0x5fde
leaq 0x46ed(%rip), %rcx      # 0xa6bb
movq %rcx, 0x23e62b(%rip)    # 0x244600
leaq 0x4865(%rip), %rcx      # 0xa841
jmp 0x6053
cmpb $0x1, 0x20253(%rip)     # 0x26238
jne 0x5ffe
leaq 0x49dc(%rip), %rcx      # 0xa9ca
movq %rcx, 0x23e60b(%rip)    # 0x244600
leaq 0x49fc(%rip), %rcx      # 0xa9f8
jmp 0x6053
cmpb $0x1, 0x20237(%rip)     # 0x2623c
jne 0x601e
leaq 0x4a18(%rip), %rcx      # 0xaa26
movq %rcx, 0x23e5eb(%rip)    # 0x244600
leaq 0x4a38(%rip), %rcx      # 0xaa54
jmp 0x6053
cmpb $0x1, 0x2021b(%rip)     # 0x26240
jne 0x603e
leaq 0x4a54(%rip), %rcx      # 0xaa82
movq %rcx, 0x23e5cb(%rip)    # 0x244600
leaq 0x4c82(%rip), %rcx      # 0xacbe
jmp 0x6053
leaq 0x4ed0(%rip), %rcx      # 0xaf15
movq %rcx, 0x23e5b4(%rip)    # 0x244600
leaq 0x4f49(%rip), %rcx      # 0xaf9c
movq %rcx, 0x23e59e(%rip)    # 0x2445f8
cmpb $0x0, 0x201c3(%rip)     # 0x26224
jne 0x615f
testb $0x1, 0x201c6(%rip)     # 0x26234
jne 0x615f
orb 0x201ce(%rip), %al      # 0x26248
testb $0x1, %al
jne 0x60c0
testb $0x1, 0x201b3(%rip)     # 0x26238
jne 0x60c0
testb $0x1, 0x201ae(%rip)     # 0x2623c
jne 0x60c0
testb $0x1, 0x201a9(%rip)     # 0x26240
jne 0x60c0
movq 0x23e550(%rip), %rcx    # 0x2445f0
leaq 0x1a3d5(%rip), %rdi     # 0x2047c
movl $0x1, %esi
movl $0xf, %edx
callq 0x10f0
cmpq $0xf, %rax
jne 0x616b
cmpb $0x0, 0x20181(%rip)     # 0x26248
jne 0x60f5
testb $0x1, 0x20170(%rip)     # 0x26240
je 0x60f5
movq 0x23e517(%rip), %rcx    # 0x2445f0
leaq 0x1a3ac(%rip), %rdi     # 0x2048c
movl $0x1, %esi
movl $0xd, %edx
callq 0x10f0
cmpq $0xd, %rax
jne 0x616b
cmpb $0x1, 0x2014c(%rip)     # 0x26248
jne 0x612a
testb $0x1, 0x20133(%rip)     # 0x26238
je 0x612a
movq 0x23e4e2(%rip), %rcx    # 0x2445f0
leaq 0x1a385(%rip), %rdi     # 0x2049a
movl $0x1, %esi
movl $0xa, %edx
callq 0x10f0
cmpq $0xa, %rax
jne 0x616b
cmpb $0x1, 0x20117(%rip)     # 0x26248
jne 0x615f
testb $0x1, 0x20102(%rip)     # 0x2623c
je 0x615f
movq 0x23e4ad(%rip), %rcx    # 0x2445f0
leaq 0x1a35b(%rip), %rdi     # 0x204a5
movl $0x1, %esi
movl $0xb, %edx
callq 0x10f0
cmpq $0xb, %rax
jne 0x616b
popq %rax
retq
callq 0x23ed
callq 0x2484
callq 0x2450