#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  scalar_t__ st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free_keys(char **, int);
char **malloc(int);
scalar_t__ mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ search_and_replace_kw(char *, int, char **, char **, int);
int sscanf(char *, char *, char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
int /*<<< orphan*/ strip_beg_end(char *);
scalar_t__ strlen(char *);
int convert_eso_to_std_FITS(char *name_in, char *name_conv) {
  FILE *convtab;
  int nkeys;
  int i;
  char **key_in;
  char **key_out;
  int fd;
  char *buf;
  char line[512];
  char kw1[80], kw2[80];
  int lineno;
  int fs;
  struct stat fileinfo;
  if ((convtab = fopen(name_conv, "r")) == NULL) {
    fprintf(stderr, "cannot open conversion table: %s\n", name_conv);
    return -1;
  }
  nkeys = 0;
  while (fgets(line, 80, convtab) != NULL) {
    if ((line[0] != '#') && (line[0] != '\n')) {
      nkeys++;
    }
  }
  rewind(convtab);
  key_in = malloc(nkeys * sizeof(char *));
  key_out = malloc(nkeys * sizeof(char *));
  i = 0;
  lineno = 0;
  while (fgets(line, 80, convtab) != NULL) {
    lineno++;
    if ((line[0] != '#') && (line[0] != '\n')) {
      if (sscanf(line, "%[^=] = %[^;#]", kw1, kw2) != 2) {
        fprintf(stderr, "*** error parsing table file %s\n", name_conv);
        fprintf(stderr, "line: %d\n", lineno);
        free_keys(key_in, i);
        free_keys(key_out, i);
        fclose(convtab);
        return -1;
      }
      strip_beg_end(kw1);
      strip_beg_end(kw2);
      if (strlen(kw2) > strlen(kw1)) {
        fprintf(stderr, "*** error in conversion table %s (line %d)\n",
                name_conv, lineno);
        fprintf(stderr, "*** error: dest keyword is longer than original\n");
        fprintf(stderr, "orig: [%s] dest: [%s]\n", kw1, kw2);
        fclose(convtab);
        free_keys(key_in, i);
        free_keys(key_out, i);
        return -1;
      }
      key_in[i] = strdup(kw1);
      key_out[i] = strdup(kw2);
      i++;
    }
  }
  fclose(convtab);
  printf("\n\n");
  printf("*** hierarch28\n");
  printf("\n");
  printf("searching %s and replacing the following keywords:\n", name_in);
  for (i = 0; i < nkeys; i++) {
    printf("\t[%s]\t=>\t[%s]\n", key_in[i], key_out[i]);
  }
  printf("\n\n");
  if (stat(name_in, &fileinfo) != 0) {
    fprintf(stderr, "*** error: accessing file [%s]\n", name_in);
    free_keys(key_in, nkeys);
    free_keys(key_out, nkeys);
    return -1;
  }
  fs = (int)fileinfo.st_size;
  if (fs < 1) {
    fprintf(stderr, "error getting FITS header size for %s\n", name_in);
    free_keys(key_in, nkeys);
    free_keys(key_out, nkeys);
    return -1;
  }
  fd = open(name_in, O_RDWR);
  if (fd == -1) {
    fprintf(stderr, "cannot open %s: aborting\n", name_in);
    free_keys(key_in, nkeys);
    free_keys(key_out, nkeys);
    return -1;
  }
  buf = (char *)mmap(0, fs, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (buf == (char *)-1) {
    perror("mmap");
    fprintf(stderr, "cannot mmap file: %s\n", name_in);
    free_keys(key_in, nkeys);
    free_keys(key_out, nkeys);
    close(fd);
    return -1;
  }
  if (search_and_replace_kw(buf, fs, key_in, key_out, nkeys) != 0) {
    fprintf(stderr, "error while doing search and replace\n");
  }
  free_keys(key_in, nkeys);
  free_keys(key_out, nkeys);
  close(fd);
  munmap(buf, fs);
  return 0;
}


x86 assembly (clang, -O0):
<convert_eso_to_std_FITS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x310,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1288 <convert_eso_to_std_FITS+0x58>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
movl   $0x0,-0x24(%rbp)
lea    -0x250(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x50,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     12dc <convert_eso_to_std_FITS+0xac>
movsbl -0x250(%rbp),%eax
cmp    $0x23,%eax
je     12d7 <convert_eso_to_std_FITS+0xa7>
movsbl -0x250(%rbp),%eax
cmp    $0xa,%eax
je     12d7 <convert_eso_to_std_FITS+0xa7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    128f <convert_eso_to_std_FITS+0x5f>
mov    -0x20(%rbp),%rdi
call   1080 <rewind@plt>
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2f4(%rbp)
lea    -0x250(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x50,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1511 <convert_eso_to_std_FITS+0x2e1>
mov    -0x2f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2f4(%rbp)
movsbl -0x250(%rbp),%eax
cmp    $0x23,%eax
je     150c <convert_eso_to_std_FITS+0x2dc>
movsbl -0x250(%rbp),%eax
cmp    $0xa,%eax
je     150c <convert_eso_to_std_FITS+0x2dc>
lea    -0x250(%rbp),%rdi
lea    -0x2a0(%rbp),%rdx
lea    -0x2f0(%rbp),%rcx
lea    0xc9e(%rip),%rsi
call   10f0 <sscanf@plt>
cmp    $0x2,%eax
je     13f9 <convert_eso_to_std_FITS+0x1c9>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xc8b(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
mov    -0x2f4(%rbp),%edx
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
lea    -0x2a0(%rbp),%rdi
call   1060 <strip_beg_end@plt>
lea    -0x2f0(%rbp),%rdi
call   1060 <strip_beg_end@plt>
lea    -0x2f0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x308(%rbp)
lea    -0x2a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x308(%rbp),%rax
cmp    %rcx,%rax
jle    14cd <convert_eso_to_std_FITS+0x29d>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x2f4(%rbp),%ecx
lea    0xc01(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2b5d(%rip),%rax
mov    (%rax),%edi
lea    0xc16(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2b46(%rip),%rax
mov    (%rax),%edi
lea    -0x2a0(%rbp),%rdx
lea    -0x2f0(%rbp),%rcx
lea    0xc22(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10e0 <free_keys@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
lea    -0x2a0(%rbp),%rdi
call   1150 <strdup@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
lea    -0x2f0(%rbp),%rdi
call   1150 <strdup@plt>
mov    %rax,%rdx
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    131c <convert_eso_to_std_FITS+0xec>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xba6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xb96(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xb96(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    159d <convert_eso_to_std_FITS+0x36d>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xb91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    155d <convert_eso_to_std_FITS+0x32d>
lea    0xb2e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x300(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
je     1604 <convert_eso_to_std_FITS+0x3d4>
mov    0x29fc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xb4f(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
mov    -0x300(%rbp),%rax
mov    %eax,-0x2f8(%rbp)
cmpl   $0x1,-0x2f8(%rbp)
jge    165d <convert_eso_to_std_FITS+0x42d>
mov    0x29a3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xb16(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
mov    -0x10(%rbp),%rdi
mov    0x2970(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    16bb <convert_eso_to_std_FITS+0x48b>
mov    0x2945(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xadf(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
mov    -0x2f8(%rbp),%esi
mov    0x2930(%rip),%rax
mov    (%rax),%edx
mov    0x28ef(%rip),%rax
or     (%rax),%edx
mov    0x290e(%rip),%rax
mov    (%rax),%ecx
mov    -0x3c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x48(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x48(%rbp)
jne    1753 <convert_eso_to_std_FITS+0x523>
lea    0xa82(%rip),%rdi
call   1130 <perror@plt>
mov    0x28b5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xa6e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x3c(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17c5 <convert_eso_to_std_FITS+0x595>
mov    -0x48(%rbp),%rdi
mov    -0x2f8(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1140 <search_and_replace_kw@plt>
cmp    $0x0,%rax
je     178f <convert_eso_to_std_FITS+0x55f>
mov    0x2849(%rip),%rax
mov    (%rax),%edi
lea    0xa1c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <free_keys@plt>
mov    -0x3c(%rbp),%edi
call   1090 <close@plt>
mov    -0x48(%rbp),%rdi
mov    -0x2f8(%rbp),%esi
call   1100 <munmap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x310,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_eso_to_std_FITS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2e8,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xd92(%rip),%rsi
mov    %rbx,%rdi
call   1140 <fopen@plt>
test   %rax,%rax
je     12da <convert_eso_to_std_FITS+0x8a>
mov    %rax,%rbp
lea    0xe0(%rsp),%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
mov    %r14,0x8(%rsp)
mov    %rbx,0x20(%rsp)
je     12f9 <convert_eso_to_std_FITS+0xa9>
xor    %ebx,%ebx
lea    0xe0(%rsp),%r14
jmp    12c5 <convert_eso_to_std_FITS+0x75>
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbp,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     12fb <convert_eso_to_std_FITS+0xab>
movzbl 0xe0(%rsp),%eax
cmp    $0xa,%al
je     12b0 <convert_eso_to_std_FITS+0x60>
cmp    $0x23,%al
je     12b0 <convert_eso_to_std_FITS+0x60>
add    $0x1,%ebx
jmp    12b0 <convert_eso_to_std_FITS+0x60>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    14ef <convert_eso_to_std_FITS+0x29f>
xor    %ebx,%ebx
mov    %rbp,%rdi
call   10a0 <rewind@plt>
mov    %rbx,0x30(%rsp)
lea    0x0(,%rbx,8),%ebx
mov    %ebx,%edi
call   10f0 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %ebx,%edi
call   10f0 <malloc@plt>
mov    %rax,%r15
lea    0xe0(%rsp),%rdi
mov    $0x50,%esi
mov    %rbp,0x18(%rsp)
mov    %rbp,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     1419 <convert_eso_to_std_FITS+0x1c9>
xor    %r13d,%r13d
mov    $0x1,%ebp
lea    0xe0(%rsp),%r14
lea    0x90(%rsp),%r12
lea    0x40(%rsp),%rbx
mov    %r15,0x28(%rsp)
jmp    138e <convert_eso_to_std_FITS+0x13e>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x50,%esi
mov    0x18(%rsp),%rdx
call   10c0 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     1419 <convert_eso_to_std_FITS+0x1c9>
movzbl 0xe0(%rsp),%eax
cmp    $0xa,%al
je     1370 <convert_eso_to_std_FITS+0x120>
cmp    $0x23,%al
je     1370 <convert_eso_to_std_FITS+0x120>
mov    %r14,%rdi
lea    0xc7c(%rip),%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1110 <sscanf@plt>
cmp    $0x2,%eax
jne    15c9 <convert_eso_to_std_FITS+0x379>
mov    %r12,%rdi
call   1080 <strip_beg_end@plt>
mov    %rbx,%rdi
call   1080 <strip_beg_end@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1060 <strlen@plt>
cmp    %rax,%r15
jg     1622 <convert_eso_to_std_FITS+0x3d2>
mov    %r12,%rdi
call   1170 <strdup@plt>
movslq %r13d,%r15
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx,%r15,8)
mov    %rbx,%rdi
call   1170 <strdup@plt>
mov    0x28(%rsp),%rcx
mov    %rax,(%rcx,%r15,8)
mov    %rcx,%r15
add    $0x1,%r13d
jmp    1370 <convert_eso_to_std_FITS+0x120>
mov    0x18(%rsp),%rdi
call   1050 <fclose@plt>
lea    0xc5e(%rip),%rdi
call   1040 <puts@plt>
lea    0xd81(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc86(%rip),%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x30(%rsp),%r12
test   %r12d,%r12d
mov    0x10(%rsp),%r13
jle    149c <convert_eso_to_std_FITS+0x24c>
mov    %r12d,%ebp
lea    0xc95(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rsi
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1480 <convert_eso_to_std_FITS+0x230>
lea    0xbe5(%rip),%rdi
call   1040 <puts@plt>
lea    0x38(%rsp),%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   10e0 <stat@plt>
test   %rax,%rax
je     1506 <convert_eso_to_std_FITS+0x2b6>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
lea    0xc46(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
call   1100 <free_keys@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1100 <free_keys@plt>
mov    $0xffffffff,%eax
add    $0x2e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x38(%rsp),%ebp
test   %ebp,%ebp
jle    1697 <convert_eso_to_std_FITS+0x447>
mov    0x2abf(%rip),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1130 <open@plt>
cmp    $0xffffffff,%eax
je     16b1 <convert_eso_to_std_FITS+0x461>
mov    %eax,%r14d
mov    0x2abd(%rip),%rax
mov    0x2a7e(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2a9b(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebp,%esi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     16c6 <convert_eso_to_std_FITS+0x476>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12d,%r8d
call   1160 <search_and_replace_kw@plt>
test   %rax,%rax
je     159a <convert_eso_to_std_FITS+0x34a>
mov    0x2a3e(%rip),%rax
mov    (%rax),%edi
lea    0xbfe(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
call   1100 <free_keys@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1100 <free_keys@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1120 <munmap@plt>
xor    %eax,%eax
jmp    14f4 <convert_eso_to_std_FITS+0x2a4>
mov    0x29f8(%rip),%r12
mov    (%r12),%edi
lea    0xa58(%rip),%rsi
mov    0x20(%rsp),%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r12),%edi
lea    0xa62(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x10(%rsp),%rdi
mov    %r13d,%esi
call   1100 <free_keys@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   1100 <free_keys@plt>
mov    0x18(%rsp),%rdi
call   1050 <fclose@plt>
jmp    14ef <convert_eso_to_std_FITS+0x29f>
mov    0x299f(%rip),%r12
mov    (%r12),%edi
lea    0xa2a(%rip),%rsi
mov    0x20(%rsp),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r12),%edi
lea    0xa3d(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r12),%edi
lea    0xa5c(%rip),%rsi
lea    0x90(%rsp),%rdx
lea    0x40(%rsp),%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x18(%rsp),%rdi
call   1050 <fclose@plt>
mov    0x10(%rsp),%rdi
mov    %r13d,%esi
call   1100 <free_keys@plt>
mov    0x28(%rsp),%rdi
mov    %r13d,%esi
jmp    14ea <convert_eso_to_std_FITS+0x29a>
mov    0x292a(%rip),%rax
mov    (%rax),%edi
lea    0xa8e(%rip),%rsi
mov    0x8(%rsp),%rdx
jmp    14d2 <convert_eso_to_std_FITS+0x282>
mov    0x2910(%rip),%rax
mov    (%rax),%edi
lea    0xa9b(%rip),%rsi
jmp    14cf <convert_eso_to_std_FITS+0x27f>
lea    0xaa9(%rip),%rdi
call   1150 <perror@plt>
mov    0x28ef(%rip),%rax
mov    (%rax),%edi
lea    0xa99(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
call   1100 <free_keys@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1100 <free_keys@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
jmp    14ef <convert_eso_to_std_FITS+0x29f>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"cannot open conversion table: %s\0A\00"
@.str.2 = [15 x i8] c"%[^=] = %[^;#]\00"
@.str.3 = [33 x i8] c"*** error parsing table file %s\0A\00"
@.str.4 = [10 x i8] c"line: %d\0A\00"
@.str.5 = [44 x i8] c"*** error in conversion table %s (line %d)\0A\00"
@.str.6 = [49 x i8] c"*** error: dest keyword is longer than original\0A\00"
@.str.7 = [23 x i8] c"orig: [%s] dest: [%s]\0A\00"
@.str.8 = [3 x i8] c"\0A\0A\00"
@.str.9 = [16 x i8] c"*** hierarch28\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [52 x i8] c"searching %s and replacing the following keywords:\0A\00"
@.str.12 = [15 x i8] c"\09[%s]\09=>\09[%s]\0A\00"
@.str.13 = [32 x i8] c"*** error: accessing file [%s]\0A\00"
@.str.14 = [39 x i8] c"error getting FITS header size for %s\0A\00"
@O_RDWR = global i32 0
@.str.15 = [26 x i8] c"cannot open %s: aborting\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.16 = [5 x i8] c"mmap\00"
@.str.17 = [22 x i8] c"cannot mmap file: %s\0A\00"
@.str.18 = [38 x i8] c"error while doing search and replace\0A\00"
define i32 @convert_eso_to_std_FITS(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i8*
%13 = alloca [512 x i8]
%14 = alloca [80 x i8]
%15 = alloca [80 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.stat
store i8* %0, i8** %4
store i8* %1, i8** %5
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %24)
store i32 -1, i32* %3
br label %263
26: ; preds = %2
store i32 0, i32* %7
br label %27
27: ; preds = %45, %26
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%29 = load i32*, i32** %6
%30 = call i32* @fgets(i8* %28, i32 80, i32* %29)
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %46
32: ; preds = %27
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 35
br i1 %36, label %37, label %45
37: ; preds = %32
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 10
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %45
45: ; preds = %42, %37, %32
br label %27
46: ; preds = %27
%47 = load i32*, i32** %6
%48 = call i32 @rewind(i32* %47)
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = mul i64 %50, 8
%52 = trunc i64 %51 to i32
%53 = call i8** @malloc(i32 %52)
store i8** %53, i8*** %9
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = mul i64 %55, 8
%57 = trunc i64 %56 to i32
%58 = call i8** @malloc(i32 %57)
store i8** %58, i8*** %10
store i32 0, i32* %8
store i32 0, i32* %16
br label %59
59: ; preds = %141, %46
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%61 = load i32*, i32** %6
%62 = call i32* @fgets(i8* %60, i32 80, i32* %61)
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %142
64: ; preds = %59
%65 = load i32, i32* %16
%66 = add nsw i32 %65, 1
store i32 %66, i32* %16
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 35
br i1 %70, label %71, label %141
71: ; preds = %64
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 10
br i1 %75, label %76, label %141
76: ; preds = %71
%77 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%78 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%79 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%80 = call i32 @sscanf(i8* %77, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %78, i8* %79)
%81 = icmp ne i32 %80, 2
br i1 %81, label %82, label %97
82: ; preds = %76
%83 = load i32, i32* @stderr
%84 = load i8*, i8** %5
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %84)
%86 = load i32, i32* @stderr
%87 = load i32, i32* %16
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %87)
%89 = load i8**, i8*** %9
%90 = load i32, i32* %8
%91 = call i32 @free_keys(i8** %89, i32 %90)
%92 = load i8**, i8*** %10
%93 = load i32, i32* %8
%94 = call i32 @free_keys(i8** %92, i32 %93)
%95 = load i32*, i32** %6
%96 = call i32 @fclose(i32* %95)
store i32 -1, i32* %3
br label %263
97: ; preds = %76
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%99 = call i32 @strip_beg_end(i8* %98)
%100 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%101 = call i32 @strip_beg_end(i8* %100)
%102 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%103 = call i64 @strlen(i8* %102)
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%105 = call i64 @strlen(i8* %104)
%106 = icmp sgt i64 %103, %105
br i1 %106, label %107, label %126
107: ; preds = %97
%108 = load i32, i32* @stderr
%109 = load i8*, i8** %5
%110 = load i32, i32* %16
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* %109, i32 %110)
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%114 = load i32, i32* @stderr
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%116 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %115, i8* %116)
%118 = load i32*, i32** %6
%119 = call i32 @fclose(i32* %118)
%120 = load i8**, i8*** %9
%121 = load i32, i32* %8
%122 = call i32 @free_keys(i8** %120, i32 %121)
%123 = load i8**, i8*** %10
%124 = load i32, i32* %8
%125 = call i32 @free_keys(i8** %123, i32 %124)
store i32 -1, i32* %3
br label %263
126: ; preds = %97
%127 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%128 = call i8* @strdup(i8* %127)
%129 = load i8**, i8*** %9
%130 = load i32, i32* %8
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i8*, i8** %129, i64 %131
store i8* %128, i8** %132
%133 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%134 = call i8* @strdup(i8* %133)
%135 = load i8**, i8*** %10
%136 = load i32, i32* %8
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8*, i8** %135, i64 %137
store i8* %134, i8** %138
%139 = load i32, i32* %8
%140 = add nsw i32 %139, 1
store i32 %140, i32* %8
br label %141
141: ; preds = %126, %71, %64
br label %59
142: ; preds = %59
%143 = load i32*, i32** %6
%144 = call i32 @fclose(i32* %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%148 = load i8*, i8** %4
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.11, i64 0, i64 0), i8* %148)
store i32 0, i32* %8
br label %150
150: ; preds = %166, %142
%151 = load i32, i32* %8
%152 = load i32, i32* %7
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %169
154: ; preds = %150
%155 = load i8**, i8*** %9
%156 = load i32, i32* %8
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8*, i8** %155, i64 %157
%159 = load i8*, i8** %158
%160 = load i8**, i8*** %10
%161 = load i32, i32* %8
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8*, i8** %160, i64 %162
%164 = load i8*, i8** %163
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* %159, i8* %164)
br label %166
166: ; preds = %154
%167 = load i32, i32* %8
%168 = add nsw i32 %167, 1
store i32 %168, i32* %8
br label %150
169: ; preds = %150
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%171 = load i8*, i8** %4
%172 = call i64 @stat(i8* %171, %struct.stat* %18)
%173 = icmp ne i64 %172, 0
br i1 %173, label %174, label %184
174: ; preds = %169
%175 = load i32, i32* @stderr
%176 = load i8*, i8** %4
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.13, i64 0, i64 0), i8* %176)
%178 = load i8**, i8*** %9
%179 = load i32, i32* %7
%180 = call i32 @free_keys(i8** %178, i32 %179)
%181 = load i8**, i8*** %10
%182 = load i32, i32* %7
%183 = call i32 @free_keys(i8** %181, i32 %182)
store i32 -1, i32* %3
br label %263
184: ; preds = %169
%185 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%186 = load i64, i64* %185
%187 = trunc i64 %186 to i32
store i32 %187, i32* %17
%188 = load i32, i32* %17
%189 = icmp slt i32 %188, 1
br i1 %189, label %190, label %200
190: ; preds = %184
%191 = load i32, i32* @stderr
%192 = load i8*, i8** %4
%193 = call i32 (i32, i8*, ...) @fprintf(i32 %191, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8* %192)
%194 = load i8**, i8*** %9
%195 = load i32, i32* %7
%196 = call i32 @free_keys(i8** %194, i32 %195)
%197 = load i8**, i8*** %10
%198 = load i32, i32* %7
%199 = call i32 @free_keys(i8** %197, i32 %198)
store i32 -1, i32* %3
br label %263
200: ; preds = %184
%201 = load i8*, i8** %4
%202 = load i32, i32* @O_RDWR
%203 = call i32 @open(i8* %201, i32 %202)
store i32 %203, i32* %11
%204 = load i32, i32* %11
%205 = icmp eq i32 %204, -1
br i1 %205, label %206, label %216
206: ; preds = %200
%207 = load i32, i32* @stderr
%208 = load i8*, i8** %4
%209 = call i32 (i32, i8*, ...) @fprintf(i32 %207, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %208)
%210 = load i8**, i8*** %9
%211 = load i32, i32* %7
%212 = call i32 @free_keys(i8** %210, i32 %211)
%213 = load i8**, i8*** %10
%214 = load i32, i32* %7
%215 = call i32 @free_keys(i8** %213, i32 %214)
store i32 -1, i32* %3
br label %263
216: ; preds = %200
%217 = load i32, i32* %17
%218 = load i32, i32* @PROT_READ
%219 = load i32, i32* @PROT_WRITE
%220 = or i32 %218, %219
%221 = load i32, i32* @MAP_SHARED
%222 = load i32, i32* %11
%223 = call i64 @mmap(i32 0, i32 %217, i32 %220, i32 %221, i32 %222, i32 0)
%224 = inttoptr i64 %223 to i8*
store i8* %224, i8** %12
%225 = load i8*, i8** %12
%226 = icmp eq i8* %225, inttoptr (i64 -1 to i8*)
br i1 %226, label %227, label %240
227: ; preds = %216
%228 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%229 = load i32, i32* @stderr
%230 = load i8*, i8** %4
%231 = call i32 (i32, i8*, ...) @fprintf(i32 %229, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %230)
%232 = load i8**, i8*** %9
%233 = load i32, i32* %7
%234 = call i32 @free_keys(i8** %232, i32 %233)
%235 = load i8**, i8*** %10
%236 = load i32, i32* %7
%237 = call i32 @free_keys(i8** %235, i32 %236)
%238 = load i32, i32* %11
%239 = call i32 @close(i32 %238)
store i32 -1, i32* %3
br label %263
240: ; preds = %216
%241 = load i8*, i8** %12
%242 = load i32, i32* %17
%243 = load i8**, i8*** %9
%244 = load i8**, i8*** %10
%245 = load i32, i32* %7
%246 = call i64 @search_and_replace_kw(i8* %241, i32 %242, i8** %243, i8** %244, i32 %245)
%247 = icmp ne i64 %246, 0
br i1 %247, label %248, label %251
248: ; preds = %240
%249 = load i32, i32* @stderr
%250 = call i32 (i32, i8*, ...) @fprintf(i32 %249, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0))
br label %251
251: ; preds = %248, %240
%252 = load i8**, i8*** %9
%253 = load i32, i32* %7
%254 = call i32 @free_keys(i8** %252, i32 %253)
%255 = load i8**, i8*** %10
%256 = load i32, i32* %7
%257 = call i32 @free_keys(i8** %255, i32 %256)
%258 = load i32, i32* %11
%259 = call i32 @close(i32 %258)
%260 = load i8*, i8** %12
%261 = load i32, i32* %17
%262 = call i32 @munmap(i8* %260, i32 %261)
store i32 0, i32* %3
br label %263
263: ; preds = %251, %227, %206, %190, %174, %107, %82, %22
%264 = load i32, i32* %3
ret i32 %264
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"cannot open conversion table: %s\0A\00"
@.str.2 = [15 x i8] c"%[^=] = %[^;#]\00"
@.str.3 = [33 x i8] c"*** error parsing table file %s\0A\00"
@.str.4 = [10 x i8] c"line: %d\0A\00"
@.str.5 = [44 x i8] c"*** error in conversion table %s (line %d)\0A\00"
@.str.6 = [49 x i8] c"*** error: dest keyword is longer than original\0A\00"
@.str.7 = [23 x i8] c"orig: [%s] dest: [%s]\0A\00"
@.str.11 = [52 x i8] c"searching %s and replacing the following keywords:\0A\00"
@.str.12 = [15 x i8] c"\09[%s]\09=>\09[%s]\0A\00"
@.str.13 = [32 x i8] c"*** error: accessing file [%s]\0A\00"
@.str.14 = [39 x i8] c"error getting FITS header size for %s\0A\00"
@O_RDWR = global i32 0
@.str.15 = [26 x i8] c"cannot open %s: aborting\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.16 = [5 x i8] c"mmap\00"
@.str.17 = [22 x i8] c"cannot mmap file: %s\0A\00"
@.str.18 = [38 x i8] c"error while doing search and replace\0A\00"
@str.19 = [15 x i8] c"*** hierarch28\00"
@str.20 = [2 x i8] c"\0A\00"
define i32 @convert_eso_to_std_FITS(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca %struct.stat
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = bitcast %struct.stat* %6 to i8*
%11 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = call i32* @fgets(i8* %7, i32 80, i32* %11)
%15 = icmp eq i32* %14, null
br i1 %15, label %28, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %151
19: ; preds = %13, %24
%20 = phi i32 [ %25, %24 ], [ 0, %13 ]
%21 = load i8, i8* %7
switch i8 %21, label %22 [
i8 35, label %24
i8 10, label %24
]
22: ; preds = %19
%23 = add nsw i32 %20, 1
br label %24
24: ; preds = %19, %19, %22
%25 = phi i32 [ %23, %22 ], [ %20, %19 ], [ %20, %19 ]
%26 = call i32* @fgets(i8* %7, i32 80, i32* %11)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %19
28: ; preds = %24, %13
%29 = phi i32 [ 0, %13 ], [ %25, %24 ]
%30 = call i32 @rewind(i32* %11)
%31 = shl i32 %29, 3
%32 = call i8** @malloc(i32 %31)
%33 = call i8** @malloc(i32 %31)
%34 = call i32* @fgets(i8* %7, i32 80, i32* %11)
%35 = icmp eq i32* %34, null
br i1 %35, label %79, label %36
36: ; preds = %28, %75
%37 = phi i32 [ %39, %75 ], [ 0, %28 ]
%38 = phi i32 [ %76, %75 ], [ 0, %28 ]
%39 = add nuw nsw i32 %37, 1
%40 = load i8, i8* %7
switch i8 %40, label %41 [
i8 35, label %75
i8 10, label %75
]
41: ; preds = %36
%42 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %9)
%43 = icmp eq i32 %42, 2
br i1 %43, label %52, label %44
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%49 = call i32 @free_keys(i8** %32, i32 %38)
%50 = call i32 @free_keys(i8** %33, i32 %38)
%51 = call i32 @fclose(i32* %11)
br label %151
52: ; preds = %41
%53 = call i32 @strip_beg_end(i8* %8)
%54 = call i32 @strip_beg_end(i8* %9)
%55 = call i64 @strlen(i8* %9)
%56 = call i64 @strlen(i8* %8)
%57 = icmp sgt i64 %55, %56
br i1 %57, label %58, label %68
58: ; preds = %52
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* %1, i32 %39)
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %8, i8* %9)
%65 = call i32 @fclose(i32* %11)
%66 = call i32 @free_keys(i8** %32, i32 %38)
%67 = call i32 @free_keys(i8** %33, i32 %38)
br label %151
68: ; preds = %52
%69 = call i8* @strdup(i8* %8)
%70 = sext i32 %38 to i64
%71 = getelementptr inbounds i8*, i8** %32, i64 %70
store i8* %69, i8** %71
%72 = call i8* @strdup(i8* %9)
%73 = getelementptr inbounds i8*, i8** %33, i64 %70
store i8* %72, i8** %73
%74 = add nsw i32 %38, 1
br label %75
75: ; preds = %36, %36, %68
%76 = phi i32 [ %74, %68 ], [ %38, %36 ], [ %38, %36 ]
%77 = call i32* @fgets(i8* %7, i32 80, i32* %11)
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %36
79: ; preds = %75, %28
%80 = call i32 @fclose(i32* %11)
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.20, i64 0, i64 0))
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.19, i64 0, i64 0))
%83 = call i32 @putchar(i32 10)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.11, i64 0, i64 0), i8* %0)
%85 = icmp sgt i32 %29, 0
br i1 %85, label %86, label %97
86: ; preds = %79
%87 = zext i32 %29 to i64
br label %88
88: ; preds = %86, %88
%89 = phi i64 [ 0, %86 ], [ %95, %88 ]
%90 = getelementptr inbounds i8*, i8** %32, i64 %89
%91 = load i8*, i8** %90
%92 = getelementptr inbounds i8*, i8** %33, i64 %89
%93 = load i8*, i8** %92
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* %91, i8* %93)
%95 = add nuw nsw i64 %89, 1
%96 = icmp eq i64 %95, %87
br i1 %96, label %97, label %88
97: ; preds = %88, %79
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.20, i64 0, i64 0))
%99 = call i64 @stat(i8* %0, %struct.stat* %6)
%100 = icmp eq i64 %99, 0
br i1 %100, label %106, label %101
101: ; preds = %97
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.13, i64 0, i64 0), i8* %0)
%104 = call i32 @free_keys(i8** %32, i32 %29)
%105 = call i32 @free_keys(i8** %33, i32 %29)
br label %151
106: ; preds = %97
%107 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%108 = load i64, i64* %107
%109 = trunc i64 %108 to i32
%110 = icmp slt i32 %109, 1
br i1 %110, label %111, label %116
111: ; preds = %106
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i8* %0)
%114 = call i32 @free_keys(i8** %32, i32 %29)
%115 = call i32 @free_keys(i8** %33, i32 %29)
br label %151
116: ; preds = %106
%117 = load i32, i32* @O_RDWR
%118 = call i32 @open(i8* %0, i32 %117)
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %125
120: ; preds = %116
%121 = load i32, i32* @stderr
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %0)
%123 = call i32 @free_keys(i8** %32, i32 %29)
%124 = call i32 @free_keys(i8** %33, i32 %29)
br label %151
125: ; preds = %116
%126 = load i32, i32* @PROT_READ
%127 = load i32, i32* @PROT_WRITE
%128 = or i32 %127, %126
%129 = load i32, i32* @MAP_SHARED
%130 = call i64 @mmap(i32 0, i32 %109, i32 %128, i32 %129, i32 %118, i32 0)
%131 = inttoptr i64 %130 to i8*
%132 = icmp eq i8* %131, inttoptr (i64 -1 to i8*)
br i1 %132, label %133, label %140
133: ; preds = %125
%134 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%135 = load i32, i32* @stderr
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %0)
%137 = call i32 @free_keys(i8** %32, i32 %29)
%138 = call i32 @free_keys(i8** %33, i32 %29)
%139 = call i32 @close(i32 %118)
br label %151
140: ; preds = %125
%141 = call i64 @search_and_replace_kw(i8* %131, i32 %109, i8** %32, i8** %33, i32 %29)
%142 = icmp eq i64 %141, 0
br i1 %142, label %146, label %143
143: ; preds = %140
%144 = load i32, i32* @stderr
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0))
br label %146
146: ; preds = %143, %140
%147 = call i32 @free_keys(i8** %32, i32 %29)
%148 = call i32 @free_keys(i8** %33, i32 %29)
%149 = call i32 @close(i32 %118)
%150 = call i32 @munmap(i8* %131, i32 %109)
br label %151
151: ; preds = %146, %133, %120, %111, %101, %58, %44, %16
%152 = phi i32 [ -1, %16 ], [ -1, %44 ], [ -1, %58 ], [ -1, %101 ], [ -1, %111 ], [ -1, %120 ], [ -1, %133 ], [ 0, %146 ]
ret i32 %152
}