user: 请将以下的汇编代码转换成C语言代码:

```asm
<wrfile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x110,%rsp
  mov    %rdi,-0xe8(%rbp)
  mov    %rsi,-0xf0(%rbp)
  mov    %rdx,-0xf8(%rbp)
  mov    %ecx,-0xfc(%rbp)
  mov    %r8,-0x108(%rbp)
  mov    %r9d,-0x100(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    $0x0,%eax
  call   <filec_getdebug@plt>
  mov    %eax,-0xb4(%rbp)
  cmpl   $0x0,-0xb4(%rbp)
  je     L6
  mov    -0xe8(%rbp),%rax
  mov    %rax,%rsi
  lea    D494(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rsi
  lea    D188(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0xfc(%rbp),%eax
  mov    %eax,%esi
  lea    D525(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0xb8(%rbp)
  jmp    L776
L144:
  mov    -0xb8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x108(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  lea    D106(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  addl   $0x1,-0xb8(%rbp)
L776:
  mov    -0xb8(%rbp),%eax
  cmp    -0xfc(%rbp),%eax
  jl     L144
  mov    -0x100(%rbp),%eax
  mov    %eax,%esi
  lea    D405(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x1,-0x100(%rbp)
  jne    L153
  lea    D263(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L153:
  cmpl   $0x2,-0x100(%rbp)
  jne    L319
  lea    D102(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L319:
  cmpl   $0x3,-0x100(%rbp)
  jne    L2
  lea    D329(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L2:
  cmpl   $0x4,-0x100(%rbp)
  jne    L352
  lea    D295(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L352:
  cmpl   $0x5,-0x100(%rbp)
  jne    L649
  lea    D13(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L649:
  cmpl   $0x6,-0x100(%rbp)
  jne    L284
  lea    D196(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L284:
  cmpl   $0x7,-0x100(%rbp)
  jne    L554
  lea    D533(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L6
L554:
  cmpl   $0x8,-0x100(%rbp)
  jne    L6
  lea    D354(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L6:
  movl   $0x1,-0xbc(%rbp)
  movl   $0x0,-0xb8(%rbp)
  jmp    L674
L535:
  mov    -0xb8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x108(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0xbc(%rbp),%eax
  imul   %edx,%eax
  mov    %eax,-0xbc(%rbp)
  mov    -0xb8(%rbp),%eax
  lea    0x1(%rax),%edx
  lea    -0x60(%rbp),%rax
  lea    D593(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0xf0(%rbp),%rdx
  lea    -0xb0(%rbp),%rcx
  lea    -0x60(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <gethd@plt>
  movzbl -0xb0(%rbp),%eax
  test   %al,%al
  je     L662
  lea    -0xc8(%rbp),%rdx
  lea    -0xb0(%rbp),%rax
  lea    D428(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L662
  mov    -0xb8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x108(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0xc8(%rbp),%eax
  cmp    %eax,%edx
  je     L633
L662:
  mov    -0xb8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x108(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  lea    -0xb0(%rbp),%rax
  lea    D408(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0xf0(%rbp),%rdx
  lea    -0xb0(%rbp),%rcx
  lea    -0x60(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <puthd@plt>
L633:
  addl   $0x1,-0xb8(%rbp)
L674:
  mov    -0xb8(%rbp),%eax
  cmp    -0xfc(%rbp),%eax
  jl     L535
  mov    -0xf0(%rbp),%rdx
  lea    -0xb0(%rbp),%rax
  mov    %rax,%rsi
  lea    D99(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  lea    -0xc8(%rbp),%rdx
  lea    -0xb0(%rbp),%rax
  lea    D428(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L304
  mov    -0xc8(%rbp),%eax
  cmp    %eax,-0xfc(%rbp)
  je     L32
L304:
  mov    -0xfc(%rbp),%edx
  lea    -0xb0(%rbp),%rax
  lea    D428(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0xf0(%rbp),%rdx
  lea    -0xb0(%rbp),%rax
  mov    %rax,%rsi
  lea    D99(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
L32:
  mov    -0xf0(%rbp),%rdx
  lea    -0xb0(%rbp),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  cmpl   $0x1,-0x100(%rbp)
  jne    L834
  lea    -0xb0(%rbp),%rax
  lea    D479(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L834
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D479(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L834:
  cmpl   $0x2,-0x100(%rbp)
  jne    L300
  lea    -0xb0(%rbp),%rax
  lea    D225(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L300
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D225(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L300:
  cmpl   $0x3,-0x100(%rbp)
  jne    L707
  lea    -0xb0(%rbp),%rax
  lea    D565(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L707
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D565(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L707:
  cmpl   $0x4,-0x100(%rbp)
  jne    L388
  lea    -0xb0(%rbp),%rax
  lea    D304(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L388
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D304(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L388:
  cmpl   $0x5,-0x100(%rbp)
  jne    L473
  lea    -0xb0(%rbp),%rax
  lea    D142(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L473
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D142(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L473:
  cmpl   $0x6,-0x100(%rbp)
  jne    L299
  lea    -0xb0(%rbp),%rax
  lea    D5(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L299
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D5(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L299:
  cmpl   $0x7,-0x100(%rbp)
  jne    L308
  lea    -0xb0(%rbp),%rax
  lea    D332(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L308
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D332(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L308:
  cmpl   $0x8,-0x100(%rbp)
  jne    L36
  lea    -0xb0(%rbp),%rax
  lea    D513(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L36
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D513(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L36:
  cmpl   $0x9,-0x100(%rbp)
  jne    L375
  lea    -0xb0(%rbp),%rax
  lea    D265(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L375
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D332(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L579
L375:
  cmpl   $0xa,-0x100(%rbp)
  jne    L579
  lea    -0xb0(%rbp),%rax
  lea    D469(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L579
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D513(%rip),%rax
  mov    %rax,%rsi
  lea    D82(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
L579:
  mov    -0xf0(%rbp),%rdx
  lea    -0xb0(%rbp),%rax
  mov    %rax,%rsi
  lea    D573(%rip),%rax
  mov    %rax,%rdi
  call   <gethd@plt>
  mov    $0x0,%eax
  call   <getbo@plt>
  test   %eax,%eax
  jne    L114
  lea    -0xb0(%rbp),%rax
  lea    D454(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L114
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D454(%rip),%rax
  mov    %rax,%rsi
  lea    D573(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
  jmp    L663
L114:
  mov    $0x0,%eax
  call   <getbo@plt>
  cmp    $0x1,%eax
  jne    L663
  lea    -0xb0(%rbp),%rax
  lea    D539(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L663
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rdx
  lea    D539(%rip),%rax
  mov    %rax,%rsi
  lea    D573(%rip),%rax
  mov    %rax,%rdi
  call   <puthd@plt>
L663:
  movl   $0x0,-0xcc(%rbp)
  cmpl   $0x1,-0x100(%rbp)
  jne    L287
  mov    -0xbc(%rbp),%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L287:
  cmpl   $0x2,-0x100(%rbp)
  jne    L767
  mov    -0xbc(%rbp),%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L767:
  cmpl   $0x3,-0x100(%rbp)
  jne    L320
  mov    -0xbc(%rbp),%eax
  cltq
  add    %eax,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L320:
  cmpl   $0x4,-0x100(%rbp)
  jne    L467
  mov    -0xbc(%rbp),%eax
  cltq
  add    %eax,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L467:
  cmpl   $0x5,-0x100(%rbp)
  jne    L148
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L148:
  cmpl   $0x6,-0x100(%rbp)
  jne    L687
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L687:
  cmpl   $0x7,-0x100(%rbp)
  jne    L732
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L732:
  cmpl   $0x8,-0x100(%rbp)
  jne    L397
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L397:
  cmpl   $0x9,-0x100(%rbp)
  jne    L557
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L342
L557:
  cmpl   $0xa,-0x100(%rbp)
  jne    L342
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x4,%eax
  mov    %eax,-0xbc(%rbp)
L342:
  mov    -0xf0(%rbp),%rax
  mov    $0x200,%esi
  mov    %rax,%rdi
  call   <padhd@plt>
  mov    -0xf0(%rbp),%rdx
  lea    -0xc4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <gethdl@plt>
  mov    -0xc4(%rbp),%edx
  mov    -0xbc(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xd8(%rbp)
  cmpl   $0x0,-0xb4(%rbp)
  je     L484
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rsi
  lea    D362(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L484:
  movl   $0x1,-0xd4(%rbp)
  cmpl   $0x0,-0xb4(%rbp)
  je     L754
  mov    -0xe8(%rbp),%rax
  mov    %rax,%rsi
  lea    D318(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L754:
  mov    -0xe8(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0xc0(%rbp)
  lea    -0xcc(%rbp),%rdi
  lea    -0xd8(%rbp),%rcx
  lea    -0xc0(%rbp),%rdx
  mov    -0xe8(%rbp),%rsi
  lea    -0xd4(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <dskbow_@plt>
  mov    -0xcc(%rbp),%eax
  test   %eax,%eax
  je     L619
  mov    -0xcc(%rbp),%eax
  jmp    L701
L619:
  movl   $0x0,-0xd0(%rbp)
  lea    -0xd0(%rbp),%rdx
  lea    -0xd4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbww_@plt>
  lea    -0xcc(%rbp),%rcx
  lea    -0xc4(%rbp),%rdx
  mov    -0xf0(%rbp),%rsi
  lea    -0xd4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbw_@plt>
  mov    -0xcc(%rbp),%eax
  test   %eax,%eax
  jne    L338
  lea    -0xcc(%rbp),%rcx
  lea    -0xbc(%rbp),%rdx
  mov    -0xf8(%rbp),%rsi
  lea    -0xd4(%rbp),%rax
  mov    %rax,%rdi
  call   <dskbw_@plt>
  mov    -0xcc(%rbp),%eax
  test   %eax,%eax
  jne    L310
  movl   $0x1,-0xd0(%rbp)
  lea    -0xd0(%rbp),%rdx
  lea    -0xd4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbww_@plt>
  jmp    L37
L338:
  nop
  jmp    L37
L310:
  nop
L37:
  lea    -0xcc(%rbp),%rdx
  lea    -0xd4(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dskbcw_@plt>
  mov    -0xcc(%rbp),%eax
L701:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L684
  call   <__stack_chk_fail@plt>
L684:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D494
type_infered: string
name: retrieve_data
arguments: tag: D188
type_infered: string
name: retrieve_data
arguments: tag: D525
type_infered: string
name: retrieve_data
arguments: tag: D106
type_infered: string
name: retrieve_data
arguments: tag: D405
type_infered: string
name: retrieve_data
arguments: tag: D263
type_infered: string
name: retrieve_data
arguments: tag: D102
type_infered: string
name: retrieve_data
arguments: tag: D329
type_infered: string
name: retrieve_data
arguments: tag: D295
type_infered: string
name: retrieve_data
arguments: tag: D13
type_infered: string
name: retrieve_data
arguments: tag: D196
type_infered: string
name: retrieve_data
arguments: tag: D533
type_infered: string
name: retrieve_data
arguments: tag: D354
type_infered: string
name: retrieve_data
arguments: tag: D593
type_infered: string
name: retrieve_data
arguments: tag: D428
type_infered: string
name: retrieve_data
arguments: tag: D408
type_infered: string
name: retrieve_data
arguments: tag: D99
type_infered: string
name: retrieve_data
arguments: tag: D82
type_infered: string
name: retrieve_data
arguments: tag: D479
type_infered: string
name: retrieve_data
arguments: tag: D225
type_infered: string
name: retrieve_data
arguments: tag: D565
type_infered: string
name: retrieve_data
arguments: tag: D304
type_infered: string
name: retrieve_data
arguments: tag: D142
type_infered: string
name: retrieve_data
arguments: tag: D5
type_infered: string
name: retrieve_data
arguments: tag: D332
type_infered: string
name: retrieve_data
arguments: tag: D513
type_infered: string
name: retrieve_data
arguments: tag: D265
type_infered: string
name: retrieve_data
arguments: tag: D469
type_infered: string
name: retrieve_data
arguments: tag: D573
type_infered: string
name: retrieve_data
arguments: tag: D454
type_infered: string
name: retrieve_data
arguments: tag: D539
type_infered: string
name: retrieve_data
arguments: tag: D362
type_infered: string
name: retrieve_data
arguments: tag: D318
type_infered: string

tool: D494: Filename      : %s


tool: D188: Header        : 
%s<END


tool: D525: Array dim     : %d


tool: D106:               : %d


tool: D405: Type          : %d

tool: D263:  (signed_byte)

tool: D102:  (unsigned_byte)

tool: D329:  (signed_short)

tool: D295:  (unsigned_short)

tool: D13:  (signed_long)

tool: D196:  (unsigned_long)

tool: D533:  (float)

tool: D354:  (double)

tool: D593: SIZE%d

tool: D428: %d

tool: D408: %4d

tool: D99: DIM

tool: D82: TYPE

tool: D479: signed_byte

tool: D225: unsigned_byte

tool: D565: signed_short

tool: D304: unsigned_short

tool: D142: signed_long

tool: D5: unsigned_long

tool: D332: float

tool: D513: double

tool: D265: complex

tool: D469: double_complex

tool: D573: BYTE_ORDER

tool: D454: little_endian

tool: D539: big_endian

tool: D362: Updated Header        : 
%s<END


tool: D318: Opening file : %s


assistant: ```c
int wrfile(char *filename, char *head, char *array, int naxis, int *axis, int type) {
  int size, lun;
  int lflag;
  int istat;
  char s[80], s1[80];
  int t;
  int headl, j, i;
  int as;
  int filec_debug = filec_getdebug();
  if (filec_debug) {
    printf("Filename      : %s\n", filename);
    printf("Header        : \n%s<END\n", head);
    printf("Array dim     : %d\n", naxis);
    for (i = 0; i < naxis; i++)
      printf("              : %d\n", axis[i]);
    printf("Type          : %d", type);
    if (type == 1)
      printf(" (signed_byte)\n");
    else if (type == 2)
      printf(" (unsigned_byte)\n");
    else if (type == 3)
      printf(" (signed_short)\n");
    else if (type == 4)
      printf(" (unsigned_short)\n");
    else if (type == 5)
      printf(" (signed_long)\n");
    else if (type == 6)
      printf(" (unsigned_long)\n");
    else if (type == 7)
      printf(" (float)\n");
    else if (type == 8)
      printf(" (double)\n");
  }
  as = 1;
  for (i = 0; i < naxis; i++) {
    as *= axis[i];
    sprintf(s1, "SIZE%d", i + 1);
    gethd(s1, s, head);
    if (*s == 0 || sscanf(s, "%d", &t) != 1 || t != axis[i]) {
      sprintf(s, "%4d", axis[i]);
      puthd(s1, s, head);
    }
  }
  gethd("DIM", s, head);
  if (sscanf(s, "%d", &t) != 1 || t != naxis) {
    sprintf(s, "%d", naxis);
    puthd("DIM", s, head);
  }
  gethd("TYPE", s, head);
  if (type == 1 && strcmp(s, "signed_byte"))
    puthd("TYPE", "signed_byte", head);
  else if (type == 2 && strcmp(s, "unsigned_byte"))
    puthd("TYPE", "unsigned_byte", head);
  else if (type == 3 && strcmp(s, "signed_short"))
    puthd("TYPE", "signed_short", head);
  else if (type == 4 && strcmp(s, "unsigned_short"))
    puthd("TYPE", "unsigned_short", head);
  else if (type == 5 && strcmp(s, "signed_long"))
    puthd("TYPE", "signed_long", head);
  else if (type == 6 && strcmp(s, "unsigned_long"))
    puthd("TYPE", "unsigned_long", head);
  else if (type == 7 && strcmp(s, "float"))
    puthd("TYPE", "float", head);
  else if (type == 8 && strcmp(s, "double"))
    puthd("TYPE", "double", head);
  else if (type == 9 && strcmp(s, "complex"))
    puthd("TYPE", "float", head);
  else if (type == 10 && strcmp(s, "double_complex"))
    puthd("TYPE", "double", head);
  gethd("BYTE_ORDER", s, head);
  if (getbo() == 0 && strcmp(s, "little_endian") != 0)
    puthd("BYTE_ORDER", "little_endian", head);
  else if (getbo() == 1 && strcmp(s, "big_endian") != 0)
    puthd("BYTE_ORDER", "big_endian", head);
  istat = 0;
  if (type == 1)
    as *= sizeof(char);
  else if (type == 2)
    as *= sizeof(unsigned char);
  else if (type == 3)
    as *= sizeof(short);
  else if (type == 4)
    as *= sizeof(unsigned short);
  else if (type == 5)
    as *= sizeof(int);
  else if (type == 6)
    as *= sizeof(unsigned int);
  else if (type == 7)
    as *= sizeof(float);
  else if (type == 8)
    as *= sizeof(double);
  else if (type == 9)
    as *= 2 * sizeof(float);
  else if (type == 10)
    as *= 2 * sizeof(double);
  padhd(head, 512);
  gethdl(&headl, head);
  size = headl + as;
  if (filec_debug)
    printf("Updated Header        : \n%s<END\n", head);
  lun = 1;
  if (filec_debug)
    printf("Opening file : %s\n", filename);
  j = strlen(filename);
  dskbow_(&lun, filename, &j, &size, &istat);
  if (istat != 0)
    return (istat);
  lflag = (1 == 0);
  dskbww_(&lun, &lflag);
  dskbw_(&lun, head, &headl, &istat);
  if (istat != 0)
    goto close;
  dskbw_(&lun, (char *)array, &as, &istat);
  if (istat != 0)
    goto close;
  lflag = (1 == 1);
  dskbww_(&lun, &lflag);
close:
  dskbcw_(&lun, &istat);
  return (istat);
}
```