// File: /workspace/github_c_makefile_star2_O3/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 0x204f5(%rip), %edx     # 0x26234
movzbl 0x204f2(%rip), %eax     # 0x26238
movzbl 0x204ef(%rip), %ecx     # 0x2623c
movzbl 0x204d0(%rip), %esi     # 0x26224
leal (%rcx,%rsi), %r8d
addl %eax, %r8d
addl %edx, %r8d
movzbl 0x204db(%rip), %edi     # 0x26240
addl %r8d, %edi
cmpl $0x2, %edi
jae 0x6034
testb %sil, %sil
jne 0x5dd5
movl 0x20434(%rip), %edi     # 0x261b0
notl %edi
sarl $0x1f, %edi
addl 0x204e9(%rip), %edi     # 0x26270
leal -0x4(,%rdi,2), %esi
cmpb $0x0, 0x204b7(%rip)     # 0x2624c
cmovel %edi, %esi
cmpl $0x64, %esi
setge %dil
testb %dil, %dl
jne 0x602f
movl %eax, %edi
orb %cl, %dil
cmpb $0x1, %dil
jne 0x5dbf
cmpl $0xff, %esi
jg 0x602f
movl %edx, %edi
orb %al, %dil
orb %cl, %dil
jne 0x5dd5
cmpl $0x100, %esi            # imm = 0x100
jge 0x602f
movq 0x2021c(%rip), %rsi     # 0x25ff8
movq (%rsi), %rsi
movq %rsi, 0x20402(%rip)     # 0x261e8
movq 0x2043b(%rip), %rdi     # 0x26228
testq %rdi, %rdi
je 0x5e33
leaq 0x1a83d(%rip), %r8      # 0x20636
leaq 0x1a6a2(%rip), %rsi     # 0x204a2
cmpb $0x0, 0x20449(%rip)     # 0x26250
cmovneq %r8, %rsi
testb %dl, %dl
cmovneq %r8, %rsi
testb %al, %al
cmovneq %r8, %rsi
testb %cl, %cl
cmovneq %r8, %rsi
callq 0x10a0
movq %rax, 0x23e7c7(%rip)    # 0x2445f0
testq %rax, %rax
jne 0x5e52
callq 0x2399
leaq 0x1a661(%rip), %rax     # 0x2049b
movq %rax, 0x203e7(%rip)     # 0x26228
movq 0x20190(%rip), %rax     # 0x25fd8
movq (%rax), %rax
movq %rax, 0x23e79e(%rip)    # 0x2445f0
movb 0x203f8(%rip), %cl      # 0x26250
cmpb $0x1, %cl
jne 0x5e7d
leaq 0x4680(%rip), %rdx      # 0xa4e4
movq %rdx, 0x23e78d(%rip)    # 0x2445f8
movq %rdx, 0x23e78e(%rip)    # 0x244600
movb 0x203bc(%rip), %dl      # 0x26234
jmp 0x5f25
cmpb $0x1, 0x203b0(%rip)     # 0x26234
jne 0x5ea7
leaq 0x48f9(%rip), %rax      # 0xa786
movq %rax, 0x23e76c(%rip)    # 0x244600
leaq 0x4a60(%rip), %rax      # 0xa8fb
movq %rax, 0x23e756(%rip)    # 0x2445f8
jmp 0x602d
cmpb $0x1, 0x2038a(%rip)     # 0x26238
jne 0x5ec7
leaq 0x4bbd(%rip), %rdx      # 0xaa74
movq %rdx, 0x23e742(%rip)    # 0x244600
leaq 0x4bdd(%rip), %rdx      # 0xaaa2
jmp 0x5f1c
cmpb $0x1, 0x2036e(%rip)     # 0x2623c
jne 0x5ee7
leaq 0x4bf9(%rip), %rdx      # 0xaad0
movq %rdx, 0x23e722(%rip)    # 0x244600
leaq 0x4c19(%rip), %rdx      # 0xaafe
jmp 0x5f1c
cmpb $0x1, 0x20352(%rip)     # 0x26240
jne 0x5f07
leaq 0x4c35(%rip), %rdx      # 0xab2c
movq %rdx, 0x23e702(%rip)    # 0x244600
leaq 0x4e71(%rip), %rdx      # 0xad76
jmp 0x5f1c
leaq 0x50cb(%rip), %rdx      # 0xafd9
movq %rdx, 0x23e6eb(%rip)    # 0x244600
leaq 0x5144(%rip), %rdx      # 0xb060
movq %rdx, 0x23e6d5(%rip)    # 0x2445f8
xorl %edx, %edx
cmpb $0x0, 0x202f8(%rip)     # 0x26224
jne 0x602d
testb $0x1, %dl
jne 0x602d
movb 0x20307(%rip), %dl      # 0x26248
orb %dl, %cl
movb 0x202f2(%rip), %sil     # 0x2623c
orb 0x202e7(%rip), %sil     # 0x26238
orb %cl, %sil
movb 0x202e6(%rip), %cl      # 0x26240
orb %cl, %sil
testb $0x1, %sil
jne 0x5f92
leaq 0x1a561(%rip), %rdi     # 0x204cb
movl $0x1, %esi
movl $0xf, %edx
movq %rax, %rcx
callq 0x10e0
cmpq $0xf, %rax
jne 0x6039
movb 0x202bc(%rip), %dl      # 0x26248
movb 0x202ae(%rip), %cl      # 0x26240
testb $0x1, %dl
jne 0x5fc5
testb $0x1, %cl
je 0x5fc5
movq 0x23e64d(%rip), %rcx    # 0x2445f0
leaq 0x1a531(%rip), %rdi     # 0x204db
movl $0x1, %esi
movl $0xd, %edx
callq 0x10e0
cmpq $0xd, %rax
jne 0x6039
movb 0x20283(%rip), %dl      # 0x26248
testb $0x1, %dl
je 0x5ffc
testb $0x1, 0x20267(%rip)     # 0x26238
je 0x5ffc
movq 0x23e616(%rip), %rcx    # 0x2445f0
leaq 0x1a508(%rip), %rdi     # 0x204e9
movl $0x1, %esi
movl $0xa, %edx
callq 0x10e0
cmpq $0xa, %rax
jne 0x6039
movb 0x2024c(%rip), %dl      # 0x26248
testb $0x1, %dl
je 0x602d
testb $0x1, 0x20234(%rip)     # 0x2623c
je 0x602d
movq 0x23e5df(%rip), %rcx    # 0x2445f0
leaq 0x1a4dc(%rip), %rdi     # 0x204f4
movl $0x1, %esi
movl $0xb, %edx
callq 0x10e0
cmpq $0xb, %rax
jne 0x6039
popq %rax
retq
callq 0x2371
callq 0x2408
callq 0x23d4