#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;
  int st_blksize;
};

/* Variables and functions */
int O_CREAT;
int O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int atoi(char *);
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int fstat(int, struct stat *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int open(char *, int, int);
int /*<<< orphan*/ read(int, char *, int);
scalar_t__ rename(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
scalar_t__ unlink(char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int ret = 0;
  if ((argc == 3) || (argc == 4)) {
    int fax_format, to_fd;
    char dest_file_name[1024], *filename, *ttaaii;
    filename = argv[1];
    ttaaii = argv[2];
    if ((to_fd = strlen(ttaaii)) != 18) {
      (void)fprintf(stderr,
                    "WMO header must be at least 18 bytes long and must be a "
                    "WMO header. (%s %d)\n",
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/"
                    "master/src/tools/fax2gts.c",
                    92);
      exit(-1);
    }
    if (argc == 4) {
      fax_format = atoi(argv[3]);
      switch (fax_format) {
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
        break;
      default:
        (void)fprintf(stderr, "Wrong FAX format number %d (%s %d)\n",
                      fax_format,
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/"
                      "master/src/tools/fax2gts.c",
                      110);
        exit(-1);
      }
    } else {
      fax_format = 2;
    }
    (void)sprintf(dest_file_name, ".%s", filename);
    if ((to_fd = open(dest_file_name, (O_WRONLY | O_CREAT | O_TRUNC),
                      (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
      (void)fprintf(stderr, "Failed to open() `%s' : %s (%s %d)\n",
                    dest_file_name, strerror(errno),
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/"
                    "master/src/tools/fax2gts.c",
                    125);
      (void)unlink(dest_file_name);
    } else {
      char fullname[1024], wmo_header[33];
      wmo_header[0] = 1;
      wmo_header[1] = '\015';
      wmo_header[2] = '\015';
      wmo_header[3] = '\012';
      (void)memcpy(&wmo_header[4], ttaaii, 18);
      wmo_header[10] = wmo_header[15] = ' ';
      wmo_header[22] = '\015';
      wmo_header[23] = '\015';
      wmo_header[24] = '\012';
      wmo_header[25] = 'D';
      wmo_header[26] = 'F';
      wmo_header[27] = 'A';
      wmo_header[28] = 'X';
      wmo_header[29] = '1';
      wmo_header[30] = '0';
      switch (fax_format) {
      case 1:
        wmo_header[31] = '6';
        wmo_header[32] = '2';
        break;
      case 3:
        wmo_header[31] = '7';
        wmo_header[32] = '4';
        break;
      case 4:
        wmo_header[31] = '8';
        wmo_header[32] = '4';
        break;
      case 5:
        wmo_header[31] = '9';
        wmo_header[32] = '9';
        break;
      default:
        wmo_header[31] = '6';
        wmo_header[32] = '4';
        break;
      }
      if (write(to_fd, wmo_header, 33) != 33) {
        (void)fprintf(stderr,
                      "Failed to write() WMO header to `%s' : %s (%s %d)\n",
                      dest_file_name, strerror(errno),
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/"
                      "master/src/tools/fax2gts.c",
                      180);
        (void)unlink(dest_file_name);
        ret = -1;
      } else {
        int from_fd;
        (void)sprintf(fullname, "%s", filename);
        if ((from_fd = open(fullname, O_RDONLY, 0)) < 0) {
          (void)fprintf(stderr, "Failed to open() `%s' : %s (%s %d)\n",
                        fullname, strerror(errno),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                        "refs/heads/master/src/tools/fax2gts.c",
                        193);
          ret = -1;
        } else {
          struct stat stat_buf;
          if (fstat(from_fd, &stat_buf) == -1) {
            (void)fprintf(stderr, "Failed to fstat() `%s' : %s (%s %d)\n",
                          fullname, strerror(errno),
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                          "refs/heads/master/src/tools/fax2gts.c",
                          203);
            ret = -1;
          } else {
            if (stat_buf.st_size > 0) {
              char *buffer;
              if ((buffer = malloc(stat_buf.st_blksize)) == NULL) {
                (void)fprintf(stderr,
                              "Failed to malloc() %d bytes : %s (%s %d)\n",
                              stat_buf.st_blksize, strerror(errno),
                              "/scratch/repos/new/home/jordi_armengol_estape/"
                              "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/"
                              "afd/refs/heads/master/src/tools/fax2gts.c",
                              217);
                ret = -1;
              } else {
                int bytes_buffered;
                do {
                  if ((bytes_buffered =
                           read(from_fd, buffer, stat_buf.st_blksize)) == -1) {
                    (void)fprintf(
                        stderr,
                        "Failed to read() %d bytes from `%s' : %s (%s %d)\n",
                        stat_buf.st_blksize, fullname, strerror(errno),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                        "refs/heads/master/src/tools/fax2gts.c",
                        233);
                    ret = -1;
                    break;
                  }
                  if (bytes_buffered > 0) {
                    if (write(to_fd, buffer, bytes_buffered) !=
                        bytes_buffered) {
                      (void)fprintf(
                          stderr,
                          "Failed to write() %d bytes to `%s' : %s (%s %d)\n",
                          bytes_buffered, dest_file_name, strerror(errno),
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                          "refs/heads/master/src/tools/fax2gts.c",
                          244);
                      ret = -1;
                      break;
                    }
                  }
                } while (bytes_buffered == stat_buf.st_blksize);
                free(buffer);
                if (ret != -1) {
                  wmo_header[0] = '\015';
                  wmo_header[1] = '\015';
                  wmo_header[2] = '\012';
                  wmo_header[3] = 3;
                  if (write(to_fd, wmo_header, 4) != 4) {
                    (void)fprintf(
                        stderr,
                        "Failed to write() WMO end to `%s' : %s (%s %d)",
                        dest_file_name, strerror(errno),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                        "refs/heads/master/src/tools/fax2gts.c",
                        263);
                  }
                }
              }
            } else {
              (void)fprintf(stderr, "Source FAX file `%s' is empty. (%s %d)\n",
                            fullname,
                            "/scratch/repos/new/home/jordi_armengol_estape/"
                            "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/"
                            "afd/refs/heads/master/src/tools/fax2gts.c",
                            272);
              ret = -1;
            }
          }
          if (close(from_fd) == -1) {
            (void)fprintf(stderr, "Failed to close() `%s' : %s (%s %d)\n",
                          fullname, strerror(errno),
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                          "refs/heads/master/src/tools/fax2gts.c",
                          280);
          }
        }
      }
      if (close(to_fd) == -1) {
        (void)fprintf(stderr, "Failed to close() `%s' : %s (%s %d)\n",
                      dest_file_name, strerror(errno),
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/"
                      "master/src/tools/fax2gts.c",
                      287);
      }
      if (ret == 0) {
        if (unlink(fullname) < 0) {
          (void)fprintf(
              stderr,
              "Failed to unlink() original TIFF file `%s' : %s (%s %d)\n",
              fullname, strerror(errno),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/src/tools/"
              "fax2gts.c",
              296);
        }
        if (rename(dest_file_name, fullname) < 0) {
          (void)fprintf(stderr,
                        "Failed to rename() file `%s' to `%s' : %s (%s %d)\n",
                        dest_file_name, fullname, strerror(errno),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/"
                        "refs/heads/master/src/tools/fax2gts.c",
                        303);
        }
      }
    }
  } else {
    (void)fprintf(stderr,
                  "Usage: %s <filename> <WMO Header>[ <FAX format>]\n\n",
                  argv[0]);
    (void)fprintf(stderr, "    The following Fax formats are possible:\n");
    (void)fprintf(stderr, "       1 - DFAX1062\n");
    (void)fprintf(stderr, "       2 - DFAX1064\n");
    (void)fprintf(stderr, "       3 - DFAX1074\n");
    (void)fprintf(stderr, "       4 - DFAX1084\n");
    (void)fprintf(stderr, "       5 - DFAX1099\n");
    (void)fprintf(stderr, "    Default is 2 when none is supplied.\n\n");
    (void)fprintf(stderr, "    WMO Header must be of the following format:\n");
    (void)fprintf(stderr, "       TTAAii_CCCC_YYGGgg\n");
  }
  return (ret);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x960,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1234 <main+0x34>
cmpl   $0x4,-0x8(%rbp)
jne    1b50 <main+0x950>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x428(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x12,%eax
je     1297 <main+0x97>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
lea    0xde0(%rip),%rdx
mov    $0x5c,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1300 <main+0x100>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
sub    $0x4,%eax
ja     12ca <main+0xca>
jmp    12c5 <main+0xc5>
jmp    12fb <main+0xfb>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xe0c(%rip),%rsi
lea    0xd7d(%rip),%rcx
mov    $0x6e,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
jmp    1307 <main+0x107>
movl   $0x2,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
lea    0xdf1(%rip),%rsi
call   10f0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2c61(%rip),%rax
mov    (%rax),%esi
mov    0x2cc0(%rip),%rax
or     (%rax),%esi
mov    0x2caf(%rip),%rax
or     (%rax),%esi
mov    0x2c56(%rip),%rax
mov    (%rax),%edx
mov    0x2c7d(%rip),%rax
or     (%rax),%edx
mov    0x2c54(%rip),%rax
or     (%rax),%edx
mov    0x2c43(%rip),%rax
or     (%rax),%edx
call   10c0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    13df <main+0x1df>
mov    0x2c41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x894(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x890(%rbp)
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x894(%rbp),%edi
mov    -0x890(%rbp),%rdx
mov    %rax,%rcx
lea    0xd57(%rip),%rsi
lea    0xca0(%rip),%r8
mov    $0x7d,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <unlink@plt>
jmp    1b4b <main+0x94b>
movb   $0x1,-0x860(%rbp)
movb   $0xd,-0x85f(%rbp)
movb   $0xd,-0x85e(%rbp)
movb   $0xa,-0x85d(%rbp)
lea    -0x85c(%rbp),%rdi
mov    -0x430(%rbp),%rsi
mov    $0x12,%edx
call   10a0 <memcpy@plt>
movb   $0x20,-0x851(%rbp)
movb   $0x20,-0x856(%rbp)
movb   $0xd,-0x84a(%rbp)
movb   $0xd,-0x849(%rbp)
movb   $0xa,-0x848(%rbp)
movb   $0x44,-0x847(%rbp)
movb   $0x46,-0x846(%rbp)
movb   $0x41,-0x845(%rbp)
movb   $0x58,-0x844(%rbp)
movb   $0x31,-0x843(%rbp)
movb   $0x30,-0x842(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x8a0(%rbp)
sub    $0x4,%eax
ja     14db <main+0x2db>
mov    -0x8a0(%rbp),%rax
lea    0xb7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x36,-0x841(%rbp)
movb   $0x32,-0x840(%rbp)
jmp    14e9 <main+0x2e9>
movb   $0x37,-0x841(%rbp)
movb   $0x34,-0x840(%rbp)
jmp    14e9 <main+0x2e9>
movb   $0x38,-0x841(%rbp)
movb   $0x34,-0x840(%rbp)
jmp    14e9 <main+0x2e9>
movb   $0x39,-0x841(%rbp)
movb   $0x39,-0x840(%rbp)
jmp    14e9 <main+0x2e9>
movb   $0x36,-0x841(%rbp)
movb   $0x34,-0x840(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x860(%rbp),%rsi
mov    $0x21,%edx
call   1050 <write@plt>
cmp    $0x21,%eax
je     1574 <main+0x374>
mov    0x2ab3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8ac(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x8a8(%rbp)
mov    0x2a8e(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x8ac(%rbp),%edi
mov    -0x8a8(%rbp),%rdx
mov    %rax,%rcx
lea    0xbed(%rip),%rsi
lea    0xb12(%rip),%r8
mov    $0xb4,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <unlink@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    19db <main+0x7db>
lea    -0x830(%rbp),%rdi
mov    -0x428(%rbp),%rdx
lea    0xb85(%rip),%rsi
call   10f0 <sprintf@plt>
lea    -0x830(%rbp),%rdi
mov    0x2a3c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <open@plt>
mov    %eax,-0x864(%rbp)
cmp    $0x0,%eax
jge    1616 <main+0x416>
mov    0x2a05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8bc(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x8b8(%rbp)
mov    0x29e0(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x8bc(%rbp),%edi
mov    -0x8b8(%rbp),%rdx
mov    %rax,%rcx
lea    0xb1b(%rip),%rsi
lea    0xa64(%rip),%r8
mov    $0xc1,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    19d6 <main+0x7d6>
mov    -0x864(%rbp),%edi
lea    -0x878(%rbp),%rsi
call   1120 <fstat@plt>
cmp    $0xffffffff,%eax
jne    1693 <main+0x493>
mov    0x2988(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8cc(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x8c8(%rbp)
mov    0x2963(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x8cc(%rbp),%edi
mov    -0x8c8(%rbp),%rdx
mov    %rax,%rcx
lea    0xaf5(%rip),%rsi
lea    0x9e7(%rip),%r8
mov    $0xcb,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1967 <main+0x767>
cmpq   $0x0,-0x878(%rbp)
jle    1930 <main+0x730>
mov    -0x870(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x880(%rbp)
cmp    $0x0,%rax
jne    171c <main+0x51c>
mov    0x28fc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8d4(%rbp)
mov    -0x870(%rbp),%eax
mov    %eax,-0x8d0(%rbp)
mov    0x28d9(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x8d4(%rbp),%edi
mov    -0x8d0(%rbp),%edx
mov    %rax,%rcx
lea    0xa91(%rip),%rsi
lea    0x95e(%rip),%r8
mov    $0xd9,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    192b <main+0x72b>
jmp    1721 <main+0x521>
mov    -0x864(%rbp),%edi
mov    -0x880(%rbp),%rsi
mov    -0x870(%rbp),%edx
call   1080 <read@plt>
mov    %eax,-0x884(%rbp)
cmp    $0xffffffff,%eax
jne    17bd <main+0x5bd>
mov    0x2871(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8e8(%rbp)
mov    -0x870(%rbp),%eax
mov    %eax,-0x8e4(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x8e0(%rbp)
mov    0x2840(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x8e8(%rbp),%edi
mov    -0x8e4(%rbp),%edx
mov    -0x8e0(%rbp),%rcx
mov    %rax,%r8
lea    0xa1b(%rip),%rsi
lea    0x8be(%rip),%r9
movl   $0xe9,(%rsp)
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    187c <main+0x67c>
cmpl   $0x0,-0x884(%rbp)
jle    1865 <main+0x665>
mov    -0x1c(%rbp),%edi
mov    -0x880(%rbp),%rsi
mov    -0x884(%rbp),%edx
call   1050 <write@plt>
cmp    -0x884(%rbp),%eax
je     1860 <main+0x660>
mov    0x27ce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8f8(%rbp)
mov    -0x884(%rbp),%eax
mov    %eax,-0x8f4(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x8f0(%rbp)
mov    0x279d(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x8f8(%rbp),%edi
mov    -0x8f4(%rbp),%edx
mov    -0x8f0(%rbp),%rcx
mov    %rax,%r8
lea    0x9aa(%rip),%rsi
lea    0x81b(%rip),%r9
movl   $0xf4,(%rsp)
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    187c <main+0x67c>
jmp    1865 <main+0x665>
jmp    186a <main+0x66a>
mov    -0x884(%rbp),%eax
cmp    -0x870(%rbp),%eax
je     1721 <main+0x521>
mov    -0x880(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0xffffffff,-0x14(%rbp)
je     1926 <main+0x726>
movb   $0xd,-0x860(%rbp)
movb   $0xd,-0x85f(%rbp)
movb   $0xa,-0x85e(%rbp)
movb   $0x3,-0x85d(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x860(%rbp),%rsi
mov    $0x4,%edx
call   1050 <write@plt>
cmp    $0x4,%eax
je     1921 <main+0x721>
mov    0x26ee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x904(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x900(%rbp)
mov    0x26c9(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x904(%rbp),%edi
mov    -0x900(%rbp),%rdx
mov    %rax,%rcx
lea    0x90d(%rip),%rsi
lea    0x74d(%rip),%r8
mov    $0x107,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1926 <main+0x726>
jmp    192b <main+0x72b>
jmp    1962 <main+0x762>
mov    0x2689(%rip),%rax
mov    (%rax),%edi
lea    -0x830(%rbp),%rdx
lea    0x902(%rip),%rsi
lea    0x713(%rip),%rcx
mov    $0x110,%r8d
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1967 <main+0x767>
mov    -0x864(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    19d1 <main+0x7d1>
mov    0x263e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x914(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x910(%rbp)
mov    0x2619(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x914(%rbp),%edi
mov    -0x910(%rbp),%rdx
mov    %rax,%rcx
lea    0x8b4(%rip),%rsi
lea    0x69d(%rip),%r8
mov    $0x118,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    19d6 <main+0x7d6>
jmp    19db <main+0x7db>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    1a42 <main+0x842>
mov    0x25cd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x924(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x920(%rbp)
mov    0x25a8(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x924(%rbp),%edi
mov    -0x920(%rbp),%rdx
mov    %rax,%rcx
lea    0x843(%rip),%rsi
lea    0x62c(%rip),%r8
mov    $0x11f,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1b46 <main+0x946>
lea    -0x830(%rbp),%rdi
call   1040 <unlink@plt>
cmp    $0x0,%rax
jge    1ab8 <main+0x8b8>
mov    0x2557(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x934(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x930(%rbp)
mov    0x2532(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x934(%rbp),%edi
mov    -0x930(%rbp),%rdx
mov    %rax,%rcx
lea    0x7f2(%rip),%rsi
lea    0x5b6(%rip),%r8
mov    $0x128,%r9d
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x420(%rbp),%rdi
lea    -0x830(%rbp),%rsi
call   10d0 <rename@plt>
cmp    $0x0,%rax
jge    1b41 <main+0x941>
mov    0x24e4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x948(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x940(%rbp)
mov    0x24b1(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x94c(%rbp),%edi
mov    -0x948(%rbp),%rdx
mov    -0x940(%rbp),%rcx
mov    %rax,%r8
lea    0x7a3(%rip),%rsi
lea    0x52e(%rip),%r9
movl   $0x12f,(%rsp)
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1b46 <main+0x946>
jmp    1b4b <main+0x94b>
jmp    1c3d <main+0xa3d>
mov    0x2469(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x79b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x244b(%rip),%rax
mov    (%rax),%edi
lea    0x7b7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2434(%rip),%rax
mov    (%rax),%edi
lea    0x7cd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x241d(%rip),%rax
mov    (%rax),%edi
lea    0x7cb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2406(%rip),%rax
mov    (%rax),%edi
lea    0x7c9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x23ef(%rip),%rax
mov    (%rax),%edi
lea    0x7c7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x23d8(%rip),%rax
mov    (%rax),%edi
lea    0x7c5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x23c1(%rip),%rax
mov    (%rax),%edi
lea    0x7c3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x23aa(%rip),%rax
mov    (%rax),%edi
lea    0x7d6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2393(%rip),%rax
mov    (%rax),%edi
lea    0x7f0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x960,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x858,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    -0x3(%rbx),%eax
cmp    $0x1,%eax
ja     13d8 <main+0x1c8>
mov    0x8(%rbp),%r14
mov    0x10(%rbp),%r12
mov    %r12,%rdi
call   1070 <strlen@plt>
cmp    $0x12,%eax
jne    18c1 <main+0x6b1>
mov    $0x2,%r13d
cmp    $0x4,%ebx
jne    126e <main+0x5e>
mov    0x18(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,%r13d
add    $0xffffffff,%eax
cmp    $0x5,%eax
jae    18ee <main+0x6de>
lea    0xe84(%rip),%rsi
lea    0x450(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1100 <sprintf@plt>
mov    0x2d01(%rip),%rax
mov    0x2d62(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d4f(%rip),%rax
or     (%rax),%esi
mov    0x2cf6(%rip),%rax
mov    0x2d1f(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cf4(%rip),%rax
or     (%rax),%edx
mov    0x2ce3(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
call   10d0 <open@plt>
test   %eax,%eax
js     1502 <main+0x2f2>
mov    %eax,%r15d
movl   $0xa0d0d01,0x10(%rsp)
0a
lea    0x14(%rsp),%rdi
mov    %r12,%rsi
mov    $0x12,%edx
call   10b0 <memcpy@plt>
movb   $0x20,0x1f(%rsp)
movb   $0x20,0x1a(%rsp)
movabs $0x31584146440a0d0d,%rax
41 58 31
mov    %rax,0x26(%rsp)
movb   $0x30,0x2e(%rsp)
mov    %r13d,%eax
add    $0xffffffff,%eax
lea    -0x8(,%r13,8),%ecx
ff
movabs $0x3934343432,%rdx
lea    0x4030204(%rdx),%rsi
shr    %cl,%rsi
shr    %cl,%rdx
cmp    $0x5,%eax
mov    $0x36,%eax
cmovb  %esi,%eax
mov    $0x34,%ecx
cmovb  %edx,%ecx
mov    %al,0x2f(%rsp)
mov    %cl,0x30(%rsp)
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x21,%edx
call   1060 <write@plt>
cmp    $0x21,%eax
jne    1554 <main+0x344>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    0x2c54(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   10d0 <open@plt>
test   %eax,%eax
js     15a9 <main+0x399>
mov    %eax,%r14d
lea    0x40(%rsp),%rsi
mov    %eax,%edi
call   1130 <fstat@plt>
cmp    $0xffffffff,%eax
je     15f0 <main+0x3e0>
cmpq   $0x0,0x40(%rsp)
jle    1631 <main+0x421>
mov    0x48(%rsp),%ebx
mov    %ebx,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     165f <main+0x44f>
mov    %rax,%r12
jmp    1498 <main+0x288>
mov    0x2be1(%rip),%rbx
mov    (%rbx),%edi
mov    0x0(%rbp),%rdx
lea    0xf02(%rip),%rsi
xor    %r12d,%r12d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf22(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf3f(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf44(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf49(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf4e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf53(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf58(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf72(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf93(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1837 <main+0x627>
nopl   0x0(%rax,%rax,1)
cmp    %ebx,%ebp
jne    184c <main+0x63c>
mov    %r14d,%edi
mov    %r12,%rsi
mov    %ebx,%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     169a <main+0x48a>
mov    %eax,%ebp
test   %eax,%eax
jle    1490 <main+0x280>
mov    %r15d,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1060 <write@plt>
cmp    %ebp,%eax
je     1490 <main+0x280>
mov    0x2af4(%rip),%rax
mov    (%rax),%ebx
mov    0x2ae3(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
movl   $0xf4,(%rsp)
lea    0xceb(%rip),%rsi
lea    0xb5c(%rip),%r9
lea    0x450(%rsp),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
jmp    16cf <main+0x4bf>
mov    0x2ab7(%rip),%rax
mov    (%rax),%ebx
mov    0x2aa6(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xbdd(%rip),%rsi
lea    0xb26(%rip),%r8
xor    %r12d,%r12d
lea    0x450(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
mov    $0x7d,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <unlink@plt>
jmp    1837 <main+0x627>
mov    0x2a65(%rip),%rax
mov    (%rax),%ebx
mov    0x2a54(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xbaf(%rip),%rsi
lea    0xad4(%rip),%r8
lea    0x450(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
mov    $0xb4,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <unlink@plt>
mov    $0xffffffff,%r12d
jmp    1730 <main+0x520>
mov    0x2a10(%rip),%rax
mov    (%rax),%ebx
mov    0x29ff(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xb36(%rip),%rsi
lea    0xa7f(%rip),%r8
lea    0x50(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
mov    $0xc1,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%r12d
jmp    1730 <main+0x520>
mov    0x29c9(%rip),%rax
mov    (%rax),%ebx
mov    0x29b8(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xb46(%rip),%rsi
lea    0xa38(%rip),%r8
lea    0x50(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
mov    $0xcb,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    16e1 <main+0x4d1>
mov    0x2988(%rip),%rax
mov    (%rax),%edi
lea    0xbf4(%rip),%rsi
lea    0xa05(%rip),%rcx
lea    0x50(%rsp),%rdx
mov    $0x110,%r8d
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    16e1 <main+0x4d1>
mov    0x295a(%rip),%rax
mov    (%rax),%ebp
mov    0x2949(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xafc(%rip),%rsi
lea    0x9c9(%rip),%r8
mov    %ebp,%edi
mov    %ebx,%edx
mov    %rax,%rcx
mov    $0xd9,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    16e1 <main+0x4d1>
mov    0x291f(%rip),%rax
mov    (%rax),%ebp
mov    0x290e(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
movl   $0xe9,(%rsp)
lea    0xae4(%rip),%rsi
lea    0x987(%rip),%r9
lea    0x50(%rsp),%rcx
mov    %ebp,%edi
mov    %ebx,%edx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    $0xffffffff,%r12d
mov    %r14d,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
jne    1730 <main+0x520>
mov    0x28c5(%rip),%rax
mov    (%rax),%ebx
mov    0x28b4(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xb4b(%rip),%rsi
lea    0x934(%rip),%r8
lea    0x50(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
mov    $0x118,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r15d,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
je     1748 <main+0x538>
test   %r12d,%r12d
jne    1837 <main+0x627>
jmp    1790 <main+0x580>
mov    0x2871(%rip),%rax
mov    (%rax),%ebx
mov    0x2860(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xaf7(%rip),%rsi
lea    0x8e0(%rip),%r8
lea    0x450(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
mov    $0x11f,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %r12d,%r12d
jne    1837 <main+0x627>
lea    0x50(%rsp),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
jns    17db <main+0x5cb>
mov    0x281a(%rip),%rax
mov    (%rax),%ebx
mov    0x2809(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xac5(%rip),%rsi
lea    0x889(%rip),%r8
lea    0x50(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
mov    $0x128,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0x450(%rsp),%rdi
lea    0x50(%rsp),%rsi
call   10e0 <rename@plt>
test   %rax,%rax
jns    1837 <main+0x627>
mov    0x27c7(%rip),%rax
mov    (%rax),%ebx
mov    0x27b6(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
movl   $0x12f,(%rsp)
lea    0xaa4(%rip),%rsi
lea    0x82f(%rip),%r9
lea    0x450(%rsp),%rdx
lea    0x50(%rsp),%rcx
mov    %ebx,%edi
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12d,%eax
add    $0x858,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
call   1030 <free@plt>
movl   $0x30a0d0d,0x10(%rsp)
03
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x4,%edx
call   1060 <write@plt>
xor    %r12d,%r12d
cmp    $0x4,%eax
je     16e7 <main+0x4d7>
mov    0x273f(%rip),%rax
mov    (%rax),%ebx
mov    0x272e(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0x96e(%rip),%rsi
lea    0x7ae(%rip),%r8
xor    %r12d,%r12d
lea    0x450(%rsp),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
mov    $0x107,%r9d
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    16e7 <main+0x4d7>
mov    0x26f8(%rip),%rax
mov    (%rax),%edi
lea    0x72f(%rip),%rsi
lea    0x775(%rip),%rdx
mov    $0x5c,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    0x26cb(%rip),%rax
mov    (%rax),%edi
lea    0x7d7(%rip),%rsi
lea    0x748(%rip),%rcx
mov    %r13d,%edx
mov    $0x6e,%r8d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
@stderr = global i32 0
@.str = [77 x i8] c"WMO header must be at least 18 bytes long and must be a WMO header. (%s %d)\0A\00"
@.str.1 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/src/tools/fax2gts.c\00"
@.str.2 = [36 x i8] c"Wrong FAX format number %d (%s %d)\0A\00"
@.str.3 = [4 x i8] c".%s\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.4 = [36 x i8] c"Failed to open() `%s' : %s (%s %d)\0A\00"
@errno = global i32 0
@.str.5 = [51 x i8] c"Failed to write() WMO header to `%s' : %s (%s %d)\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@O_RDONLY = global i32 0
@.str.7 = [37 x i8] c"Failed to fstat() `%s' : %s (%s %d)\0A\00"
@.str.8 = [42 x i8] c"Failed to malloc() %d bytes : %s (%s %d)\0A\00"
@.str.9 = [50 x i8] c"Failed to read() %d bytes from `%s' : %s (%s %d)\0A\00"
@.str.10 = [49 x i8] c"Failed to write() %d bytes to `%s' : %s (%s %d)\0A\00"
@.str.11 = [47 x i8] c"Failed to write() WMO end to `%s' : %s (%s %d)\00"
@.str.12 = [40 x i8] c"Source FAX file `%s' is empty. (%s %d)\0A\00"
@.str.13 = [37 x i8] c"Failed to close() `%s' : %s (%s %d)\0A\00"
@.str.14 = [57 x i8] c"Failed to unlink() original TIFF file `%s' : %s (%s %d)\0A\00"
@.str.15 = [51 x i8] c"Failed to rename() file `%s' to `%s' : %s (%s %d)\0A\00"
@.str.16 = [51 x i8] c"Usage: %s <filename> <WMO Header>[ <FAX format>]\0A\0A\00"
@.str.17 = [45 x i8] c" The following Fax formats are possible:\0A\00"
@.str.18 = [21 x i8] c" 1 - DFAX1062\0A\00"
@.str.19 = [21 x i8] c" 2 - DFAX1064\0A\00"
@.str.20 = [21 x i8] c" 3 - DFAX1074\0A\00"
@.str.21 = [21 x i8] c" 4 - DFAX1084\0A\00"
@.str.22 = [21 x i8] c" 5 - DFAX1099\0A\00"
@.str.23 = [42 x i8] c" Default is 2 when none is supplied.\0A\0A\00"
@.str.24 = [49 x i8] c" WMO Header must be of the following format:\0A\00"
@.str.25 = [27 x i8] c" TTAAii_CCCC_YYGGgg\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [1024 x i8]
%13 = alloca [33 x i8]
%14 = alloca i32
%15 = alloca %struct.stat
%16 = alloca i8*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 3
br i1 %19, label %23, label %20
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %287
23: ; preds = %20, %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %10
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %11
%30 = load i8*, i8** %11
%31 = call i32 @strlen(i8* %30)
store i32 %31, i32* %8
%32 = icmp ne i32 %31, 18
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 92)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %23
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 4
br i1 %39, label %40, label %53
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i32 @atoi(i8* %43)
store i32 %44, i32* %7
%45 = load i32, i32* %7
switch i32 %45, label %47 [
i32 1, label %46
i32 2, label %46
i32 3, label %46
i32 4, label %46
i32 5, label %46
]
46: ; preds = %40, %40, %40, %40, %40
br label %52
47: ; preds = %40
%48 = load i32, i32* @stderr
%49 = load i32, i32* %7
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %49, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 110)
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %46
br label %54
53: ; preds = %37
store i32 2, i32* %7
br label %54
54: ; preds = %53, %52
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%56 = load i8*, i8** %10
%57 = call i32 @sprintf(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%59 = load i32, i32* @O_WRONLY
%60 = load i32, i32* @O_CREAT
%61 = or i32 %59, %60
%62 = load i32, i32* @O_TRUNC
%63 = or i32 %61, %62
%64 = load i32, i32* @S_IRUSR
%65 = load i32, i32* @S_IWUSR
%66 = or i32 %64, %65
%67 = load i32, i32* @S_IRGRP
%68 = or i32 %66, %67
%69 = load i32, i32* @S_IROTH
%70 = or i32 %68, %69
%71 = call i32 @open(i8* %58, i32 %63, i32 %70)
store i32 %71, i32* %8
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %81
73: ; preds = %54
%74 = load i32, i32* @stderr
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %75, i8* %77, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 125)
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%80 = call i64 @unlink(i8* %79)
br label %286
81: ; preds = %54
%82 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 0
store i8 1, i8* %82
%83 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 1
store i8 13, i8* %83
%84 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 2
store i8 13, i8* %84
%85 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 3
store i8 10, i8* %85
%86 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 4
%87 = load i8*, i8** %11
%88 = call i32 @memcpy(i8* %86, i8* %87, i32 18)
%89 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 15
store i8 32, i8* %89
%90 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 10
store i8 32, i8* %90
%91 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 22
store i8 13, i8* %91
%92 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 23
store i8 13, i8* %92
%93 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 24
store i8 10, i8* %93
%94 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 25
store i8 68, i8* %94
%95 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 26
store i8 70, i8* %95
%96 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 27
store i8 65, i8* %96
%97 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 28
store i8 88, i8* %97
%98 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 29
store i8 49, i8* %98
%99 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 30
store i8 48, i8* %99
%100 = load i32, i32* %7
switch i32 %100, label %113 [
i32 1, label %101
i32 3, label %104
i32 4, label %107
i32 5, label %110
]
101: ; preds = %81
%102 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 31
store i8 54, i8* %102
%103 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 32
store i8 50, i8* %103
br label %116
104: ; preds = %81
%105 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 31
store i8 55, i8* %105
%106 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 32
store i8 52, i8* %106
br label %116
107: ; preds = %81
%108 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 31
store i8 56, i8* %108
%109 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 32
store i8 52, i8* %109
br label %116
110: ; preds = %81
%111 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 31
store i8 57, i8* %111
%112 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 32
store i8 57, i8* %112
br label %116
113: ; preds = %81
%114 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 31
store i8 54, i8* %114
%115 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 32
store i8 52, i8* %115
br label %116
116: ; preds = %113, %110, %107, %104, %101
%117 = load i32, i32* %8
%118 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 0
%119 = call i32 @write(i32 %117, i8* %118, i32 33)
%120 = icmp ne i32 %119, 33
br i1 %120, label %121, label %129
121: ; preds = %116
%122 = load i32, i32* @stderr
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%124 = load i32, i32* @errno
%125 = call i8* @strerror(i32 %124)
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* %123, i8* %125, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 180)
%127 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%128 = call i64 @unlink(i8* %127)
store i32 -1, i32* %6
br label %249
129: ; preds = %116
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%131 = load i8*, i8** %10
%132 = call i32 @sprintf(i8* %130, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %131)
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%134 = load i32, i32* @O_RDONLY
%135 = call i32 @open(i8* %133, i32 %134, i32 0)
store i32 %135, i32* %14
%136 = icmp slt i32 %135, 0
br i1 %136, label %137, label %143
137: ; preds = %129
%138 = load i32, i32* @stderr
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%140 = load i32, i32* @errno
%141 = call i8* @strerror(i32 %140)
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %139, i8* %141, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 193)
store i32 -1, i32* %6
br label %248
143: ; preds = %129
%144 = load i32, i32* %14
%145 = call i32 @fstat(i32 %144, %struct.stat* %15)
%146 = icmp eq i32 %145, -1
br i1 %146, label %147, label %153
147: ; preds = %143
%148 = load i32, i32* @stderr
%149 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%150 = load i32, i32* @errno
%151 = call i8* @strerror(i32 %150)
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %149, i8* %151, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 203)
store i32 -1, i32* %6
br label %237
153: ; preds = %143
%154 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%155 = load i64, i64* %154
%156 = icmp sgt i64 %155, 0
br i1 %156, label %157, label %232
157: ; preds = %153
%158 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%159 = load i32, i32* %158
%160 = call i8* @malloc(i32 %159)
store i8* %160, i8** %16
%161 = icmp eq i8* %160, null
br i1 %161, label %162, label %169
162: ; preds = %157
%163 = load i32, i32* @stderr
%164 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%165 = load i32, i32* %164
%166 = load i32, i32* @errno
%167 = call i8* @strerror(i32 %166)
%168 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %165, i8* %167, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 217)
store i32 -1, i32* %6
br label %231
169: ; preds = %157
br label %170
170: ; preds = %204, %169
%171 = load i32, i32* %14
%172 = load i8*, i8** %16
%173 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%174 = load i32, i32* %173
%175 = call i32 @read(i32 %171, i8* %172, i32 %174)
store i32 %175, i32* %17
%176 = icmp eq i32 %175, -1
br i1 %176, label %177, label %185
177: ; preds = %170
%178 = load i32, i32* @stderr
%179 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%180 = load i32, i32* %179
%181 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%182 = load i32, i32* @errno
%183 = call i8* @strerror(i32 %182)
%184 = call i32 (i32, i8*, ...) @fprintf(i32 %178, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i32 %180, i8* %181, i8* %183, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 233)
store i32 -1, i32* %6
br label %209
185: ; preds = %170
%186 = load i32, i32* %17
%187 = icmp sgt i32 %186, 0
br i1 %187, label %188, label %203
188: ; preds = %185
%189 = load i32, i32* %8
%190 = load i8*, i8** %16
%191 = load i32, i32* %17
%192 = call i32 @write(i32 %189, i8* %190, i32 %191)
%193 = load i32, i32* %17
%194 = icmp ne i32 %192, %193
br i1 %194, label %195, label %202
195: ; preds = %188
%196 = load i32, i32* @stderr
%197 = load i32, i32* %17
%198 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%199 = load i32, i32* @errno
%200 = call i8* @strerror(i32 %199)
%201 = call i32 (i32, i8*, ...) @fprintf(i32 %196, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i32 %197, i8* %198, i8* %200, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 244)
store i32 -1, i32* %6
br label %209
202: ; preds = %188
br label %203
203: ; preds = %202, %185
br label %204
204: ; preds = %203
%205 = load i32, i32* %17
%206 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%207 = load i32, i32* %206
%208 = icmp eq i32 %205, %207
br i1 %208, label %170, label %209
209: ; preds = %204, %195, %177
%210 = load i8*, i8** %16
%211 = call i32 @free(i8* %210)
%212 = load i32, i32* %6
%213 = icmp ne i32 %212, -1
br i1 %213, label %214, label %230
214: ; preds = %209
%215 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 0
store i8 13, i8* %215
%216 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 1
store i8 13, i8* %216
%217 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 2
store i8 10, i8* %217
%218 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 3
store i8 3, i8* %218
%219 = load i32, i32* %8
%220 = getelementptr inbounds [33 x i8], [33 x i8]* %13, i64 0, i64 0
%221 = call i32 @write(i32 %219, i8* %220, i32 4)
%222 = icmp ne i32 %221, 4
br i1 %222, label %223, label %229
223: ; preds = %214
%224 = load i32, i32* @stderr
%225 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%226 = load i32, i32* @errno
%227 = call i8* @strerror(i32 %226)
%228 = call i32 (i32, i8*, ...) @fprintf(i32 %224, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i8* %225, i8* %227, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 263)
br label %229
229: ; preds = %223, %214
br label %230
230: ; preds = %229, %209
br label %231
231: ; preds = %230, %162
br label %236
232: ; preds = %153
%233 = load i32, i32* @stderr
%234 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%235 = call i32 (i32, i8*, ...) @fprintf(i32 %233, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i8* %234, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 272)
store i32 -1, i32* %6
br label %236
236: ; preds = %232, %231
br label %237
237: ; preds = %236, %147
%238 = load i32, i32* %14
%239 = call i32 @close(i32 %238)
%240 = icmp eq i32 %239, -1
br i1 %240, label %241, label %247
241: ; preds = %237
%242 = load i32, i32* @stderr
%243 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%244 = load i32, i32* @errno
%245 = call i8* @strerror(i32 %244)
%246 = call i32 (i32, i8*, ...) @fprintf(i32 %242, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i8* %243, i8* %245, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 280)
br label %247
247: ; preds = %241, %237
br label %248
248: ; preds = %247, %137
br label %249
249: ; preds = %248, %121
%250 = load i32, i32* %8
%251 = call i32 @close(i32 %250)
%252 = icmp eq i32 %251, -1
br i1 %252, label %253, label %259
253: ; preds = %249
%254 = load i32, i32* @stderr
%255 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%256 = load i32, i32* @errno
%257 = call i8* @strerror(i32 %256)
%258 = call i32 (i32, i8*, ...) @fprintf(i32 %254, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i8* %255, i8* %257, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 287)
br label %259
259: ; preds = %253, %249
%260 = load i32, i32* %6
%261 = icmp eq i32 %260, 0
br i1 %261, label %262, label %285
262: ; preds = %259
%263 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%264 = call i64 @unlink(i8* %263)
%265 = icmp slt i64 %264, 0
br i1 %265, label %266, label %272
266: ; preds = %262
%267 = load i32, i32* @stderr
%268 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%269 = load i32, i32* @errno
%270 = call i8* @strerror(i32 %269)
%271 = call i32 (i32, i8*, ...) @fprintf(i32 %267, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i8* %268, i8* %270, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 296)
br label %272
272: ; preds = %266, %262
%273 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%274 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%275 = call i64 @rename(i8* %273, i8* %274)
%276 = icmp slt i64 %275, 0
br i1 %276, label %277, label %284
277: ; preds = %272
%278 = load i32, i32* @stderr
%279 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%280 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%281 = load i32, i32* @errno
%282 = call i8* @strerror(i32 %281)
%283 = call i32 (i32, i8*, ...) @fprintf(i32 %278, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.15, i64 0, i64 0), i8* %279, i8* %280, i8* %282, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 303)
br label %284
284: ; preds = %277, %272
br label %285
285: ; preds = %284, %259
br label %286
286: ; preds = %285, %73
br label %311
287: ; preds = %20
%288 = load i32, i32* @stderr
%289 = load i8**, i8*** %5
%290 = getelementptr inbounds i8*, i8** %289, i64 0
%291 = load i8*, i8** %290
%292 = call i32 (i32, i8*, ...) @fprintf(i32 %288, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.16, i64 0, i64 0), i8* %291)
%293 = load i32, i32* @stderr
%294 = call i32 (i32, i8*, ...) @fprintf(i32 %293, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.17, i64 0, i64 0))
%295 = load i32, i32* @stderr
%296 = call i32 (i32, i8*, ...) @fprintf(i32 %295, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.18, i64 0, i64 0))
%297 = load i32, i32* @stderr
%298 = call i32 (i32, i8*, ...) @fprintf(i32 %297, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%299 = load i32, i32* @stderr
%300 = call i32 (i32, i8*, ...) @fprintf(i32 %299, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%301 = load i32, i32* @stderr
%302 = call i32 (i32, i8*, ...) @fprintf(i32 %301, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0))
%303 = load i32, i32* @stderr
%304 = call i32 (i32, i8*, ...) @fprintf(i32 %303, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
%305 = load i32, i32* @stderr
%306 = call i32 (i32, i8*, ...) @fprintf(i32 %305, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.23, i64 0, i64 0))
%307 = load i32, i32* @stderr
%308 = call i32 (i32, i8*, ...) @fprintf(i32 %307, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.24, i64 0, i64 0))
%309 = load i32, i32* @stderr
%310 = call i32 (i32, i8*, ...) @fprintf(i32 %309, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.25, i64 0, i64 0))
br label %311
311: ; preds = %287, %286
%312 = load i32, i32* %6
ret i32 %312
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
@stderr = global i32 0
@.str = [77 x i8] c"WMO header must be at least 18 bytes long and must be a WMO header. (%s %d)\0A\00"
@.str.1 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/src/tools/fax2gts.c\00"
@.str.2 = [36 x i8] c"Wrong FAX format number %d (%s %d)\0A\00"
@.str.3 = [4 x i8] c".%s\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.4 = [36 x i8] c"Failed to open() `%s' : %s (%s %d)\0A\00"
@errno = global i32 0
@.str.5 = [51 x i8] c"Failed to write() WMO header to `%s' : %s (%s %d)\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [37 x i8] c"Failed to fstat() `%s' : %s (%s %d)\0A\00"
@.str.8 = [42 x i8] c"Failed to malloc() %d bytes : %s (%s %d)\0A\00"
@.str.9 = [50 x i8] c"Failed to read() %d bytes from `%s' : %s (%s %d)\0A\00"
@.str.10 = [49 x i8] c"Failed to write() %d bytes to `%s' : %s (%s %d)\0A\00"
@.str.11 = [47 x i8] c"Failed to write() WMO end to `%s' : %s (%s %d)\00"
@.str.12 = [40 x i8] c"Source FAX file `%s' is empty. (%s %d)\0A\00"
@.str.13 = [37 x i8] c"Failed to close() `%s' : %s (%s %d)\0A\00"
@.str.14 = [57 x i8] c"Failed to unlink() original TIFF file `%s' : %s (%s %d)\0A\00"
@.str.15 = [51 x i8] c"Failed to rename() file `%s' to `%s' : %s (%s %d)\0A\00"
@.str.16 = [51 x i8] c"Usage: %s <filename> <WMO Header>[ <FAX format>]\0A\0A\00"
@.str.17 = [45 x i8] c" The following Fax formats are possible:\0A\00"
@.str.18 = [21 x i8] c" 1 - DFAX1062\0A\00"
@.str.19 = [21 x i8] c" 2 - DFAX1064\0A\00"
@.str.20 = [21 x i8] c" 3 - DFAX1074\0A\00"
@.str.21 = [21 x i8] c" 4 - DFAX1084\0A\00"
@.str.22 = [21 x i8] c" 5 - DFAX1099\0A\00"
@.str.23 = [42 x i8] c" Default is 2 when none is supplied.\0A\0A\00"
@.str.24 = [49 x i8] c" WMO Header must be of the following format:\0A\00"
@.str.25 = [27 x i8] c" TTAAii_CCCC_YYGGgg\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [33 x i8]
%6 = alloca %struct.stat
%7 = icmp eq i32 %0, 4
%8 = add i32 %0, -3
%9 = icmp ult i32 %8, 2
br i1 %9, label %10, label %204
10: ; preds = %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %15)
%17 = icmp eq i32 %16, 18
br i1 %17, label %22, label %18
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 92)
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %10
br i1 %7, label %23, label %33
23: ; preds = %22
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
%27 = add i32 %26, -1
%28 = icmp ult i32 %27, 5
br i1 %28, label %33, label %29
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %26, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 110)
%32 = tail call i32 @exit(i32 -1)
unreachable
33: ; preds = %22, %23
%34 = phi i32 [ %26, %23 ], [ 2, %22 ]
%35 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%36 = load i32, i32* @O_WRONLY
%37 = load i32, i32* @O_CREAT
%38 = or i32 %37, %36
%39 = load i32, i32* @O_TRUNC
%40 = or i32 %38, %39
%41 = load i32, i32* @S_IRUSR
%42 = load i32, i32* @S_IWUSR
%43 = or i32 %42, %41
%44 = load i32, i32* @S_IRGRP
%45 = or i32 %43, %44
%46 = load i32, i32* @S_IROTH
%47 = or i32 %45, %46
%48 = call i32 @open(i8* %11, i32 %40, i32 %47)
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %56
50: ; preds = %33
%51 = load i32, i32* @stderr
%52 = load i32, i32* @errno
%53 = tail call i8* @strerror(i32 %52)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %11, i8* %53, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 125)
%55 = call i64 @unlink(i8* %11)
br label %202
56: ; preds = %33
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%58 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
store i8 1, i8* %58
%59 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 1
store i8 13, i8* %59
%60 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 2
store i8 13, i8* %60
%61 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 3
store i8 10, i8* %61
%62 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 4
%63 = call i32 @memcpy(i8* %62, i8* %15, i32 18)
%64 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 15
store i8 32, i8* %64
%65 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 10
store i8 32, i8* %65
%66 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 22
store i8 13, i8* %66
%67 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 23
store i8 13, i8* %67
%68 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 24
store i8 10, i8* %68
%69 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 25
store i8 68, i8* %69
%70 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 26
store i8 70, i8* %70
%71 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 27
store i8 65, i8* %71
%72 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 28
store i8 88, i8* %72
%73 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 29
store i8 49, i8* %73
%74 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 30
store i8 48, i8* %74
%75 = add i32 %34, -1
%76 = icmp ult i32 %75, 5
%77 = zext i32 %75 to i40
%78 = shl nuw nsw i40 %77, 3
%79 = lshr i40 245756278326, %78
%80 = trunc i40 %79 to i8
%81 = zext i32 %75 to i40
%82 = shl nuw nsw i40 %81, 3
%83 = lshr i40 245688972338, %82
%84 = trunc i40 %83 to i8
%85 = select i1 %76, i8 %80, i8 54
%86 = select i1 %76, i8 %84, i8 52
%87 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 31
store i8 %85, i8* %87
%88 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 32
store i8 %86, i8* %88
%89 = call i32 @write(i32 %48, i8* %58, i32 33)
%90 = icmp eq i32 %89, 33
br i1 %90, label %97, label %91
91: ; preds = %56
%92 = load i32, i32* @stderr
%93 = load i32, i32* @errno
%94 = call i8* @strerror(i32 %93)
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* %11, i8* %94, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 180)
%96 = call i64 @unlink(i8* %11)
br label %174
97: ; preds = %56
%98 = call i8* @strcpy(i8* %57, i8* dereferenceable(1) %13)
%99 = load i32, i32* @O_RDONLY
%100 = call i32 @open(i8* %57, i32 %99, i32 0)
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %107
102: ; preds = %97
%103 = load i32, i32* @stderr
%104 = load i32, i32* @errno
%105 = call i8* @strerror(i32 %104)
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %57, i8* %105, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 193)
br label %174
107: ; preds = %97
%108 = bitcast %struct.stat* %6 to i8*
%109 = call i32 @fstat(i32 %100, %struct.stat* %6)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %116
111: ; preds = %107
%112 = load i32, i32* @stderr
%113 = load i32, i32* @errno
%114 = call i8* @strerror(i32 %113)
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %57, i8* %114, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 203)
br label %164
116: ; preds = %107
%117 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%118 = load i64, i64* %117
%119 = icmp sgt i64 %118, 0
br i1 %119, label %120, label %161
120: ; preds = %116
%121 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 1
%122 = load i32, i32* %121
%123 = call i8* @malloc(i32 %122)
%124 = icmp eq i8* %123, null
br i1 %124, label %125, label %130
125: ; preds = %120
%126 = load i32, i32* @stderr
%127 = load i32, i32* @errno
%128 = call i8* @strerror(i32 %127)
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %122, i8* %128, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 217)
br label %164
130: ; preds = %120, %148
%131 = call i32 @read(i32 %100, i8* %123, i32 %122)
%132 = icmp eq i32 %131, -1
br i1 %132, label %133, label %138
133: ; preds = %130
%134 = load i32, i32* @stderr
%135 = load i32, i32* @errno
%136 = call i8* @strerror(i32 %135)
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i32 %122, i8* %57, i8* %136, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 233)
br label %150
138: ; preds = %130
%139 = icmp sgt i32 %131, 0
br i1 %139, label %140, label %148
140: ; preds = %138
%141 = call i32 @write(i32 %48, i8* %123, i32 %131)
%142 = icmp eq i32 %141, %131
br i1 %142, label %148, label %143
143: ; preds = %140
%144 = load i32, i32* @stderr
%145 = load i32, i32* @errno
%146 = call i8* @strerror(i32 %145)
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i32 %131, i8* %11, i8* %146, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 244)
br label %150
148: ; preds = %138, %140
%149 = icmp eq i32 %131, %122
br i1 %149, label %130, label %152
150: ; preds = %143, %133
%151 = call i32 @free(i8* %123)
br label %164
152: ; preds = %148
%153 = call i32 @free(i8* %123)
store i8 13, i8* %58
store i8 13, i8* %59
store i8 10, i8* %60
store i8 3, i8* %61
%154 = call i32 @write(i32 %48, i8* %58, i32 4)
%155 = icmp eq i32 %154, 4
br i1 %155, label %164, label %156
156: ; preds = %152
%157 = load i32, i32* @stderr
%158 = load i32, i32* @errno
%159 = call i8* @strerror(i32 %158)
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %157, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i8* %11, i8* %159, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 263)
br label %164
161: ; preds = %116
%162 = load i32, i32* @stderr
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i8* %57, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 272)
br label %164
164: ; preds = %150, %125, %152, %156, %161, %111
%165 = phi i32 [ -1, %111 ], [ -1, %161 ], [ -1, %125 ], [ 0, %152 ], [ 0, %156 ], [ -1, %150 ]
%166 = call i32 @close(i32 %100)
%167 = icmp eq i32 %166, -1
br i1 %167, label %168, label %173
168: ; preds = %164
%169 = load i32, i32* @stderr
%170 = load i32, i32* @errno
%171 = call i8* @strerror(i32 %170)
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i8* %57, i8* %171, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 280)
br label %173
173: ; preds = %168, %164
br label %174
174: ; preds = %102, %173, %91
%175 = phi i32 [ -1, %91 ], [ -1, %102 ], [ %165, %173 ]
%176 = call i32 @close(i32 %48)
%177 = icmp eq i32 %176, -1
br i1 %177, label %178, label %183
178: ; preds = %174
%179 = load i32, i32* @stderr
%180 = load i32, i32* @errno
%181 = call i8* @strerror(i32 %180)
%182 = call i32 (i32, i8*, ...) @fprintf(i32 %179, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i8* %11, i8* %181, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 287)
br label %183
183: ; preds = %178, %174
%184 = icmp eq i32 %175, 0
br i1 %184, label %185, label %201
185: ; preds = %183
%186 = call i64 @unlink(i8* %57)
%187 = icmp slt i64 %186, 0
br i1 %187, label %188, label %193
188: ; preds = %185
%189 = load i32, i32* @stderr
%190 = load i32, i32* @errno
%191 = call i8* @strerror(i32 %190)
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %189, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i8* %57, i8* %191, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 296)
br label %193
193: ; preds = %188, %185
%194 = call i64 @rename(i8* %11, i8* %57)
%195 = icmp slt i64 %194, 0
br i1 %195, label %196, label %201
196: ; preds = %193
%197 = load i32, i32* @stderr
%198 = load i32, i32* @errno
%199 = call i8* @strerror(i32 %198)
%200 = call i32 (i32, i8*, ...) @fprintf(i32 %197, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.15, i64 0, i64 0), i8* %11, i8* %57, i8* %199, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 303)
br label %201
201: ; preds = %193, %196, %183
br label %202
202: ; preds = %201, %50
%203 = phi i32 [ 0, %50 ], [ %175, %201 ]
br label %226
204: ; preds = %2
%205 = load i32, i32* @stderr
%206 = load i8*, i8** %1
%207 = tail call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.16, i64 0, i64 0), i8* %206)
%208 = load i32, i32* @stderr
%209 = tail call i32 (i32, i8*, ...) @fprintf(i32 %208, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.17, i64 0, i64 0))
%210 = load i32, i32* @stderr
%211 = tail call i32 (i32, i8*, ...) @fprintf(i32 %210, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.18, i64 0, i64 0))
%212 = load i32, i32* @stderr
%213 = tail call i32 (i32, i8*, ...) @fprintf(i32 %212, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%214 = load i32, i32* @stderr
%215 = tail call i32 (i32, i8*, ...) @fprintf(i32 %214, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%216 = load i32, i32* @stderr
%217 = tail call i32 (i32, i8*, ...) @fprintf(i32 %216, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0))
%218 = load i32, i32* @stderr
%219 = tail call i32 (i32, i8*, ...) @fprintf(i32 %218, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
%220 = load i32, i32* @stderr
%221 = tail call i32 (i32, i8*, ...) @fprintf(i32 %220, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.23, i64 0, i64 0))
%222 = load i32, i32* @stderr
%223 = tail call i32 (i32, i8*, ...) @fprintf(i32 %222, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.24, i64 0, i64 0))
%224 = load i32, i32* @stderr
%225 = tail call i32 (i32, i8*, ...) @fprintf(i32 %224, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.25, i64 0, i64 0))
br label %226
226: ; preds = %204, %202
%227 = phi i32 [ %203, %202 ], [ 0, %204 ]
ret i32 %227
}