#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 */
typedef char *filebuff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int isnewfile;
int /*<<< orphan*/ memmove(char *, char *, int);
int status;
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
char *timestamp(int /*<<< orphan*/, int /*<<< orphan*/);
int rastwritefile(char *filename, char *tag, char *value, int isstrict) {
  FILE *fp = (FILE *)NULL, *rastopenfile();
  char texfile[1024] = "\000", filebuff[(65536 - 1) + 1] = "\000", tag1[1024],
       tag2[1024], *strchange(), *timestamp();
  int istag = 0, rastreadfile(), isnewfile = 0, status = 0;
  int istimestamp = 0;
  if (filename == (char *)NULL || value == (char *)NULL)
    goto end_of_job;
  if (strlen(filename) < 2 || *value == '\000')
    goto end_of_job;
  strncpy(texfile, filename, 1023);
  texfile[1023] = '\000';
  if (rastopenfile(texfile, NULL) == (FILE *)NULL) {
    if (isstrict)
      goto end_of_job;
    isnewfile = 1;
  }
  if (tag != (char *)NULL)
    if (*tag != '\000') {
      istag = 1;
      strcpy(tag1, "<");
      strcpy(tag2, "</");
      strcat(tag1, tag);
      strcat(tag2, tag);
      strcat(tag1, ">");
      strcat(tag2, ">");
      if ((tag1) != NULL) {
        char *p;
        while ((p = strchr((tag1), (' '))) != NULL) {
          if ((1) != 0) {
            if (!(((p)) == NULL ? 1 : (*((p)) == '\000' ? 1 : 0))) {
              int thislen3 = strlen(p);
              if ((1) >= thislen3)
                *(p) = '\000';
              else
                memmove(p, p + (1), 1 + thislen3 - (1));
            }
          } else
            ;
        }
      } else
        ;
      if ((tag2) != NULL) {
        char *p;
        while ((p = strchr((tag2), (' '))) != NULL) {
          if ((1) != 0) {
            if (!(((p)) == NULL ? 1 : (*((p)) == '\000' ? 1 : 0))) {
              int thislen3 = strlen(p);
              if ((1) >= thislen3)
                *(p) = '\000';
              else
                memmove(p, p + (1), 1 + thislen3 - (1));
            }
          } else
            ;
        }
      } else
        ;
    }
  *filebuff = '\000';
  if (!isnewfile)
    if (istag)
      if (rastreadfile(texfile, 1, NULL, filebuff) <= 0)
        goto end_of_job;
  if (istag) {
    int tlen1 = strlen(tag1), tlen2 = strlen(tag2), flen;
    char *tagp1 = (isnewfile ? NULL : strstr(filebuff, tag1)),
         *tagp2 = (isnewfile ? NULL : strstr(filebuff, tag2));
    if (tagp1 == (char *)NULL) {
      if (tagp2 != (char *)NULL) {
        if (!(((filebuff)) == NULL ? 1 : (*((filebuff)) == '\000' ? 1 : 0)) &&
            !(((tagp2 + tlen2)) == NULL
                  ? 1
                  : (*((tagp2 + tlen2)) == '\000' ? 1 : 0))) {
          int sqlen = strlen((filebuff)) - strlen((tagp2 + tlen2));
          if (sqlen > 0 && sqlen <= 999) {
            if ((sqlen) != 0) {
              if (!((((filebuff))) == NULL
                        ? 1
                        : (*(((filebuff))) == '\000' ? 1 : 0))) {
                int thislen3 = strlen((filebuff));
                if ((sqlen) >= thislen3)
                  *((filebuff)) = '\000';
                else
                  memmove((filebuff), (filebuff) + (sqlen),
                          1 + thislen3 - (sqlen));
              }
            } else
              ;
          }
        } else
          ;
      }
      if ((flen = strlen(filebuff)) > 0)
        if (!((*(filebuff + flen - 1)) != '\000' && *("\n\r") != '\000' &&
              strchr("\n\r", (*(filebuff + flen - 1))) != (char *)NULL))
          if (0)
            strcat(filebuff, "\n");
      strcat(filebuff, tag1);
      strcat(filebuff, value);
      strcat(filebuff, tag2);
      strcat(filebuff, "\n");
    } else {
      if (tagp2 == NULL) {
        *(tagp1 + tlen1) = '\000';
        strcat(filebuff, value);
        strcat(filebuff, tag2);
      } else if ((flen = ((int)(tagp2 - tagp1)) - tlen1) >= 0)
        strchange(flen, tagp1 + tlen1, value);
      else {
        char fbuff[4096];
        if ((flen = ((int)(tagp1 - tagp2)) + tlen1) <= 0)
          goto end_of_job;
        strcpy(fbuff, tag1);
        strcat(fbuff, value);
        strcat(fbuff, tag2);
        strchange(flen, tagp2, fbuff);
      }
    }
  }
  if ((fp = rastopenfile(texfile, "w")) == (FILE *)NULL)
    goto end_of_job;
  if (fputs((istag ? filebuff : value), fp) != EOF)
    status = 1;
  fclose(fp);
  if (status > 0)
    if (istimestamp)
      if (istag)
        if (strstr(tag, "timestamp") == (char *)NULL) {
          char fbuff[2048];
          strcpy(fbuff, tag);
          strcat(fbuff, " modified at ");
          strcat(fbuff, timestamp(0, 0));
          status = rastwritefile(filename, "timestamp", fbuff, 1);
        }
end_of_job:
  return (status);
}


x86 assembly (clang, -O0):
<rastwritefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x124b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10a0 <memset@plt>
lea    -0x10430(%rbp),%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   10a0 <memset@plt>
movl   $0x0,-0x10c34(%rbp)
movl   $0x0,-0x10c38(%rbp)
movl   $0x0,-0x10c3c(%rbp)
movl   $0x0,-0x10c40(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1276 <rastwritefile+0x86>
cmpq   $0x0,-0x18(%rbp)
jne    127b <rastwritefile+0x8b>
jmp    1b4e <rastwritefile+0x95e>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jl     129d <rastwritefile+0xad>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12a2 <rastwritefile+0xb2>
jmp    1b4e <rastwritefile+0x95e>
lea    -0x430(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3ff,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x31(%rbp)
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x0,%al
call   10e0 <rastopenfile@plt>
cmp    $0x0,%rax
jne    12f0 <rastwritefile+0x100>
cmpl   $0x0,-0x1c(%rbp)
je     12e6 <rastwritefile+0xf6>
jmp    1b4e <rastwritefile+0x95e>
movl   $0x1,-0x10c38(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     152e <rastwritefile+0x33e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1529 <rastwritefile+0x339>
movl   $0x1,-0x10c34(%rbp)
lea    -0x10830(%rbp),%rdi
lea    0xcdd(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x10c30(%rbp),%rdi
lea    0xccc(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x10830(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x10c30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x10830(%rbp),%rdi
lea    0xc9c(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x10c30(%rbp),%rdi
lea    0xc89(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x10830(%rbp),%rdi
mov    $0x20,%esi
call   1080 <strchr@plt>
mov    %rax,-0x10c48(%rbp)
cmp    $0x0,%rax
je     1450 <rastwritefile+0x260>
cmpq   $0x0,-0x10c48(%rbp)
jne    13c0 <rastwritefile+0x1d0>
mov    $0x1,%al
test   $0x1,%al
jne    144b <rastwritefile+0x25b>
jmp    13f1 <rastwritefile+0x201>
mov    -0x10c48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    13e2 <rastwritefile+0x1f2>
mov    $0x1,%al
test   $0x1,%al
jne    144b <rastwritefile+0x25b>
jmp    13f1 <rastwritefile+0x201>
xor    %eax,%eax
test   $0x1,%al
jne    144b <rastwritefile+0x25b>
jmp    13f1 <rastwritefile+0x201>
mov    -0x10c48(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10c4c(%rbp)
mov    $0x1,%eax
cmp    -0x10c4c(%rbp),%eax
jl     1423 <rastwritefile+0x233>
mov    -0x10c48(%rbp),%rax
movb   $0x0,(%rax)
jmp    1446 <rastwritefile+0x256>
mov    -0x10c48(%rbp),%rdi
mov    -0x10c48(%rbp),%rsi
add    $0x1,%rsi
mov    -0x10c4c(%rbp),%edx
add    $0x1,%edx
sub    $0x1,%edx
call   10f0 <memmove@plt>
jmp    144b <rastwritefile+0x25b>
jmp    1381 <rastwritefile+0x191>
jmp    1455 <rastwritefile+0x265>
lea    -0x10c30(%rbp),%rdi
mov    $0x20,%esi
call   1080 <strchr@plt>
mov    %rax,-0x10c58(%rbp)
cmp    $0x0,%rax
je     1524 <rastwritefile+0x334>
cmpq   $0x0,-0x10c58(%rbp)
jne    1494 <rastwritefile+0x2a4>
mov    $0x1,%al
test   $0x1,%al
jne    151f <rastwritefile+0x32f>
jmp    14c5 <rastwritefile+0x2d5>
mov    -0x10c58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    14b6 <rastwritefile+0x2c6>
mov    $0x1,%al
test   $0x1,%al
jne    151f <rastwritefile+0x32f>
jmp    14c5 <rastwritefile+0x2d5>
xor    %eax,%eax
test   $0x1,%al
jne    151f <rastwritefile+0x32f>
jmp    14c5 <rastwritefile+0x2d5>
mov    -0x10c58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10c5c(%rbp)
mov    $0x1,%eax
cmp    -0x10c5c(%rbp),%eax
jl     14f7 <rastwritefile+0x307>
mov    -0x10c58(%rbp),%rax
movb   $0x0,(%rax)
jmp    151a <rastwritefile+0x32a>
mov    -0x10c58(%rbp),%rdi
mov    -0x10c58(%rbp),%rsi
add    $0x1,%rsi
mov    -0x10c5c(%rbp),%edx
add    $0x1,%edx
sub    $0x1,%edx
call   10f0 <memmove@plt>
jmp    151f <rastwritefile+0x32f>
jmp    1455 <rastwritefile+0x265>
jmp    1529 <rastwritefile+0x339>
jmp    152e <rastwritefile+0x33e>
movb   $0x0,-0x10430(%rbp)
cmpl   $0x0,-0x10c38(%rbp)
jne    1585 <rastwritefile+0x395>
cmpl   $0x0,-0x10c34(%rbp)
je     1580 <rastwritefile+0x390>
lea    -0x430(%rbp),%rdi
lea    -0x10430(%rbp),%rcx
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   10b0 <rastreadfile@plt>
cmp    $0x0,%eax
jg     157b <rastwritefile+0x38b>
jmp    1b4e <rastwritefile+0x95e>
jmp    1580 <rastwritefile+0x390>
jmp    1585 <rastwritefile+0x395>
cmpl   $0x0,-0x10c34(%rbp)
je     1a08 <rastwritefile+0x818>
lea    -0x10830(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10c60(%rbp)
lea    -0x10c30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10c64(%rbp)
cmpl   $0x0,-0x10c38(%rbp)
je     15d1 <rastwritefile+0x3e1>
xor    %eax,%eax
mov    %rax,-0x12488(%rbp)
jmp    15eb <rastwritefile+0x3fb>
lea    -0x10430(%rbp),%rdi
lea    -0x10830(%rbp),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x12488(%rbp)
mov    -0x12488(%rbp),%rax
mov    %rax,-0x10c70(%rbp)
cmpl   $0x0,-0x10c38(%rbp)
je     1614 <rastwritefile+0x424>
xor    %eax,%eax
mov    %rax,-0x12490(%rbp)
jmp    162e <rastwritefile+0x43e>
lea    -0x10430(%rbp),%rdi
lea    -0x10c30(%rbp),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x12490(%rbp)
mov    -0x12490(%rbp),%rax
mov    %rax,-0x10c78(%rbp)
cmpq   $0x0,-0x10c70(%rbp)
jne    18e8 <rastwritefile+0x6f8>
cmpq   $0x0,-0x10c78(%rbp)
je     1838 <rastwritefile+0x648>
lea    -0x10430(%rbp),%rax
cmp    $0x0,%rax
jne    1678 <rastwritefile+0x488>
mov    $0x1,%al
test   $0x1,%al
jne    182e <rastwritefile+0x63e>
jmp    16a6 <rastwritefile+0x4b6>
movsbl -0x10430(%rbp),%eax
cmp    $0x0,%eax
jne    1697 <rastwritefile+0x4a7>
mov    $0x1,%al
test   $0x1,%al
jne    182e <rastwritefile+0x63e>
jmp    16a6 <rastwritefile+0x4b6>
xor    %eax,%eax
test   $0x1,%al
jne    182e <rastwritefile+0x63e>
jmp    16a6 <rastwritefile+0x4b6>
mov    -0x10c78(%rbp),%rax
movslq -0x10c64(%rbp),%rcx
add    %rcx,%rax
cmp    $0x0,%rax
jne    16d0 <rastwritefile+0x4e0>
mov    $0x1,%al
test   $0x1,%al
jne    182e <rastwritefile+0x63e>
jmp    1709 <rastwritefile+0x519>
mov    -0x10c78(%rbp),%rax
movslq -0x10c64(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    16fa <rastwritefile+0x50a>
mov    $0x1,%al
test   $0x1,%al
jne    182e <rastwritefile+0x63e>
jmp    1709 <rastwritefile+0x519>
xor    %eax,%eax
test   $0x1,%al
jne    182e <rastwritefile+0x63e>
jmp    1709 <rastwritefile+0x519>
lea    -0x10430(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x12494(%rbp)
mov    -0x10c78(%rbp),%rdi
movslq -0x10c64(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x12494(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10c7c(%rbp)
cmpl   $0x0,-0x10c7c(%rbp)
jle    1829 <rastwritefile+0x639>
cmpl   $0x3e7,-0x10c7c(%rbp)
jg     1829 <rastwritefile+0x639>
cmpl   $0x0,-0x10c7c(%rbp)
je     181f <rastwritefile+0x62f>
lea    -0x10430(%rbp),%rax
cmp    $0x0,%rax
jne    178b <rastwritefile+0x59b>
mov    $0x1,%al
test   $0x1,%al
jne    181a <rastwritefile+0x62a>
jmp    17b9 <rastwritefile+0x5c9>
movsbl -0x10430(%rbp),%eax
cmp    $0x0,%eax
jne    17aa <rastwritefile+0x5ba>
mov    $0x1,%al
test   $0x1,%al
jne    181a <rastwritefile+0x62a>
jmp    17b9 <rastwritefile+0x5c9>
xor    %eax,%eax
test   $0x1,%al
jne    181a <rastwritefile+0x62a>
jmp    17b9 <rastwritefile+0x5c9>
lea    -0x10430(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10c80(%rbp)
mov    -0x10c7c(%rbp),%eax
cmp    -0x10c80(%rbp),%eax
jl     17e9 <rastwritefile+0x5f9>
movb   $0x0,-0x10430(%rbp)
jmp    1815 <rastwritefile+0x625>
lea    -0x10430(%rbp),%rdi
lea    -0x10430(%rbp),%rsi
movslq -0x10c7c(%rbp),%rax
add    %rax,%rsi
mov    -0x10c80(%rbp),%edx
add    $0x1,%edx
sub    -0x10c7c(%rbp),%edx
call   10f0 <memmove@plt>
jmp    181a <rastwritefile+0x62a>
jmp    1824 <rastwritefile+0x634>
jmp    1824 <rastwritefile+0x634>
jmp    1829 <rastwritefile+0x639>
jmp    1833 <rastwritefile+0x643>
jmp    1833 <rastwritefile+0x643>
jmp    1838 <rastwritefile+0x648>
lea    -0x10430(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x10c68(%rbp)
cmp    $0x0,%eax
jle    189a <rastwritefile+0x6aa>
movslq -0x10c68(%rbp),%rax
movsbl -0x10431(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1890 <rastwritefile+0x6a0>
movslq -0x10c68(%rbp),%rax
lea    0x78e(%rip),%rdi
movsbl -0x10431(%rbp,%rax,1),%esi
ff
call   1080 <strchr@plt>
cmp    $0x0,%rax
jne    1895 <rastwritefile+0x6a5>
jmp    1895 <rastwritefile+0x6a5>
jmp    189a <rastwritefile+0x6aa>
lea    -0x10430(%rbp),%rdi
lea    -0x10830(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x10430(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x10430(%rbp),%rdi
lea    -0x10c30(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x10430(%rbp),%rdi
lea    0x72c(%rip),%rsi
call   1100 <strcat@plt>
jmp    1a03 <rastwritefile+0x813>
cmpq   $0x0,-0x10c78(%rbp)
jne    1930 <rastwritefile+0x740>
mov    -0x10c70(%rbp),%rax
movslq -0x10c60(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x10430(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x10430(%rbp),%rdi
lea    -0x10c30(%rbp),%rsi
call   1100 <strcat@plt>
jmp    19fe <rastwritefile+0x80e>
mov    -0x10c78(%rbp),%rax
mov    -0x10c70(%rbp),%rcx
sub    %rcx,%rax
sub    -0x10c60(%rbp),%eax
mov    %eax,-0x10c68(%rbp)
cmp    $0x0,%eax
jl     197d <rastwritefile+0x78d>
mov    -0x10c68(%rbp),%edi
mov    -0x10c70(%rbp),%rsi
movslq -0x10c60(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    $0x0,%al
call   10d0 <strchange@plt>
jmp    19f9 <rastwritefile+0x809>
mov    -0x10c70(%rbp),%rax
mov    -0x10c78(%rbp),%rcx
sub    %rcx,%rax
add    -0x10c60(%rbp),%eax
mov    %eax,-0x10c68(%rbp)
cmp    $0x0,%eax
jg     19a8 <rastwritefile+0x7b8>
jmp    1b4e <rastwritefile+0x95e>
lea    -0x11c80(%rbp),%rdi
lea    -0x10830(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x11c80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0x11c80(%rbp),%rdi
lea    -0x10c30(%rbp),%rsi
call   1100 <strcat@plt>
mov    -0x10c68(%rbp),%edi
mov    -0x10c78(%rbp),%rsi
lea    -0x11c80(%rbp),%rdx
mov    $0x0,%al
call   10d0 <strchange@plt>
jmp    19fe <rastwritefile+0x80e>
jmp    1a03 <rastwritefile+0x813>
jmp    1a08 <rastwritefile+0x818>
lea    -0x430(%rbp),%rdi
lea    0x5f6(%rip),%rsi
mov    $0x0,%al
call   10e0 <rastopenfile@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1a30 <rastwritefile+0x840>
jmp    1b4e <rastwritefile+0x95e>
cmpl   $0x0,-0x10c34(%rbp)
je     1a50 <rastwritefile+0x860>
lea    -0x10430(%rbp),%rax
mov    %rax,-0x124a0(%rbp)
jmp    1a5b <rastwritefile+0x86b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x124a0(%rbp)
mov    -0x124a0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <fputs@plt>
mov    0x2576(%rip),%rcx
cmp    (%rcx),%rax
je     1a85 <rastwritefile+0x895>
movl   $0x1,-0x10c3c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x0,-0x10c3c(%rbp)
jle    1b49 <rastwritefile+0x959>
cmpl   $0x0,-0x10c40(%rbp)
je     1b44 <rastwritefile+0x954>
cmpl   $0x0,-0x10c34(%rbp)
je     1b3f <rastwritefile+0x94f>
mov    -0x10(%rbp),%rdi
lea    0x54e(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
jne    1b3a <rastwritefile+0x94a>
lea    -0x12480(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x12480(%rbp),%rdi
lea    0x52b(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x12480(%rbp),%rax
mov    %rax,-0x124a8(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1070 <timestamp@plt>
mov    -0x124a8(%rbp),%rdi
mov    %rax,%rsi
call   1100 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x12480(%rbp),%rdx
lea    0x4e4(%rip),%rsi
mov    $0x1,%ecx
call   10c0 <rastwritefile@plt>
mov    %eax,-0x10c3c(%rbp)
jmp    1b3f <rastwritefile+0x94f>
jmp    1b44 <rastwritefile+0x954>
jmp    1b49 <rastwritefile+0x959>
jmp    1b4e <rastwritefile+0x95e>
mov    -0x10c3c(%rbp),%eax
add    $0x124b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rastwritefile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x11c18,%rsp
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0x810(%rsp),%rdi
xor    %r12d,%r12d
mov    $0x400,%edx
xor    %esi,%esi
call   1090 <memset@plt>
lea    0x1c10(%rsp),%rdi
mov    $0x10000,%edx
xor    %esi,%esi
call   1090 <memset@plt>
test   %rbp,%rbp
je     1646 <rastwritefile+0x476>
test   %rbx,%rbx
je     1646 <rastwritefile+0x476>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jl     1646 <rastwritefile+0x476>
cmpb   $0x0,(%rbx)
je     1646 <rastwritefile+0x476>
lea    0x810(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x3ff,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xc0f(%rsp)
xor    %r12d,%r12d
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   10c0 <rastopenfile@plt>
test   %r15d,%r15d
je     1281 <rastwritefile+0xb1>
test   %rax,%rax
je     1646 <rastwritefile+0x476>
test   %r13,%r13
je     1359 <rastwritefile+0x189>
cmpb   $0x0,0x0(%r13)
je     1359 <rastwritefile+0x189>
mov    %rbx,0x8(%rsp)
lea    0xd5f(%rip),%rsi
mov    %rax,%r15
lea    0x410(%rsp),%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
lea    0xd47(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10e0 <strcat@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   10e0 <strcat@plt>
lea    0xd20(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   10e0 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10e0 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%r14
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1369 <rastwritefile+0x199>
mov    %rax,%rbp
lea    0x410(%rsp),%rbx
jmp    1340 <rastwritefile+0x170>
lea    0x1(%rbp),%rsi
mov    %rbp,%rdi
mov    %eax,%edx
call   10d0 <memmove@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1369 <rastwritefile+0x199>
cmpb   $0x0,0x0(%rbp)
je     132b <rastwritefile+0x15b>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x1,%eax
jg     131d <rastwritefile+0x14d>
movb   $0x0,0x0(%rbp)
jmp    132b <rastwritefile+0x15b>
movb   $0x0,0x1c10(%rsp)
xor    %r14d,%r14d
jmp    15f2 <rastwritefile+0x422>
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     13c3 <rastwritefile+0x1f3>
mov    %rax,%rbp
lea    0x10(%rsp),%rbx
jmp    13aa <rastwritefile+0x1da>
lea    0x1(%rbp),%rsi
mov    %rbp,%rdi
mov    %eax,%edx
call   10d0 <memmove@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
je     13c3 <rastwritefile+0x1f3>
cmpb   $0x0,0x0(%rbp)
je     1395 <rastwritefile+0x1c5>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x1,%eax
jg     1387 <rastwritefile+0x1b7>
movb   $0x0,0x0(%rbp)
jmp    1395 <rastwritefile+0x1c5>
movb   $0x0,0x1c10(%rsp)
test   %r14,%r14
je     13f9 <rastwritefile+0x229>
xor    %r12d,%r12d
lea    0x810(%rsp),%rdi
lea    0x1c10(%rsp),%rcx
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   10a0 <rastreadfile@plt>
test   %eax,%eax
jle    1646 <rastwritefile+0x476>
lea    0x410(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,%r13d
lea    0x10(%rsp),%rdi
call   1060 <strlen@plt>
test   %r14,%r14
je     15a3 <rastwritefile+0x3d3>
mov    %eax,%r15d
lea    0x1c10(%rsp),%rbx
lea    0x410(%rsp),%rsi
mov    %rbx,%rdi
call   10f0 <strstr@plt>
mov    %rax,%rbp
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10f0 <strstr@plt>
mov    %rax,%rbx
test   %rbp,%rbp
je     147b <rastwritefile+0x2ab>
test   %rbx,%rbx
je     1515 <rastwritefile+0x345>
mov    %ebx,%edi
sub    %ebp,%edi
sub    %r13d,%edi
js     153f <rastwritefile+0x36f>
movslq %r13d,%rax
add    %rax,%rbp
mov    %rbp,%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdx
jmp    158a <rastwritefile+0x3ba>
test   %rbx,%rbx
je     15a3 <rastwritefile+0x3d3>
cmpb   $0x0,0x1c10(%rsp)
je     15a3 <rastwritefile+0x3d3>
movslq %r15d,%rax
cmpb   $0x0,(%rbx,%rax,1)
je     15a3 <rastwritefile+0x3d3>
add    %rax,%rbx
lea    0x1c10(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
sub    %eax,%ebp
lea    -0x3e8(%rbp),%eax
cmp    $0xfffffc19,%eax
jb     15a3 <rastwritefile+0x3d3>
cmpb   $0x0,0x1c10(%rsp)
je     15a3 <rastwritefile+0x3d3>
lea    0x1c10(%rsp),%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
jge    159b <rastwritefile+0x3cb>
mov    %ebp,%ecx
lea    (%rsp,%rcx,1),%rsi
add    $0x1c10,%rsi
sub    %ebp,%eax
add    $0x1,%eax
lea    0x1c10(%rsp),%rdi
mov    %eax,%edx
call   10d0 <memmove@plt>
jmp    15a3 <rastwritefile+0x3d3>
movslq %r13d,%rax
movb   $0x0,0x0(%rbp,%rax,1)
lea    0x1c10(%rsp),%rbp
mov    %rbp,%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   10e0 <strcat@plt>
lea    0x10(%rsp),%rsi
jmp    15e7 <rastwritefile+0x417>
sub    %ebx,%ebp
add    %ebp,%r13d
test   %r13d,%r13d
jle    1593 <rastwritefile+0x3c3>
lea    0xc10(%rsp),%r14
lea    0x410(%rsp),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    0x8(%rsp),%rbp
mov    %rbp,%rsi
call   10e0 <strcat@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   10e0 <strcat@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %rbp,%rbx
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <strchange@plt>
jmp    15ef <rastwritefile+0x41f>
xor    %r12d,%r12d
jmp    1646 <rastwritefile+0x476>
movb   $0x0,0x1c10(%rsp)
lea    0x1c10(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x410(%rsp),%rsi
mov    %rbp,%rdi
call   10e0 <strcat@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   10e0 <strcat@plt>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   10e0 <strcat@plt>
lea    0xa20(%rip),%rsi
mov    %rbp,%rdi
call   10e0 <strcat@plt>
mov    $0x1,%r14b
lea    0xa10(%rip),%rsi
xor    %r12d,%r12d
lea    0x810(%rsp),%rdi
xor    %eax,%eax
call   10c0 <rastopenfile@plt>
test   %rax,%rax
je     1646 <rastwritefile+0x476>
mov    %rax,%rbp
test   %r14b,%r14b
lea    0x1c10(%rsp),%rax
cmovne %rax,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <fputs@plt>
mov    0x29b4(%rip),%rcx
xor    %r12d,%r12d
cmp    (%rcx),%rax
setne  %r12b
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    %r12d,%eax
add    $0x11c18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"<\00"
@.str.1 = [3 x i8] c"</\00"
@.str.2 = [2 x i8] c">\00"
@.str.3 = [3 x i8] c"\0A\0D\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c"w\00"
@EOF = global i64 0
@.str.6 = [10 x i8] c"timestamp\00"
@.str.7 = [14 x i8] c" modified at \00"
@isnewfile = global i32 0
@status = global i32 0
define i32 @rastwritefile(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [1024 x i8]
%11 = alloca [65536 x i8]
%12 = alloca [1024 x i8]
%13 = alloca [1024 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i32
%28 = alloca i32
%29 = alloca [4096 x i8]
%30 = alloca [2048 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32* null, i32** %9
%31 = bitcast [1024 x i8]* %10 to i8*
%32 = bitcast [65536 x i8]* %11 to i8*
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
%33 = load i8*, i8** %5
%34 = icmp eq i8* %33, null
br i1 %34, label %38, label %35
35: ; preds = %4
%36 = load i8*, i8** %7
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %39
38: ; preds = %35, %4
br label %426
39: ; preds = %35
%40 = load i8*, i8** %5
%41 = call i32 @strlen(i8* %40)
%42 = icmp slt i32 %41, 2
br i1 %42, label %48, label %43
43: ; preds = %39
%44 = load i8*, i8** %7
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %43, %39
br label %426
49: ; preds = %43
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%51 = load i8*, i8** %5
%52 = call i32 @strncpy(i8* %50, i8* %51, i32 1023)
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 1023
store i8 0, i8* %53
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%55 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @rastopenfile to i32* (i8*, i8*, ...)*)(i8* %54, i8* null)
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %62
57: ; preds = %49
%58 = load i32, i32* %8
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %57
br label %426
61: ; preds = %57
store i32 1, i32* %15
br label %62
62: ; preds = %61, %49
%63 = load i8*, i8** %6
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %152
65: ; preds = %62
%66 = load i8*, i8** %6
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %151
70: ; preds = %65
store i32 1, i32* %14
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%72 = call i32 @strcpy(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%74 = call i32 @strcpy(i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%76 = load i8*, i8** %6
%77 = call i32 @strcat(i8* %75, i8* %76)
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%79 = load i8*, i8** %6
%80 = call i32 @strcat(i8* %78, i8* %79)
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%82 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%84 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %85
85: ; preds = %116, %70
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%87 = call i8* @strchr(i8* %86, i8 signext 32)
store i8* %87, i8** %18
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %117
89: ; preds = %85
%90 = load i8*, i8** %18
%91 = icmp eq i8* %90, null
br i1 %91, label %92, label %93
92: ; preds = %89
br i1 true, label %116, label %100
93: ; preds = %89
%94 = load i8*, i8** %18
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %93
br i1 true, label %116, label %100
99: ; preds = %93
br i1 false, label %116, label %100
100: ; preds = %99, %98, %92
%101 = load i8*, i8** %18
%102 = call i32 @strlen(i8* %101)
store i32 %102, i32* %19
%103 = load i32, i32* %19
%104 = icmp sge i32 1, %103
br i1 %104, label %105, label %107
105: ; preds = %100
%106 = load i8*, i8** %18
store i8 0, i8* %106
br label %115
107: ; preds = %100
%108 = load i8*, i8** %18
%109 = load i8*, i8** %18
%110 = getelementptr inbounds i8, i8* %109, i64 1
%111 = load i32, i32* %19
%112 = add nsw i32 1, %111
%113 = sub nsw i32 %112, 1
%114 = call i32 @memmove(i8* %108, i8* %110, i32 %113)
br label %115
115: ; preds = %107, %105
br label %116
116: ; preds = %115, %99, %98, %92
br label %85
117: ; preds = %85
br label %118
118: ; preds = %149, %117
%119 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%120 = call i8* @strchr(i8* %119, i8 signext 32)
store i8* %120, i8** %20
%121 = icmp ne i8* %120, null
br i1 %121, label %122, label %150
122: ; preds = %118
%123 = load i8*, i8** %20
%124 = icmp eq i8* %123, null
br i1 %124, label %125, label %126
125: ; preds = %122
br i1 true, label %149, label %133
126: ; preds = %122
%127 = load i8*, i8** %20
%128 = load i8, i8* %127
%129 = sext i8 %128 to i32
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %132
131: ; preds = %126
br i1 true, label %149, label %133
132: ; preds = %126
br i1 false, label %149, label %133
133: ; preds = %132, %131, %125
%134 = load i8*, i8** %20
%135 = call i32 @strlen(i8* %134)
store i32 %135, i32* %21
%136 = load i32, i32* %21
%137 = icmp sge i32 1, %136
br i1 %137, label %138, label %140
138: ; preds = %133
%139 = load i8*, i8** %20
store i8 0, i8* %139
br label %148
140: ; preds = %133
%141 = load i8*, i8** %20
%142 = load i8*, i8** %20
%143 = getelementptr inbounds i8, i8* %142, i64 1
%144 = load i32, i32* %21
%145 = add nsw i32 1, %144
%146 = sub nsw i32 %145, 1
%147 = call i32 @memmove(i8* %141, i8* %143, i32 %146)
br label %148
148: ; preds = %140, %138
br label %149
149: ; preds = %148, %132, %131, %125
br label %118
150: ; preds = %118
br label %151
151: ; preds = %150, %65
br label %152
152: ; preds = %151, %62
%153 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
store i8 0, i8* %153
%154 = load i32, i32* %15
%155 = icmp ne i32 %154, 0
br i1 %155, label %167, label %156
156: ; preds = %152
%157 = load i32, i32* %14
%158 = icmp ne i32 %157, 0
br i1 %158, label %159, label %166
159: ; preds = %156
%160 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%161 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%162 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @rastreadfile to i32 (i8*, i32, i8*, i8*, ...)*)(i8* %160, i32 1, i8* null, i8* %161)
%163 = icmp sle i32 %162, 0
br i1 %163, label %164, label %165
164: ; preds = %159
br label %426
165: ; preds = %159
br label %166
166: ; preds = %165, %156
br label %167
167: ; preds = %166, %152
%168 = load i32, i32* %14
%169 = icmp ne i32 %168, 0
br i1 %169, label %170, label %376
170: ; preds = %167
%171 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%172 = call i32 @strlen(i8* %171)
store i32 %172, i32* %22
%173 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%174 = call i32 @strlen(i8* %173)
store i32 %174, i32* %23
%175 = load i32, i32* %15
%176 = icmp ne i32 %175, 0
br i1 %176, label %177, label %178
177: ; preds = %170
br label %182
178: ; preds = %170
%179 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%180 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%181 = call i8* @strstr(i8* %179, i8* %180)
br label %182
182: ; preds = %178, %177
%183 = phi i8* [ null, %177 ], [ %181, %178 ]
store i8* %183, i8** %25
%184 = load i32, i32* %15
%185 = icmp ne i32 %184, 0
br i1 %185, label %186, label %187
186: ; preds = %182
br label %191
187: ; preds = %182
%188 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%189 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%190 = call i8* @strstr(i8* %188, i8* %189)
br label %191
191: ; preds = %187, %186
%192 = phi i8* [ null, %186 ], [ %190, %187 ]
store i8* %192, i8** %26
%193 = load i8*, i8** %25
%194 = icmp eq i8* %193, null
br i1 %194, label %195, label %316
195: ; preds = %191
%196 = load i8*, i8** %26
%197 = icmp ne i8* %196, null
br i1 %197, label %198, label %280
198: ; preds = %195
%199 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%200 = icmp eq i8* %199, null
br i1 %200, label %201, label %202
201: ; preds = %198
br i1 true, label %278, label %209
202: ; preds = %198
%203 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%204 = load i8, i8* %203
%205 = sext i8 %204 to i32
%206 = icmp eq i32 %205, 0
br i1 %206, label %207, label %208
207: ; preds = %202
br i1 true, label %278, label %209
208: ; preds = %202
br i1 false, label %278, label %209
209: ; preds = %208, %207, %201
%210 = load i8*, i8** %26
%211 = load i32, i32* %23
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds i8, i8* %210, i64 %212
%214 = icmp eq i8* %213, null
br i1 %214, label %215, label %216
215: ; preds = %209
br i1 true, label %278, label %226
216: ; preds = %209
%217 = load i8*, i8** %26
%218 = load i32, i32* %23
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8, i8* %217, i64 %219
%221 = load i8, i8* %220
%222 = sext i8 %221 to i32
%223 = icmp eq i32 %222, 0
br i1 %223, label %224, label %225
224: ; preds = %216
br i1 true, label %278, label %226
225: ; preds = %216
br i1 false, label %278, label %226
226: ; preds = %225, %224, %215
%227 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%228 = call i32 @strlen(i8* %227)
%229 = load i8*, i8** %26
%230 = load i32, i32* %23
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds i8, i8* %229, i64 %231
%233 = call i32 @strlen(i8* %232)
%234 = sub nsw i32 %228, %233
store i32 %234, i32* %27
%235 = load i32, i32* %27
%236 = icmp sgt i32 %235, 0
br i1 %236, label %237, label %277
237: ; preds = %226
%238 = load i32, i32* %27
%239 = icmp sle i32 %238, 999
br i1 %239, label %240, label %277
240: ; preds = %237
%241 = load i32, i32* %27
%242 = icmp ne i32 %241, 0
br i1 %242, label %243, label %275
243: ; preds = %240
%244 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%245 = icmp eq i8* %244, null
br i1 %245, label %246, label %247
246: ; preds = %243
br i1 true, label %274, label %254
247: ; preds = %243
%248 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%249 = load i8, i8* %248
%250 = sext i8 %249 to i32
%251 = icmp eq i32 %250, 0
br i1 %251, label %252, label %253
252: ; preds = %247
br i1 true, label %274, label %254
253: ; preds = %247
br i1 false, label %274, label %254
254: ; preds = %253, %252, %246
%255 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%256 = call i32 @strlen(i8* %255)
store i32 %256, i32* %28
%257 = load i32, i32* %27
%258 = load i32, i32* %28
%259 = icmp sge i32 %257, %258
br i1 %259, label %260, label %262
260: ; preds = %254
%261 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
store i8 0, i8* %261
br label %273
262: ; preds = %254
%263 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%264 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%265 = load i32, i32* %27
%266 = sext i32 %265 to i64
%267 = getelementptr inbounds i8, i8* %264, i64 %266
%268 = load i32, i32* %28
%269 = add nsw i32 1, %268
%270 = load i32, i32* %27
%271 = sub nsw i32 %269, %270
%272 = call i32 @memmove(i8* %263, i8* %267, i32 %271)
br label %273
273: ; preds = %262, %260
br label %274
274: ; preds = %273, %253, %252, %246
br label %276
275: ; preds = %240
br label %276
276: ; preds = %275, %274
br label %277
277: ; preds = %276, %237, %226
br label %279
278: ; preds = %225, %224, %215, %208, %207, %201
br label %279
279: ; preds = %278, %277
br label %280
280: ; preds = %279, %195
%281 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%282 = call i32 @strlen(i8* %281)
store i32 %282, i32* %24
%283 = icmp sgt i32 %282, 0
br i1 %283, label %284, label %304
284: ; preds = %280
%285 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%286 = load i32, i32* %24
%287 = sext i32 %286 to i64
%288 = getelementptr inbounds i8, i8* %285, i64 %287
%289 = getelementptr inbounds i8, i8* %288, i64 -1
%290 = load i8, i8* %289
%291 = sext i8 %290 to i32
%292 = icmp ne i32 %291, 0
br i1 %292, label %293, label %302
293: ; preds = %284
%294 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%295 = load i32, i32* %24
%296 = sext i32 %295 to i64
%297 = getelementptr inbounds i8, i8* %294, i64 %296
%298 = getelementptr inbounds i8, i8* %297, i64 -1
%299 = load i8, i8* %298
%300 = call i8* @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8 signext %299)
%301 = icmp ne i8* %300, null
br i1 %301, label %303, label %302
302: ; preds = %293, %284
br label %303
303: ; preds = %302, %293
br label %304
304: ; preds = %303, %280
%305 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%306 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%307 = call i32 @strcat(i8* %305, i8* %306)
%308 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%309 = load i8*, i8** %7
%310 = call i32 @strcat(i8* %308, i8* %309)
%311 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%312 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%313 = call i32 @strcat(i8* %311, i8* %312)
%314 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%315 = call i32 @strcat(i8* %314, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %375
316: ; preds = %191
%317 = load i8*, i8** %26
%318 = icmp eq i8* %317, null
br i1 %318, label %319, label %330
319: ; preds = %316
%320 = load i8*, i8** %25
%321 = load i32, i32* %22
%322 = sext i32 %321 to i64
%323 = getelementptr inbounds i8, i8* %320, i64 %322
store i8 0, i8* %323
%324 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%325 = load i8*, i8** %7
%326 = call i32 @strcat(i8* %324, i8* %325)
%327 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
%328 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%329 = call i32 @strcat(i8* %327, i8* %328)
br label %374
330: ; preds = %316
%331 = load i8*, i8** %26
%332 = load i8*, i8** %25
%333 = ptrtoint i8* %331 to i64
%334 = ptrtoint i8* %332 to i64
%335 = sub i64 %333, %334
%336 = trunc i64 %335 to i32
%337 = load i32, i32* %22
%338 = sub nsw i32 %336, %337
store i32 %338, i32* %24
%339 = icmp sge i32 %338, 0
br i1 %339, label %340, label %348
340: ; preds = %330
%341 = load i32, i32* %24
%342 = load i8*, i8** %25
%343 = load i32, i32* %22
%344 = sext i32 %343 to i64
%345 = getelementptr inbounds i8, i8* %342, i64 %344
%346 = load i8*, i8** %7
%347 = call i8* (i32, i8*, i8*, ...) bitcast (i8* (...)* @strchange to i8* (i32, i8*, i8*, ...)*)(i32 %341, i8* %345, i8* %346)
br label %373
348: ; preds = %330
%349 = load i8*, i8** %25
%350 = load i8*, i8** %26
%351 = ptrtoint i8* %349 to i64
%352 = ptrtoint i8* %350 to i64
%353 = sub i64 %351, %352
%354 = trunc i64 %353 to i32
%355 = load i32, i32* %22
%356 = add nsw i32 %354, %355
store i32 %356, i32* %24
%357 = icmp sle i32 %356, 0
br i1 %357, label %358, label %359
358: ; preds = %348
br label %426
359: ; preds = %348
%360 = getelementptr inbounds [4096 x i8], [4096 x i8]* %29, i64 0, i64 0
%361 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%362 = call i32 @strcpy(i8* %360, i8* %361)
%363 = getelementptr inbounds [4096 x i8], [4096 x i8]* %29, i64 0, i64 0
%364 = load i8*, i8** %7
%365 = call i32 @strcat(i8* %363, i8* %364)
%366 = getelementptr inbounds [4096 x i8], [4096 x i8]* %29, i64 0, i64 0
%367 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%368 = call i32 @strcat(i8* %366, i8* %367)
%369 = load i32, i32* %24
%370 = load i8*, i8** %26
%371 = getelementptr inbounds [4096 x i8], [4096 x i8]* %29, i64 0, i64 0
%372 = call i8* (i32, i8*, i8*, ...) bitcast (i8* (...)* @strchange to i8* (i32, i8*, i8*, ...)*)(i32 %369, i8* %370, i8* %371)
br label %373
373: ; preds = %359, %340
br label %374
374: ; preds = %373, %319
br label %375
375: ; preds = %374, %304
br label %376
376: ; preds = %375, %167
%377 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%378 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @rastopenfile to i32* (i8*, i8*, ...)*)(i8* %377, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %378, i32** %9
%379 = icmp eq i32* %378, null
br i1 %379, label %380, label %381
380: ; preds = %376
br label %426
381: ; preds = %376
%382 = load i32, i32* %14
%383 = icmp ne i32 %382, 0
br i1 %383, label %384, label %386
384: ; preds = %381
%385 = getelementptr inbounds [65536 x i8], [65536 x i8]* %11, i64 0, i64 0
br label %388
386: ; preds = %381
%387 = load i8*, i8** %7
br label %388
388: ; preds = %386, %384
%389 = phi i8* [ %385, %384 ], [ %387, %386 ]
%390 = load i32*, i32** %9
%391 = call i64 @fputs(i8* %389, i32* %390)
%392 = load i64, i64* @EOF
%393 = icmp ne i64 %391, %392
br i1 %393, label %394, label %395
394: ; preds = %388
store i32 1, i32* %16
br label %395
395: ; preds = %394, %388
%396 = load i32*, i32** %9
%397 = call i32 @fclose(i32* %396)
%398 = load i32, i32* %16
%399 = icmp sgt i32 %398, 0
br i1 %399, label %400, label %425
400: ; preds = %395
%401 = load i32, i32* %17
%402 = icmp ne i32 %401, 0
br i1 %402, label %403, label %424
403: ; preds = %400
%404 = load i32, i32* %14
%405 = icmp ne i32 %404, 0
br i1 %405, label %406, label %423
406: ; preds = %403
%407 = load i8*, i8** %6
%408 = call i8* @strstr(i8* %407, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%409 = icmp eq i8* %408, null
br i1 %409, label %410, label %422
410: ; preds = %406
%411 = getelementptr inbounds [2048 x i8], [2048 x i8]* %30, i64 0, i64 0
%412 = load i8*, i8** %6
%413 = call i32 @strcpy(i8* %411, i8* %412)
%414 = getelementptr inbounds [2048 x i8], [2048 x i8]* %30, i64 0, i64 0
%415 = call i32 @strcat(i8* %414, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%416 = getelementptr inbounds [2048 x i8], [2048 x i8]* %30, i64 0, i64 0
%417 = call i8* @timestamp(i32 0, i32 0)
%418 = call i32 @strcat(i8* %416, i8* %417)
%419 = load i8*, i8** %5
%420 = getelementptr inbounds [2048 x i8], [2048 x i8]* %30, i64 0, i64 0
%421 = call i32 @rastwritefile(i8* %419, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %420, i32 1)
store i32 %421, i32* %16
br label %422
422: ; preds = %410, %406
br label %423
423: ; preds = %422, %403
br label %424
424: ; preds = %423, %400
br label %425
425: ; preds = %424, %395
br label %426
426: ; preds = %425, %380, %358, %164, %60, %48, %38
%427 = load i32, i32* %16
ret i32 %427
}

LLVM IR (-O2):
@.str = [2 x i8] c"<\00"
@.str.1 = [3 x i8] c"</\00"
@.str.2 = [2 x i8] c">\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c"w\00"
@EOF = global i64 0
@isnewfile = global i32 0
@status = global i32 0
define i32 @rastwritefile(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = alloca [65536 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [4096 x i8]
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%14 = icmp eq i8* %0, null
%15 = icmp eq i8* %2, null
%16 = or i1 %14, %15
br i1 %16, label %162, label %17
17: ; preds = %4
%18 = tail call i32 @strlen(i8* %0)
%19 = icmp slt i32 %18, 2
br i1 %19, label %162, label %20
20: ; preds = %17
%21 = load i8, i8* %2
%22 = icmp eq i8 %21, 0
br i1 %22, label %162, label %23
23: ; preds = %20
%24 = call i32 @strncpy(i8* %10, i8* %0, i32 1023)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1023
store i8 0, i8* %25
%26 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @rastopenfile to i32* (i8*, i8*, ...)*)(i8* %10, i8* null)
%27 = icmp eq i32* %26, null
%28 = icmp ne i32 %3, 0
%29 = and i1 %28, %27
br i1 %29, label %162, label %30
30: ; preds = %23
%31 = icmp eq i8* %1, null
br i1 %31, label %79, label %32
32: ; preds = %30
%33 = load i8, i8* %1
%34 = icmp eq i8 %33, 0
br i1 %34, label %79, label %35
35: ; preds = %32
%36 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @strcat(i8* %12, i8* %1)
%39 = call i32 @strcat(i8* %13, i8* %1)
%40 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = call i8* @strchr(i8* %12, i8 signext 32)
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %47
44: ; preds = %58, %35
%45 = call i8* @strchr(i8* %13, i8 signext 32)
%46 = icmp eq i8* %45, null
br i1 %46, label %75, label %61
47: ; preds = %35, %58
%48 = phi i8* [ %59, %58 ], [ %42, %35 ]
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %47
%52 = call i32 @strlen(i8* %48)
%53 = icmp slt i32 %52, 2
br i1 %53, label %54, label %55
54: ; preds = %51
store i8 0, i8* %48
br label %58
55: ; preds = %51
%56 = getelementptr inbounds i8, i8* %48, i64 1
%57 = call i32 @memmove(i8* %48, i8* %56, i32 %52)
br label %58
58: ; preds = %54, %55, %47
%59 = call i8* @strchr(i8* %12, i8 signext 32)
%60 = icmp eq i8* %59, null
br i1 %60, label %44, label %47
61: ; preds = %44, %72
%62 = phi i8* [ %73, %72 ], [ %45, %44 ]
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 0
br i1 %64, label %72, label %65
65: ; preds = %61
%66 = call i32 @strlen(i8* %62)
%67 = icmp slt i32 %66, 2
br i1 %67, label %68, label %69
68: ; preds = %65
store i8 0, i8* %62
br label %72
69: ; preds = %65
%70 = getelementptr inbounds i8, i8* %62, i64 1
%71 = call i32 @memmove(i8* %62, i8* %70, i32 %66)
br label %72
72: ; preds = %68, %69, %61
%73 = call i8* @strchr(i8* %13, i8 signext 32)
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %61
75: ; preds = %72, %44
store i8 0, i8* %11
br i1 %27, label %80, label %76
76: ; preds = %75
%77 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @rastreadfile to i32 (i8*, i32, i8*, i8*, ...)*)(i8* %10, i32 1, i8* null, i8* %11)
%78 = icmp slt i32 %77, 1
br i1 %78, label %162, label %80
79: ; preds = %32, %30
store i8 0, i8* %11
br label %151
80: ; preds = %76, %75
%81 = call i32 @strlen(i8* %12)
%82 = call i32 @strlen(i8* %13)
br i1 %27, label %116, label %83
83: ; preds = %80
%84 = call i8* @strstr(i8* %11, i8* %12)
%85 = call i8* @strstr(i8* %11, i8* %13)
%86 = icmp eq i8* %84, null
%87 = icmp eq i8* %85, null
br i1 %86, label %88, label %122
88: ; preds = %83
%89 = load i8, i8* %11
%90 = icmp eq i8 %89, 0
%91 = select i1 %87, i1 true, i1 %90
br i1 %91, label %116, label %92
92: ; preds = %88
%93 = sext i32 %82 to i64
%94 = getelementptr inbounds i8, i8* %85, i64 %93
%95 = load i8, i8* %94
%96 = icmp eq i8 %95, 0
br i1 %96, label %116, label %97
97: ; preds = %92
%98 = call i32 @strlen(i8* %11)
%99 = call i32 @strlen(i8* %94)
%100 = sub nsw i32 %98, %99
%101 = add i32 %100, -1000
%102 = icmp ult i32 %101, -999
%103 = load i8, i8* %11
%104 = icmp eq i8 %103, 0
%105 = select i1 %102, i1 true, i1 %104
br i1 %105, label %116, label %106
106: ; preds = %97
%107 = call i32 @strlen(i8* %11)
%108 = icmp slt i32 %100, %107
br i1 %108, label %110, label %109
109: ; preds = %106
store i8 0, i8* %11
br label %116
110: ; preds = %106
%111 = zext i32 %100 to i64
%112 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 %111
%113 = sub nsw i32 1, %100
%114 = add i32 %113, %107
%115 = call i32 @memmove(i8* %11, i8* %112, i32 %114)
br label %116
116: ; preds = %80, %97, %110, %109, %92, %88
%117 = call i32 @strlen(i8* %11)
%118 = call i32 @strcat(i8* %11, i8* %12)
%119 = call i32 @strcat(i8* %11, i8* %2)
%120 = call i32 @strcat(i8* %11, i8* %13)
%121 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %151
122: ; preds = %83
br i1 %87, label %123, label %128
123: ; preds = %122
%124 = sext i32 %81 to i64
%125 = getelementptr inbounds i8, i8* %84, i64 %124
store i8 0, i8* %125
%126 = call i32 @strcat(i8* %11, i8* %2)
%127 = call i32 @strcat(i8* %11, i8* %13)
br label %151
128: ; preds = %122
%129 = ptrtoint i8* %85 to i64
%130 = ptrtoint i8* %84 to i64
%131 = sub i64 %129, %130
%132 = trunc i64 %131 to i32
%133 = sub nsw i32 %132, %81
%134 = icmp sgt i32 %133, -1
br i1 %134, label %135, label %139
135: ; preds = %128
%136 = sext i32 %81 to i64
%137 = getelementptr inbounds i8, i8* %84, i64 %136
%138 = call i8* (i32, i8*, i8*, ...) bitcast (i8* (...)* @strchange to i8* (i32, i8*, i8*, ...)*)(i32 %133, i8* %137, i8* %2)
br label %151
139: ; preds = %128
%140 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%141 = sub i64 %130, %129
%142 = trunc i64 %141 to i32
%143 = add nsw i32 %81, %142
%144 = icmp slt i32 %143, 1
br i1 %144, label %150, label %145
145: ; preds = %139
%146 = call i32 @strcpy(i8* %140, i8* %12)
%147 = call i32 @strcat(i8* %140, i8* %2)
%148 = call i32 @strcat(i8* %140, i8* %13)
%149 = call i8* (i32, i8*, i8*, ...) bitcast (i8* (...)* @strchange to i8* (i32, i8*, i8*, ...)*)(i32 %143, i8* %85, i8* %140)
br label %151
150: ; preds = %139
br label %162
151: ; preds = %116, %135, %123, %145, %79
%152 = phi i1 [ false, %79 ], [ true, %145 ], [ true, %123 ], [ true, %135 ], [ true, %116 ]
%153 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @rastopenfile to i32* (i8*, i8*, ...)*)(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%154 = icmp eq i32* %153, null
br i1 %154, label %162, label %155
155: ; preds = %151
%156 = select i1 %152, i8* %11, i8* %2
%157 = call i64 @fputs(i8* %156, i32* %153)
%158 = load i64, i64* @EOF
%159 = icmp ne i64 %157, %158
%160 = zext i1 %159 to i32
%161 = call i32 @fclose(i32* %153)
br label %162
162: ; preds = %150, %23, %4, %20, %17, %76, %151, %155
%163 = phi i32 [ 0, %4 ], [ 0, %17 ], [ 0, %20 ], [ 0, %76 ], [ 0, %150 ], [ 0, %151 ], [ %160, %155 ], [ 0, %23 ]
ret i32 %163
}