#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 int ssize_t;
typedef int /*<<< orphan*/ offset;

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ERANGE;
size_t const SSIZE_MAX;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ formatstring_error(char const *, int, char *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t const);
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
ssize_t formatstring(char *buffer, size_t buffer_size, const char *format,
                     const char *filename, size_t index, size_t offset,
                     size_t size, const char *ext) {
  assert(buffer_size == 0 || buffer != NULL);
  assert(format != NULL);
  assert(filename != NULL);
  assert(ext != NULL);
  const char *fmtptr = format;
  char *bufptr = buffer_size == 0 ? NULL : buffer;
  const char *endptr = bufptr + buffer_size;
  const size_t filename_len = strlen(filename);
  const size_t ext_len = strlen(ext);
  while (*fmtptr) {
    const char *nextptr = fmtptr;
    while (*nextptr && *nextptr != '{' && *nextptr != '}') {
      ++nextptr;
    }
    if (nextptr != fmtptr) {
      const size_t len = nextptr - fmtptr;
      {
        const size_t COPY_STR_rem = endptr > bufptr ? endptr - bufptr : 0;
        const size_t COPY_STR_cpylen =
            (((len)) < (COPY_STR_rem) ? ((len)) : (COPY_STR_rem));
        memcpy(bufptr, (fmtptr), COPY_STR_cpylen);
        bufptr += (len);
      };
      fmtptr = nextptr;
    }
    if (*fmtptr == '}') {
      ++fmtptr;
      if (*fmtptr == '}') {
        if (bufptr < endptr) {
          *bufptr = ('}');
        }
        ++bufptr;
        ;
        ++fmtptr;
      } else {
        formatstring_error(format, fmtptr - format, "expected '}'");
        errno = EINVAL;
        return -1;
      }
    } else if (*fmtptr == '{') {
      ++fmtptr;
      if (*fmtptr == '{') {
        if (bufptr < endptr) {
          *bufptr = ('{');
        }
        ++bufptr;
        ;
        ++fmtptr;
      } else {
        nextptr = fmtptr;
        while (*nextptr && *nextptr != '}') {
          ++nextptr;
        }
        if (fmtptr == nextptr) {
          formatstring_error(format, fmtptr - format,
                             "expected a variable name");
          errno = EINVAL;
          return -1;
        }
        const size_t len = nextptr - fmtptr;
        if ((strncmp((fmtptr), ("filename"),
                     ((sizeof("filename")) < (len) ? (sizeof("filename"))
                                                   : (len))) == 0)) {
          {
            const size_t COPY_STR_rem = endptr > bufptr ? endptr - bufptr : 0;
            const size_t COPY_STR_cpylen =
                (((filename_len)) < (COPY_STR_rem) ? ((filename_len))
                                                   : (COPY_STR_rem));
            memcpy(bufptr, (filename), COPY_STR_cpylen);
            bufptr += (filename_len);
          };
        } else if ((strncmp((fmtptr), ("ext"),
                            ((sizeof("ext")) < (len) ? (sizeof("ext"))
                                                     : (len))) == 0)) {
          {
            const size_t COPY_STR_rem = endptr > bufptr ? endptr - bufptr : 0;
            const size_t COPY_STR_cpylen =
                (((ext_len)) < (COPY_STR_rem) ? ((ext_len)) : (COPY_STR_rem));
            memcpy(bufptr, (ext), COPY_STR_cpylen);
            bufptr += (ext_len);
          };
        } else if ((strncmp((fmtptr), ("offset"),
                            ((sizeof("offset")) < (len) ? (sizeof("offset"))
                                                        : (len))) == 0)) {
          {
            size_t WRITE_HEX_size = sizeof(offset);
            size_t WRITE_HEX_rem = (offset);
            while (WRITE_HEX_size) {
              --WRITE_HEX_size;
              char *WRITE_HEX_outptr = bufptr + 2 * WRITE_HEX_size;
              if (WRITE_HEX_outptr < endptr) {
                *WRITE_HEX_outptr =
                    "0123456789ABCDEF"[(WRITE_HEX_rem >> 4) & 0xF];
              }
              ++WRITE_HEX_outptr;
              if (WRITE_HEX_outptr < endptr) {
                *WRITE_HEX_outptr = "0123456789ABCDEF"[WRITE_HEX_rem & 0xF];
              }
              WRITE_HEX_rem >>= 8;
            }
            bufptr += 2 * sizeof(offset);
          };
        } else if ((strncmp((fmtptr), ("index"),
                            ((sizeof("index")) < (len) ? (sizeof("index"))
                                                       : (len))) == 0)) {
          if ((index) == 0) {
            if (bufptr < endptr) {
              *bufptr = ('0');
            }
            ++bufptr;
            ;
          } else {
            size_t WRITE_DEC_isize = 0;
            size_t WRITE_DEC_n = (index);
            while (WRITE_DEC_n) {
              WRITE_DEC_n /= 10;
              ++WRITE_DEC_isize;
            }
            WRITE_DEC_n = (index);
            size_t WRITE_DEC_index = WRITE_DEC_isize;
            while (WRITE_DEC_n) {
              --WRITE_DEC_index;
              const size_t WRITE_DEC_v = WRITE_DEC_n % 10;
              char *WRITE_DEC_outptr = bufptr + WRITE_DEC_index;
              if (WRITE_DEC_outptr < endptr) {
                *WRITE_DEC_outptr = '0' + WRITE_DEC_v;
              }
              WRITE_DEC_n /= 10;
            }
            bufptr += WRITE_DEC_isize;
          };
        } else if ((strncmp((fmtptr), ("size"),
                            ((sizeof("size")) < (len) ? (sizeof("size"))
                                                      : (len))) == 0)) {
          if ((size) == 0) {
            if (bufptr < endptr) {
              *bufptr = ('0');
            }
            ++bufptr;
            ;
          } else {
            size_t WRITE_DEC_isize = 0;
            size_t WRITE_DEC_n = (size);
            while (WRITE_DEC_n) {
              WRITE_DEC_n /= 10;
              ++WRITE_DEC_isize;
            }
            WRITE_DEC_n = (size);
            size_t WRITE_DEC_index = WRITE_DEC_isize;
            while (WRITE_DEC_n) {
              --WRITE_DEC_index;
              const size_t WRITE_DEC_v = WRITE_DEC_n % 10;
              char *WRITE_DEC_outptr = bufptr + WRITE_DEC_index;
              if (WRITE_DEC_outptr < endptr) {
                *WRITE_DEC_outptr = '0' + WRITE_DEC_v;
              }
              WRITE_DEC_n /= 10;
            }
            bufptr += WRITE_DEC_isize;
          };
        } else {
          formatstring_error(format, fmtptr - format, "unknown variable name");
          errno = EINVAL;
          return -1;
        }
        fmtptr = nextptr + 1;
      }
    }
  }
  if (bufptr < endptr) {
    *bufptr = 0;
  } else if (buffer_size > 0) {
    buffer[buffer_size - 1] = 0;
  }
  ++bufptr;
  const size_t strsize = bufptr - buffer;
  if (strsize > SSIZE_MAX) {
    formatstring_error(format, fmtptr - format, "string too long");
    errno = ERANGE;
    return -1;
  }
  return (ssize_t)strsize;
}


x86 assembly (clang, -O0):
<formatstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    $0x1,%al
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x119(%rbp)
je     119c <formatstring+0x4c>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1203 <formatstring+0xb3>
xor    %eax,%eax
mov    %rax,-0x128(%rbp)
jmp    120e <formatstring+0xbe>
mov    -0x10(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x58(%rbp)
mov    0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rax
cmpb   $0x0,(%rax)
je     1c20 <formatstring+0xad0>
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x129(%rbp)
je     1297 <formatstring+0x147>
mov    -0x68(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x7b,%ecx
mov    %al,-0x129(%rbp)
je     1297 <formatstring+0x147>
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
setne  %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    12aa <formatstring+0x15a>
jmp    12bb <formatstring+0x16b>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1254 <formatstring+0x104>
mov    -0x68(%rbp),%rax
cmp    -0x40(%rbp),%rax
je     136f <formatstring+0x21f>
mov    -0x68(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jbe    12fd <formatstring+0x1ad>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x138(%rbp)
jmp    130b <formatstring+0x1bb>
xor    %eax,%eax
mov    %rax,-0x138(%rbp)
jmp    130b <formatstring+0x1bb>
mov    -0x138(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
cmp    -0x78(%rbp),%rax
jae    1334 <formatstring+0x1e4>
mov    -0x70(%rbp),%rax
mov    %rax,-0x140(%rbp)
jmp    133f <formatstring+0x1ef>
mov    -0x78(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x140(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x80(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x70(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
jne    140d <formatstring+0x2bd>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
jne    13cd <formatstring+0x27d>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    13b0 <formatstring+0x260>
mov    -0x48(%rbp),%rax
movb   $0x7d,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1408 <formatstring+0x2b8>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xc1b(%rip),%rdx
call   1070 <formatstring_error@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%ecx
mov    0x2bd6(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1cd4 <formatstring+0xb84>
jmp    1c1b <formatstring+0xacb>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
jne    1c16 <formatstring+0xac6>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
jne    146b <formatstring+0x31b>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    144e <formatstring+0x2fe>
mov    -0x48(%rbp),%rax
movb   $0x7b,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1c11 <formatstring+0xac1>
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x141(%rbp)
je     149e <formatstring+0x34e>
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
setne  %al
mov    %al,-0x141(%rbp)
mov    -0x141(%rbp),%al
test   $0x1,%al
jne    14b1 <formatstring+0x361>
jmp    14c2 <formatstring+0x372>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1473 <formatstring+0x323>
mov    -0x40(%rbp),%rax
cmp    -0x68(%rbp),%rax
jne    150b <formatstring+0x3bb>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xb25(%rip),%rdx
call   1070 <formatstring_error@plt>
mov    0x2ad4(%rip),%rax
mov    (%rax),%ecx
mov    0x2ad3(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1cd4 <formatstring+0xb84>
mov    -0x68(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x88(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    $0x9,%eax
cmp    -0x88(%rbp),%rax
jae    154b <formatstring+0x3fb>
mov    $0x9,%eax
mov    %rax,-0x158(%rbp)
jmp    1559 <formatstring+0x409>
mov    -0x88(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x150(%rbp),%rdi
mov    -0x158(%rbp),%rax
mov    %eax,%edx
lea    0xab6(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1622 <formatstring+0x4d2>
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jbe    15a4 <formatstring+0x454>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x160(%rbp)
jmp    15b2 <formatstring+0x462>
xor    %eax,%eax
mov    %rax,-0x160(%rbp)
jmp    15b2 <formatstring+0x462>
mov    -0x160(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x90(%rbp),%rax
jae    15e1 <formatstring+0x491>
mov    -0x58(%rbp),%rax
mov    %rax,-0x168(%rbp)
jmp    15ef <formatstring+0x49f>
mov    -0x90(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x168(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x98(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x58(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1c05 <formatstring+0xab5>
mov    -0x40(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    $0x4,%eax
cmp    -0x88(%rbp),%rax
jae    1650 <formatstring+0x500>
mov    $0x4,%eax
mov    %rax,-0x178(%rbp)
jmp    165e <formatstring+0x50e>
mov    -0x88(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x170(%rbp),%rdi
mov    -0x178(%rbp),%rax
mov    %eax,%edx
lea    0x9ba(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1727 <formatstring+0x5d7>
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jbe    16a9 <formatstring+0x559>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x180(%rbp)
jmp    16b7 <formatstring+0x567>
xor    %eax,%eax
mov    %rax,-0x180(%rbp)
jmp    16b7 <formatstring+0x567>
mov    -0x180(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x60(%rbp),%rax
cmp    -0xa0(%rbp),%rax
jae    16e6 <formatstring+0x596>
mov    -0x60(%rbp),%rax
mov    %rax,-0x188(%rbp)
jmp    16f4 <formatstring+0x5a4>
mov    -0xa0(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x188(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x48(%rbp),%rdi
mov    0x18(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x60(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1c00 <formatstring+0xab0>
mov    -0x40(%rbp),%rax
mov    %rax,-0x190(%rbp)
mov    $0x7,%eax
cmp    -0x88(%rbp),%rax
jae    1755 <formatstring+0x605>
mov    $0x7,%eax
mov    %rax,-0x198(%rbp)
jmp    1763 <formatstring+0x613>
mov    -0x88(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x190(%rbp),%rdi
mov    -0x198(%rbp),%rax
mov    %eax,%edx
lea    0x8b9(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1874 <formatstring+0x724>
movq   $0x8,-0xb0(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     1863 <formatstring+0x713>
mov    -0xb0(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0xb0(%rbp)
mov    -0x48(%rbp),%rax
mov    -0xb0(%rbp),%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0xc0(%rbp)
mov    -0xc0(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    180b <formatstring+0x6bb>
mov    -0xb8(%rbp),%rcx
shr    $0x4,%rcx
and    $0xf,%rcx
lea    0x83b(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0xc0(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xc0(%rbp)
mov    -0xc0(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    184c <formatstring+0x6fc>
mov    -0xb8(%rbp),%rcx
and    $0xf,%rcx
lea    0x7fa(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0xc0(%rbp),%rax
mov    %cl,(%rax)
mov    -0xb8(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0xb8(%rbp)
jmp    179f <formatstring+0x64f>
mov    -0x48(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x48(%rbp)
jmp    1bfb <formatstring+0xaab>
mov    -0x40(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    $0x6,%eax
cmp    -0x88(%rbp),%rax
jae    18a2 <formatstring+0x752>
mov    $0x6,%eax
mov    %rax,-0x1a8(%rbp)
jmp    18b0 <formatstring+0x760>
mov    -0x88(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x1a0(%rbp),%rdi
mov    -0x1a8(%rbp),%rax
mov    %eax,%edx
lea    0x784(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1a15 <formatstring+0x8c5>
cmpq   $0x0,-0x30(%rbp)
jne    1907 <formatstring+0x7b7>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    18f6 <formatstring+0x7a6>
mov    -0x48(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1a10 <formatstring+0x8c0>
movq   $0x0,-0xc8(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xd0(%rbp)
cmpq   $0x0,-0xd0(%rbp)
je     195a <formatstring+0x80a>
mov    -0xd0(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0xd0(%rbp)
mov    -0xc8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xc8(%rbp)
jmp    191d <formatstring+0x7cd>
mov    -0x30(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0xc8(%rbp),%rax
mov    %rax,-0xd8(%rbp)
cmpq   $0x0,-0xd0(%rbp)
je     1a01 <formatstring+0x8b1>
mov    -0xd8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0xd8(%rbp)
mov    -0xd0(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0xe0(%rbp)
mov    -0x48(%rbp),%rax
add    -0xd8(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    19e4 <formatstring+0x894>
mov    -0xe0(%rbp),%rax
add    $0x30,%rax
mov    %al,%cl
mov    -0xe8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xd0(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0xd0(%rbp)
jmp    1973 <formatstring+0x823>
mov    -0xc8(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1bf6 <formatstring+0xaa6>
mov    -0x40(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    $0x5,%eax
cmp    -0x88(%rbp),%rax
jae    1a43 <formatstring+0x8f3>
mov    $0x5,%eax
mov    %rax,-0x1b8(%rbp)
jmp    1a51 <formatstring+0x901>
mov    -0x88(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
mov    -0x1b0(%rbp),%rdi
mov    -0x1b8(%rbp),%rax
mov    %eax,%edx
lea    0x5e9(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1bb6 <formatstring+0xa66>
cmpq   $0x0,0x10(%rbp)
jne    1aa8 <formatstring+0x958>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    1a97 <formatstring+0x947>
mov    -0x48(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1bb1 <formatstring+0xa61>
movq   $0x0,-0xf0(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0xf8(%rbp)
cmpq   $0x0,-0xf8(%rbp)
je     1afb <formatstring+0x9ab>
mov    -0xf8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0xf8(%rbp)
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
jmp    1abe <formatstring+0x96e>
mov    0x10(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0xf0(%rbp),%rax
mov    %rax,-0x100(%rbp)
cmpq   $0x0,-0xf8(%rbp)
je     1ba2 <formatstring+0xa52>
mov    -0x100(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x100(%rbp)
mov    -0xf8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x108(%rbp)
mov    -0x48(%rbp),%rax
add    -0x100(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x110(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    1b85 <formatstring+0xa35>
mov    -0x108(%rbp),%rax
add    $0x30,%rax
mov    %al,%cl
mov    -0x110(%rbp),%rax
mov    %cl,(%rax)
mov    -0xf8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0xf8(%rbp)
jmp    1b14 <formatstring+0x9c4>
mov    -0xf0(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1bf1 <formatstring+0xaa1>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0x488(%rip),%rdx
call   1070 <formatstring_error@plt>
mov    0x23ee(%rip),%rax
mov    (%rax),%ecx
mov    0x23ed(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1cd4 <formatstring+0xb84>
jmp    1bf6 <formatstring+0xaa6>
jmp    1bfb <formatstring+0xaab>
jmp    1c00 <formatstring+0xab0>
jmp    1c05 <formatstring+0xab5>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1c16 <formatstring+0xac6>
jmp    1c1b <formatstring+0xacb>
jmp    123f <formatstring+0xef>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    1c3a <formatstring+0xaea>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
jmp    1c5a <formatstring+0xb0a>
cmpq   $0x0,-0x18(%rbp)
jbe    1c55 <formatstring+0xb05>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1c5a <formatstring+0xb0a>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
mov    0x2362(%rip),%rcx
cmp    (%rcx),%rax
jbe    1cca <formatstring+0xb7a>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0x3c5(%rip),%rdx
call   1070 <formatstring_error@plt>
mov    0x232d(%rip),%rax
mov    (%rax),%ecx
mov    0x2314(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1cd4 <formatstring+0xb84>
mov    -0x118(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formatstring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r9,%r14
mov    %r8,(%rsp)
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
sete   %cl
mov    %rdi,0xa0(%rsp)
cmove  %rsi,%rbx
or     %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r13,%r13
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,0xf8(%rsp)
setne  %dil
call   1050 <assert@plt>
mov    %rbp,0x88(%rsp)
lea    (%rbx,%rbp,1),%r12
mov    %r13,0xb0(%rsp)
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rax,0xa8(%rsp)
mov    0xf8(%rsp),%rdi
call   1040 <strlen@plt>
mov    %rax,0x90(%rsp)
mov    (%r15),%al
test   %al,%al
mov    %r15,0x98(%rsp)
je     1781 <formatstring+0x631>
mov    %r14d,%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
mov    %rcx,0x78(%rsp)
mov    %r14d,%ecx
and    $0xf,%ecx
mov    %rcx,0x70(%rsp)
mov    %r14d,%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
mov    %rcx,0x68(%rsp)
mov    %r14d,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
mov    %rcx,0x60(%rsp)
mov    %r14d,%ecx
shr    $0x10,%ecx
and    $0xf,%ecx
mov    %rcx,0x58(%rsp)
mov    %r14d,%ecx
shr    $0x14,%ecx
and    $0xf,%ecx
mov    %rcx,0x50(%rsp)
mov    %r14d,%ecx
shr    $0x18,%ecx
and    $0xf,%ecx
mov    %rcx,0x48(%rsp)
mov    %r14d,%ecx
shr    $0x1c,%ecx
mov    %rcx,0x40(%rsp)
mov    %r14,%rcx
shr    $0x20,%rcx
mov    %r14,%rdx
shr    $0x24,%rdx
and    $0xf,%edx
mov    %rdx,0x30(%rsp)
and    $0xf,%ecx
mov    %rcx,0x38(%rsp)
mov    %r14,%rcx
shr    $0x28,%rcx
mov    %r14,%rdx
shr    $0x2c,%rdx
and    $0xf,%edx
mov    %rdx,0x20(%rsp)
and    $0xf,%ecx
mov    %rcx,0x28(%rsp)
mov    %r14,%rcx
shr    $0x30,%rcx
mov    %r14,%rdx
shr    $0x34,%rdx
and    $0xf,%edx
mov    %rdx,0x10(%rsp)
and    $0xf,%ecx
mov    %rcx,0x18(%rsp)
mov    %r14,%rcx
shr    $0x38,%rcx
shr    $0x3c,%r14
mov    %r14,0x80(%rsp)
and    $0xf,%ecx
mov    %rcx,0x8(%rsp)
xor    %r14d,%r14d
mov    %r15,%rsi
jmp    1316 <formatstring+0x1c6>
nopl   0x0(%rax)
add    $0x1,%rbx
add    $0x2,%r15
mov    (%r15),%al
mov    %r15,%rsi
test   %al,%al
je     1781 <formatstring+0x631>
xor    %ebp,%ebp
mov    %eax,%ecx
test   %cl,%cl
je     133b <formatstring+0x1eb>
xchg   %ax,%ax
cmp    $0x7b,%cl
je     133b <formatstring+0x1eb>
cmp    $0x7d,%cl
je     133b <formatstring+0x1eb>
movzbl 0x1(%r15),%ecx
add    $0x1,%r15
add    $0xffffffffffffffff,%rbp
test   %cl,%cl
jne    1320 <formatstring+0x1d0>
test   %rbp,%rbp
je     1390 <formatstring+0x240>
mov    %rbp,%rax
neg    %rax
mov    %r12,%rdx
sub    %rbx,%rdx
cmovbe %r14,%rdx
cmp    %rdx,%rax
cmovb  %rax,%rdx
mov    %rbx,%rdi
call   1060 <memcpy@plt>
sub    %rbp,%rbx
mov    (%r15),%al
cmp    $0x7b,%al
je     1397 <formatstring+0x247>
cmp    $0x7d,%al
jne    1308 <formatstring+0x1b8>
cmpb   $0x7d,0x1(%r15)
jne    17c5 <formatstring+0x675>
cmp    %r12,%rbx
jae    1300 <formatstring+0x1b0>
movb   $0x7d,(%rbx)
jmp    1300 <formatstring+0x1b0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rsi,%r15
cmp    $0x7b,%al
jne    1369 <formatstring+0x219>
mov    0x1(%r15),%al
cmp    $0x7b,%al
jne    13b0 <formatstring+0x260>
cmp    %r12,%rbx
jae    1300 <formatstring+0x1b0>
movb   $0x7b,(%rbx)
jmp    1300 <formatstring+0x1b0>
lea    0x1(%r15),%r14
xor    %r13d,%r13d
test   %al,%al
je     13d2 <formatstring+0x282>
nopl   0x0(%rax,%rax,1)
cmp    $0x7d,%al
je     13d2 <formatstring+0x282>
movzbl 0x2(%r15,%r13,1),%eax
add    $0x1,%r13
test   %al,%al
jne    13c0 <formatstring+0x270>
test   %r13,%r13
je     17d9 <formatstring+0x689>
cmp    $0x9,%r13
mov    $0x9,%edx
cmovb  %r13d,%edx
mov    %r14,%rdi
lea    0xc34(%rip),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1525 <formatstring+0x3d5>
cmp    $0x4,%r13
mov    $0x4,%edx
cmovb  %r13d,%edx
mov    %r14,%rdi
lea    0xc18(%rip),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1551 <formatstring+0x401>
cmp    $0x7,%r13
mov    $0x7,%edx
cmovb  %r13d,%edx
mov    %r14,%rdi
lea    0xbf7(%rip),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1592 <formatstring+0x442>
cmp    $0x6,%r13
mov    $0x6,%edx
cmovb  %r13d,%edx
mov    %r14,%rdi
lea    0xbea(%rip),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     16e3 <formatstring+0x593>
cmp    $0x5,%r13
mov    $0x5,%edx
cmovb  %r13d,%edx
mov    %r14,%rdi
lea    0xbcb(%rip),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
jne    181f <formatstring+0x6cf>
mov    0xf0(%rsp),%rcx
test   %rcx,%rcx
je     1765 <formatstring+0x615>
mov    %rbx,%rax
xor    %esi,%esi
xor    %r14d,%r14d
movabs $0xcccccccccccccccd,%r8
cc cc cc
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %rcx,%rax
mul    %r8
shr    $0x3,%rdx
add    $0x1,%rsi
lea    0x1(%rdi),%rax
cmp    $0x9,%rcx
mov    %rdx,%rcx
ja     14c0 <formatstring+0x370>
mov    0xf0(%rsp),%rbp
jmp    1501 <formatstring+0x3b1>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rdi
cmp    $0x9,%rbp
mov    %rdx,%rbp
jbe    1583 <formatstring+0x433>
mov    %rbp,%rax
mul    %r8
shr    $0x3,%rdx
cmp    %r12,%rdi
jae    14f0 <formatstring+0x3a0>
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %rbp,%rcx
sub    %rax,%rcx
or     $0x30,%cl
mov    %cl,(%rdi)
jmp    14f0 <formatstring+0x3a0>
mov    %r12,%rdx
sub    %rbx,%rdx
mov    $0x0,%r14d
cmovbe %r14,%rdx
mov    0xa8(%rsp),%rbp
cmp    %rdx,%rbp
cmovb  %rbp,%rdx
mov    %rbx,%rdi
mov    0xb0(%rsp),%rsi
jmp    157b <formatstring+0x42b>
mov    %r12,%rdx
sub    %rbx,%rdx
mov    $0x0,%r14d
cmovbe %r14,%rdx
mov    0x90(%rsp),%rbp
cmp    %rdx,%rbp
cmovb  %rbp,%rdx
mov    %rbx,%rdi
mov    0xf8(%rsp),%rsi
call   1060 <memcpy@plt>
mov    %rbp,%rsi
add    %rsi,%rbx
add    %r13,%r15
add    $0x2,%r15
jmp    1308 <formatstring+0x1b8>
lea    0xe(%rbx),%rax
cmp    %r12,%rax
lea    0xa9a(%rip),%rsi
jae    15ac <formatstring+0x45c>
mov    0x78(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0xf(%rbx),%rax
cmp    %r12,%rax
mov    0x80(%rsp),%rdx
mov    $0x0,%r14d
jae    15cd <formatstring+0x47d>
mov    0x70(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0xc(%rbx),%rax
cmp    %r12,%rax
jae    15e0 <formatstring+0x490>
mov    0x60(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0xd(%rbx),%rax
cmp    %r12,%rax
jae    15f3 <formatstring+0x4a3>
mov    0x68(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0xa(%rbx),%rax
cmp    %r12,%rax
jae    1606 <formatstring+0x4b6>
mov    0x50(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0xb(%rbx),%rax
cmp    %r12,%rax
jae    1619 <formatstring+0x4c9>
mov    0x58(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x8(%rbx),%rax
cmp    %r12,%rax
jae    162c <formatstring+0x4dc>
mov    0x40(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x9(%rbx),%rax
cmp    %r12,%rax
jae    163f <formatstring+0x4ef>
mov    0x48(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x6(%rbx),%rax
cmp    %r12,%rax
jae    1652 <formatstring+0x502>
mov    0x30(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x7(%rbx),%rax
cmp    %r12,%rax
jae    1665 <formatstring+0x515>
mov    0x38(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x4(%rbx),%rax
cmp    %r12,%rax
jae    1678 <formatstring+0x528>
mov    0x20(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x5(%rbx),%rax
cmp    %r12,%rax
jae    168b <formatstring+0x53b>
mov    0x28(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x2(%rbx),%rax
cmp    %r12,%rax
jae    169e <formatstring+0x54e>
mov    0x10(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
lea    0x3(%rbx),%rax
cmp    %r12,%rax
jae    16b1 <formatstring+0x561>
mov    0x18(%rsp),%rcx
mov    (%rcx,%rsi,1),%cl
mov    %cl,(%rax)
cmp    %r12,%rbx
jae    16bb <formatstring+0x56b>
mov    (%rdx,%rsi,1),%al
mov    %al,(%rbx)
lea    0x1(%rbx),%rax
mov    $0x10,%esi
cmp    %r12,%rax
jae    1583 <formatstring+0x433>
mov    0x8(%rsp),%rcx
lea    0x961(%rip),%rdx
mov    (%rcx,%rdx,1),%cl
mov    %cl,(%rax)
jmp    1583 <formatstring+0x433>
mov    (%rsp),%rcx
test   %rcx,%rcx
je     1765 <formatstring+0x615>
mov    %rbx,%rax
xor    %esi,%esi
xor    %r14d,%r14d
movabs $0xcccccccccccccccd,%r8
cc cc cc
xchg   %ax,%ax
mov    %rax,%rdi
mov    %rcx,%rax
mul    %r8
shr    $0x3,%rdx
add    $0x1,%rsi
lea    0x1(%rdi),%rax
cmp    $0x9,%rcx
mov    %rdx,%rcx
ja     1700 <formatstring+0x5b0>
mov    (%rsp),%rbp
jmp    1741 <formatstring+0x5f1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffffffffffff,%rdi
cmp    $0xa,%rbp
mov    %rdx,%rbp
jb     1583 <formatstring+0x433>
mov    %rbp,%rax
mul    %r8
shr    $0x3,%rdx
cmp    %r12,%rdi
jae    1730 <formatstring+0x5e0>
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %rbp,%rcx
sub    %rax,%rcx
or     $0x30,%cl
mov    %cl,(%rdi)
jmp    1730 <formatstring+0x5e0>
mov    $0x1,%esi
cmp    %r12,%rbx
mov    $0x0,%r14d
jae    1583 <formatstring+0x433>
movb   $0x30,(%rbx)
jmp    1583 <formatstring+0x433>
mov    %rbx,%rax
cmp    %r12,%rbx
mov    0xa0(%rsp),%rcx
jb     17a5 <formatstring+0x655>
mov    0x88(%rsp),%rax
test   %rax,%rax
je     17a8 <formatstring+0x658>
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
movb   $0x0,(%rax)
add    $0x1,%rbx
cmp    %rcx,%rbx
je     17c1 <formatstring+0x671>
mov    0x2830(%rip),%rbx
lea    0x8ad(%rip),%rdx
jmp    17ea <formatstring+0x69a>
xor    %eax,%eax
jmp    180d <formatstring+0x6bd>
add    $0x1,%r15
lea    0x830(%rip),%rdx
mov    0x27f9(%rip),%rbx
jmp    17ea <formatstring+0x69a>
mov    %r14,%r15
mov    0x27ed(%rip),%rbx
lea    0x823(%rip),%rdx
mov    0x98(%rsp),%rdi
sub    %edi,%r15d
mov    %r15d,%esi
call   1070 <formatstring_error@plt>
mov    (%rbx),%eax
mov    0x27d2(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%r15
lea    0x82d(%rip),%rdx
jmp    17d0 <formatstring+0x680>

LLVM IR (-O0):
@.str = [13 x i8] c"expected '}'\00"
@EINVAL = global i32 0
@errno = global i32 0
@.str.1 = [25 x i8] c"expected a variable name\00"
@.str.2 = [9 x i8] c"filename\00"
@.str.3 = [4 x i8] c"ext\00"
@.str.4 = [7 x i8] c"offset\00"
@.str.5 = [17 x i8] c"0123456789ABCDEF\00"
@.str.6 = [6 x i8] c"index\00"
@.str.7 = [5 x i8] c"size\00"
@.str.8 = [22 x i8] c"unknown variable name\00"
@SSIZE_MAX = constant i64 0
@.str.9 = [16 x i8] c"string too long\00"
@ERANGE = global i32 0
define i32 @formatstring(i8* %0, i64 %1, i8* %2, i8* %3, i64 %4, i64 %5, i64 %6, i8* %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i64
%23 = alloca i8*
%24 = alloca i64
%25 = alloca i64
%26 = alloca i64
%27 = alloca i64
%28 = alloca i64
%29 = alloca i64
%30 = alloca i64
%31 = alloca i64
%32 = alloca i64
%33 = alloca i64
%34 = alloca i8*
%35 = alloca i64
%36 = alloca i64
%37 = alloca i64
%38 = alloca i64
%39 = alloca i8*
%40 = alloca i64
%41 = alloca i64
%42 = alloca i64
%43 = alloca i64
%44 = alloca i8*
%45 = alloca i64
store i8* %0, i8** %10
store i64 %1, i64* %11
store i8* %2, i8** %12
store i8* %3, i8** %13
store i64 %4, i64* %14
store i64 %5, i64* %15
store i64 %6, i64* %16
store i8* %7, i8** %17
%46 = load i64, i64* %11
%47 = icmp eq i64 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %8
%49 = load i8*, i8** %10
%50 = icmp ne i8* %49, null
br label %51
51: ; preds = %48, %8
%52 = phi i1 [ true, %8 ], [ %50, %48 ]
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i8*, i8** %12
%56 = icmp ne i8* %55, null
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i8*, i8** %13
%60 = icmp ne i8* %59, null
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i8*, i8** %17
%64 = icmp ne i8* %63, null
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = load i8*, i8** %12
store i8* %67, i8** %18
%68 = load i64, i64* %11
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %51
br label %73
71: ; preds = %51
%72 = load i8*, i8** %10
br label %73
73: ; preds = %71, %70
%74 = phi i8* [ null, %70 ], [ %72, %71 ]
store i8* %74, i8** %19
%75 = load i8*, i8** %19
%76 = load i64, i64* %11
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8* %77, i8** %20
%78 = load i8*, i8** %13
%79 = call i64 @strlen(i8* %78)
store i64 %79, i64* %21
%80 = load i8*, i8** %17
%81 = call i64 @strlen(i8* %80)
store i64 %81, i64* %22
br label %82
82: ; preds = %521, %73
%83 = load i8*, i8** %18
%84 = load i8, i8* %83
%85 = icmp ne i8 %84, 0
br i1 %85, label %86, label %522
86: ; preds = %82
%87 = load i8*, i8** %18
store i8* %87, i8** %23
br label %88
88: ; preds = %105, %86
%89 = load i8*, i8** %23
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %103
93: ; preds = %88
%94 = load i8*, i8** %23
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp ne i32 %96, 123
br i1 %97, label %98, label %103
98: ; preds = %93
%99 = load i8*, i8** %23
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp ne i32 %101, 125
br label %103
103: ; preds = %98, %93, %88
%104 = phi i1 [ false, %93 ], [ false, %88 ], [ %102, %98 ]
br i1 %104, label %105, label %108
105: ; preds = %103
%106 = load i8*, i8** %23
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %23
br label %88
108: ; preds = %103
%109 = load i8*, i8** %23
%110 = load i8*, i8** %18
%111 = icmp ne i8* %109, %110
br i1 %111, label %112, label %147
112: ; preds = %108
%113 = load i8*, i8** %23
%114 = load i8*, i8** %18
%115 = ptrtoint i8* %113 to i64
%116 = ptrtoint i8* %114 to i64
%117 = sub i64 %115, %116
store i64 %117, i64* %24
%118 = load i8*, i8** %20
%119 = load i8*, i8** %19
%120 = icmp ugt i8* %118, %119
br i1 %120, label %121, label %127
121: ; preds = %112
%122 = load i8*, i8** %20
%123 = load i8*, i8** %19
%124 = ptrtoint i8* %122 to i64
%125 = ptrtoint i8* %123 to i64
%126 = sub i64 %124, %125
br label %128
127: ; preds = %112
br label %128
128: ; preds = %127, %121
%129 = phi i64 [ %126, %121 ], [ 0, %127 ]
store i64 %129, i64* %25
%130 = load i64, i64* %24
%131 = load i64, i64* %25
%132 = icmp ult i64 %130, %131
br i1 %132, label %133, label %135
133: ; preds = %128
%134 = load i64, i64* %24
br label %137
135: ; preds = %128
%136 = load i64, i64* %25
br label %137
137: ; preds = %135, %133
%138 = phi i64 [ %134, %133 ], [ %136, %135 ]
store i64 %138, i64* %26
%139 = load i8*, i8** %19
%140 = load i8*, i8** %18
%141 = load i64, i64* %26
%142 = call i32 @memcpy(i8* %139, i8* %140, i64 %141)
%143 = load i64, i64* %24
%144 = load i8*, i8** %19
%145 = getelementptr inbounds i8, i8* %144, i64 %143
store i8* %145, i8** %19
%146 = load i8*, i8** %23
store i8* %146, i8** %18
br label %147
147: ; preds = %137, %108
%148 = load i8*, i8** %18
%149 = load i8, i8* %148
%150 = sext i8 %149 to i32
%151 = icmp eq i32 %150, 125
br i1 %151, label %152, label %181
152: ; preds = %147
%153 = load i8*, i8** %18
%154 = getelementptr inbounds i8, i8* %153, i32 1
store i8* %154, i8** %18
%155 = load i8*, i8** %18
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = icmp eq i32 %157, 125
br i1 %158, label %159, label %170
159: ; preds = %152
%160 = load i8*, i8** %19
%161 = load i8*, i8** %20
%162 = icmp ult i8* %160, %161
br i1 %162, label %163, label %165
163: ; preds = %159
%164 = load i8*, i8** %19
store i8 125, i8* %164
br label %165
165: ; preds = %163, %159
%166 = load i8*, i8** %19
%167 = getelementptr inbounds i8, i8* %166, i32 1
store i8* %167, i8** %19
%168 = load i8*, i8** %18
%169 = getelementptr inbounds i8, i8* %168, i32 1
store i8* %169, i8** %18
br label %180
170: ; preds = %152
%171 = load i8*, i8** %12
%172 = load i8*, i8** %18
%173 = load i8*, i8** %12
%174 = ptrtoint i8* %172 to i64
%175 = ptrtoint i8* %173 to i64
%176 = sub i64 %174, %175
%177 = trunc i64 %176 to i32
%178 = call i32 @formatstring_error(i8* %171, i32 %177, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%179 = load i32, i32* @EINVAL
store i32 %179, i32* @errno
store i32 -1, i32* %9
br label %561
180: ; preds = %165
br label %521
181: ; preds = %147
%182 = load i8*, i8** %18
%183 = load i8, i8* %182
%184 = sext i8 %183 to i32
%185 = icmp eq i32 %184, 123
br i1 %185, label %186, label %520
186: ; preds = %181
%187 = load i8*, i8** %18
%188 = getelementptr inbounds i8, i8* %187, i32 1
store i8* %188, i8** %18
%189 = load i8*, i8** %18
%190 = load i8, i8* %189
%191 = sext i8 %190 to i32
%192 = icmp eq i32 %191, 123
br i1 %192, label %193, label %204
193: ; preds = %186
%194 = load i8*, i8** %19
%195 = load i8*, i8** %20
%196 = icmp ult i8* %194, %195
br i1 %196, label %197, label %199
197: ; preds = %193
%198 = load i8*, i8** %19
store i8 123, i8* %198
br label %199
199: ; preds = %197, %193
%200 = load i8*, i8** %19
%201 = getelementptr inbounds i8, i8* %200, i32 1
store i8* %201, i8** %19
%202 = load i8*, i8** %18
%203 = getelementptr inbounds i8, i8* %202, i32 1
store i8* %203, i8** %18
br label %519
204: ; preds = %186
%205 = load i8*, i8** %18
store i8* %205, i8** %23
br label %206
206: ; preds = %218, %204
%207 = load i8*, i8** %23
%208 = load i8, i8* %207
%209 = sext i8 %208 to i32
%210 = icmp ne i32 %209, 0
br i1 %210, label %211, label %216
211: ; preds = %206
%212 = load i8*, i8** %23
%213 = load i8, i8* %212
%214 = sext i8 %213 to i32
%215 = icmp ne i32 %214, 125
br label %216
216: ; preds = %211, %206
%217 = phi i1 [ false, %206 ], [ %215, %211 ]
br i1 %217, label %218, label %221
218: ; preds = %216
%219 = load i8*, i8** %23
%220 = getelementptr inbounds i8, i8* %219, i32 1
store i8* %220, i8** %23
br label %206
221: ; preds = %216
%222 = load i8*, i8** %18
%223 = load i8*, i8** %23
%224 = icmp eq i8* %222, %223
br i1 %224, label %225, label %235
225: ; preds = %221
%226 = load i8*, i8** %12
%227 = load i8*, i8** %18
%228 = load i8*, i8** %12
%229 = ptrtoint i8* %227 to i64
%230 = ptrtoint i8* %228 to i64
%231 = sub i64 %229, %230
%232 = trunc i64 %231 to i32
%233 = call i32 @formatstring_error(i8* %226, i32 %232, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%234 = load i32, i32* @EINVAL
store i32 %234, i32* @errno
store i32 -1, i32* %9
br label %561
235: ; preds = %221
%236 = load i8*, i8** %23
%237 = load i8*, i8** %18
%238 = ptrtoint i8* %236 to i64
%239 = ptrtoint i8* %237 to i64
%240 = sub i64 %238, %239
store i64 %240, i64* %27
%241 = load i8*, i8** %18
%242 = load i64, i64* %27
%243 = icmp ult i64 9, %242
br i1 %243, label %244, label %245
244: ; preds = %235
br label %247
245: ; preds = %235
%246 = load i64, i64* %27
br label %247
247: ; preds = %245, %244
%248 = phi i64 [ 9, %244 ], [ %246, %245 ]
%249 = trunc i64 %248 to i32
%250 = call i64 @strncmp(i8* %241, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %249)
%251 = icmp eq i64 %250, 0
br i1 %251, label %252, label %281
252: ; preds = %247
%253 = load i8*, i8** %20
%254 = load i8*, i8** %19
%255 = icmp ugt i8* %253, %254
br i1 %255, label %256, label %262
256: ; preds = %252
%257 = load i8*, i8** %20
%258 = load i8*, i8** %19
%259 = ptrtoint i8* %257 to i64
%260 = ptrtoint i8* %258 to i64
%261 = sub i64 %259, %260
br label %263
262: ; preds = %252
br label %263
263: ; preds = %262, %256
%264 = phi i64 [ %261, %256 ], [ 0, %262 ]
store i64 %264, i64* %28
%265 = load i64, i64* %21
%266 = load i64, i64* %28
%267 = icmp ult i64 %265, %266
br i1 %267, label %268, label %270
268: ; preds = %263
%269 = load i64, i64* %21
br label %272
270: ; preds = %263
%271 = load i64, i64* %28
br label %272
272: ; preds = %270, %268
%273 = phi i64 [ %269, %268 ], [ %271, %270 ]
store i64 %273, i64* %29
%274 = load i8*, i8** %19
%275 = load i8*, i8** %13
%276 = load i64, i64* %29
%277 = call i32 @memcpy(i8* %274, i8* %275, i64 %276)
%278 = load i64, i64* %21
%279 = load i8*, i8** %19
%280 = getelementptr inbounds i8, i8* %279, i64 %278
store i8* %280, i8** %19
br label %516
281: ; preds = %247
%282 = load i8*, i8** %18
%283 = load i64, i64* %27
%284 = icmp ult i64 4, %283
br i1 %284, label %285, label %286
285: ; preds = %281
br label %288
286: ; preds = %281
%287 = load i64, i64* %27
br label %288
288: ; preds = %286, %285
%289 = phi i64 [ 4, %285 ], [ %287, %286 ]
%290 = trunc i64 %289 to i32
%291 = call i64 @strncmp(i8* %282, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %290)
%292 = icmp eq i64 %291, 0
br i1 %292, label %293, label %322
293: ; preds = %288
%294 = load i8*, i8** %20
%295 = load i8*, i8** %19
%296 = icmp ugt i8* %294, %295
br i1 %296, label %297, label %303
297: ; preds = %293
%298 = load i8*, i8** %20
%299 = load i8*, i8** %19
%300 = ptrtoint i8* %298 to i64
%301 = ptrtoint i8* %299 to i64
%302 = sub i64 %300, %301
br label %304
303: ; preds = %293
br label %304
304: ; preds = %303, %297
%305 = phi i64 [ %302, %297 ], [ 0, %303 ]
store i64 %305, i64* %30
%306 = load i64, i64* %22
%307 = load i64, i64* %30
%308 = icmp ult i64 %306, %307
br i1 %308, label %309, label %311
309: ; preds = %304
%310 = load i64, i64* %22
br label %313
311: ; preds = %304
%312 = load i64, i64* %30
br label %313
313: ; preds = %311, %309
%314 = phi i64 [ %310, %309 ], [ %312, %311 ]
store i64 %314, i64* %31
%315 = load i8*, i8** %19
%316 = load i8*, i8** %17
%317 = load i64, i64* %31
%318 = call i32 @memcpy(i8* %315, i8* %316, i64 %317)
%319 = load i64, i64* %22
%320 = load i8*, i8** %19
%321 = getelementptr inbounds i8, i8* %320, i64 %319
store i8* %321, i8** %19
br label %515
322: ; preds = %288
%323 = load i8*, i8** %18
%324 = load i64, i64* %27
%325 = icmp ult i64 7, %324
br i1 %325, label %326, label %327
326: ; preds = %322
br label %329
327: ; preds = %322
%328 = load i64, i64* %27
br label %329
329: ; preds = %327, %326
%330 = phi i64 [ 7, %326 ], [ %328, %327 ]
%331 = trunc i64 %330 to i32
%332 = call i64 @strncmp(i8* %323, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %331)
%333 = icmp eq i64 %332, 0
br i1 %333, label %334, label %374
334: ; preds = %329
store i64 8, i64* %32
%335 = load i64, i64* %15
store i64 %335, i64* %33
br label %336
336: ; preds = %368, %334
%337 = load i64, i64* %32
%338 = icmp ne i64 %337, 0
br i1 %338, label %339, label %371
339: ; preds = %336
%340 = load i64, i64* %32
%341 = add i64 %340, -1
store i64 %341, i64* %32
%342 = load i8*, i8** %19
%343 = load i64, i64* %32
%344 = mul i64 2, %343
%345 = getelementptr inbounds i8, i8* %342, i64 %344
store i8* %345, i8** %34
%346 = load i8*, i8** %34
%347 = load i8*, i8** %20
%348 = icmp ult i8* %346, %347
br i1 %348, label %349, label %356
349: ; preds = %339
%350 = load i64, i64* %33
%351 = lshr i64 %350, 4
%352 = and i64 %351, 15
%353 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %352
%354 = load i8, i8* %353
%355 = load i8*, i8** %34
store i8 %354, i8* %355
br label %356
356: ; preds = %349, %339
%357 = load i8*, i8** %34
%358 = getelementptr inbounds i8, i8* %357, i32 1
store i8* %358, i8** %34
%359 = load i8*, i8** %34
%360 = load i8*, i8** %20
%361 = icmp ult i8* %359, %360
br i1 %361, label %362, label %368
362: ; preds = %356
%363 = load i64, i64* %33
%364 = and i64 %363, 15
%365 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %364
%366 = load i8, i8* %365
%367 = load i8*, i8** %34
store i8 %366, i8* %367
br label %368
368: ; preds = %362, %356
%369 = load i64, i64* %33
%370 = lshr i64 %369, 8
store i64 %370, i64* %33
br label %336
371: ; preds = %336
%372 = load i8*, i8** %19
%373 = getelementptr inbounds i8, i8* %372, i64 16
store i8* %373, i8** %19
br label %514
374: ; preds = %329
%375 = load i8*, i8** %18
%376 = load i64, i64* %27
%377 = icmp ult i64 6, %376
br i1 %377, label %378, label %379
378: ; preds = %374
br label %381
379: ; preds = %374
%380 = load i64, i64* %27
br label %381
381: ; preds = %379, %378
%382 = phi i64 [ 6, %378 ], [ %380, %379 ]
%383 = trunc i64 %382 to i32
%384 = call i64 @strncmp(i8* %375, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %383)
%385 = icmp eq i64 %384, 0
br i1 %385, label %386, label %438
386: ; preds = %381
%387 = load i64, i64* %14
%388 = icmp eq i64 %387, 0
br i1 %388, label %389, label %398
389: ; preds = %386
%390 = load i8*, i8** %19
%391 = load i8*, i8** %20
%392 = icmp ult i8* %390, %391
br i1 %392, label %393, label %395
393: ; preds = %389
%394 = load i8*, i8** %19
store i8 48, i8* %394
br label %395
395: ; preds = %393, %389
%396 = load i8*, i8** %19
%397 = getelementptr inbounds i8, i8* %396, i32 1
store i8* %397, i8** %19
br label %437
398: ; preds = %386
store i64 0, i64* %35
%399 = load i64, i64* %14
store i64 %399, i64* %36
br label %400
400: ; preds = %403, %398
%401 = load i64, i64* %36
%402 = icmp ne i64 %401, 0
br i1 %402, label %403, label %408
403: ; preds = %400
%404 = load i64, i64* %36
%405 = udiv i64 %404, 10
store i64 %405, i64* %36
%406 = load i64, i64* %35
%407 = add i64 %406, 1
store i64 %407, i64* %35
br label %400
408: ; preds = %400
%409 = load i64, i64* %14
store i64 %409, i64* %36
%410 = load i64, i64* %35
store i64 %410, i64* %37
br label %411
411: ; preds = %430, %408
%412 = load i64, i64* %36
%413 = icmp ne i64 %412, 0
br i1 %413, label %414, label %433
414: ; preds = %411
%415 = load i64, i64* %37
%416 = add i64 %415, -1
store i64 %416, i64* %37
%417 = load i64, i64* %36
%418 = urem i64 %417, 10
store i64 %418, i64* %38
%419 = load i8*, i8** %19
%420 = load i64, i64* %37
%421 = getelementptr inbounds i8, i8* %419, i64 %420
store i8* %421, i8** %39
%422 = load i8*, i8** %39
%423 = load i8*, i8** %20
%424 = icmp ult i8* %422, %423
br i1 %424, label %425, label %430
425: ; preds = %414
%426 = load i64, i64* %38
%427 = add i64 48, %426
%428 = trunc i64 %427 to i8
%429 = load i8*, i8** %39
store i8 %428, i8* %429
br label %430
430: ; preds = %425, %414
%431 = load i64, i64* %36
%432 = udiv i64 %431, 10
store i64 %432, i64* %36
br label %411
433: ; preds = %411
%434 = load i64, i64* %35
%435 = load i8*, i8** %19
%436 = getelementptr inbounds i8, i8* %435, i64 %434
store i8* %436, i8** %19
br label %437
437: ; preds = %433, %395
br label %513
438: ; preds = %381
%439 = load i8*, i8** %18
%440 = load i64, i64* %27
%441 = icmp ult i64 5, %440
br i1 %441, label %442, label %443
442: ; preds = %438
br label %445
443: ; preds = %438
%444 = load i64, i64* %27
br label %445
445: ; preds = %443, %442
%446 = phi i64 [ 5, %442 ], [ %444, %443 ]
%447 = trunc i64 %446 to i32
%448 = call i64 @strncmp(i8* %439, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %447)
%449 = icmp eq i64 %448, 0
br i1 %449, label %450, label %502
450: ; preds = %445
%451 = load i64, i64* %16
%452 = icmp eq i64 %451, 0
br i1 %452, label %453, label %462
453: ; preds = %450
%454 = load i8*, i8** %19
%455 = load i8*, i8** %20
%456 = icmp ult i8* %454, %455
br i1 %456, label %457, label %459
457: ; preds = %453
%458 = load i8*, i8** %19
store i8 48, i8* %458
br label %459
459: ; preds = %457, %453
%460 = load i8*, i8** %19
%461 = getelementptr inbounds i8, i8* %460, i32 1
store i8* %461, i8** %19
br label %501
462: ; preds = %450
store i64 0, i64* %40
%463 = load i64, i64* %16
store i64 %463, i64* %41
br label %464
464: ; preds = %467, %462
%465 = load i64, i64* %41
%466 = icmp ne i64 %465, 0
br i1 %466, label %467, label %472
467: ; preds = %464
%468 = load i64, i64* %41
%469 = udiv i64 %468, 10
store i64 %469, i64* %41
%470 = load i64, i64* %40
%471 = add i64 %470, 1
store i64 %471, i64* %40
br label %464
472: ; preds = %464
%473 = load i64, i64* %16
store i64 %473, i64* %41
%474 = load i64, i64* %40
store i64 %474, i64* %42
br label %475
475: ; preds = %494, %472
%476 = load i64, i64* %41
%477 = icmp ne i64 %476, 0
br i1 %477, label %478, label %497
478: ; preds = %475
%479 = load i64, i64* %42
%480 = add i64 %479, -1
store i64 %480, i64* %42
%481 = load i64, i64* %41
%482 = urem i64 %481, 10
store i64 %482, i64* %43
%483 = load i8*, i8** %19
%484 = load i64, i64* %42
%485 = getelementptr inbounds i8, i8* %483, i64 %484
store i8* %485, i8** %44
%486 = load i8*, i8** %44
%487 = load i8*, i8** %20
%488 = icmp ult i8* %486, %487
br i1 %488, label %489, label %494
489: ; preds = %478
%490 = load i64, i64* %43
%491 = add i64 48, %490
%492 = trunc i64 %491 to i8
%493 = load i8*, i8** %44
store i8 %492, i8* %493
br label %494
494: ; preds = %489, %478
%495 = load i64, i64* %41
%496 = udiv i64 %495, 10
store i64 %496, i64* %41
br label %475
497: ; preds = %475
%498 = load i64, i64* %40
%499 = load i8*, i8** %19
%500 = getelementptr inbounds i8, i8* %499, i64 %498
store i8* %500, i8** %19
br label %501
501: ; preds = %497, %459
br label %512
502: ; preds = %445
%503 = load i8*, i8** %12
%504 = load i8*, i8** %18
%505 = load i8*, i8** %12
%506 = ptrtoint i8* %504 to i64
%507 = ptrtoint i8* %505 to i64
%508 = sub i64 %506, %507
%509 = trunc i64 %508 to i32
%510 = call i32 @formatstring_error(i8* %503, i32 %509, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%511 = load i32, i32* @EINVAL
store i32 %511, i32* @errno
store i32 -1, i32* %9
br label %561
512: ; preds = %501
br label %513
513: ; preds = %512, %437
br label %514
514: ; preds = %513, %371
br label %515
515: ; preds = %514, %313
br label %516
516: ; preds = %515, %272
%517 = load i8*, i8** %23
%518 = getelementptr inbounds i8, i8* %517, i64 1
store i8* %518, i8** %18
br label %519
519: ; preds = %516, %199
br label %520
520: ; preds = %519, %181
br label %521
521: ; preds = %520, %180
br label %82
522: ; preds = %82
%523 = load i8*, i8** %19
%524 = load i8*, i8** %20
%525 = icmp ult i8* %523, %524
br i1 %525, label %526, label %528
526: ; preds = %522
%527 = load i8*, i8** %19
store i8 0, i8* %527
br label %537
528: ; preds = %522
%529 = load i64, i64* %11
%530 = icmp ugt i64 %529, 0
br i1 %530, label %531, label %536
531: ; preds = %528
%532 = load i8*, i8** %10
%533 = load i64, i64* %11
%534 = sub i64 %533, 1
%535 = getelementptr inbounds i8, i8* %532, i64 %534
store i8 0, i8* %535
br label %536
536: ; preds = %531, %528
br label %537
537: ; preds = %536, %526
%538 = load i8*, i8** %19
%539 = getelementptr inbounds i8, i8* %538, i32 1
store i8* %539, i8** %19
%540 = load i8*, i8** %19
%541 = load i8*, i8** %10
%542 = ptrtoint i8* %540 to i64
%543 = ptrtoint i8* %541 to i64
%544 = sub i64 %542, %543
store i64 %544, i64* %45
%545 = load i64, i64* %45
%546 = load i64, i64* @SSIZE_MAX
%547 = icmp ugt i64 %545, %546
br i1 %547, label %548, label %558
548: ; preds = %537
%549 = load i8*, i8** %12
%550 = load i8*, i8** %18
%551 = load i8*, i8** %12
%552 = ptrtoint i8* %550 to i64
%553 = ptrtoint i8* %551 to i64
%554 = sub i64 %552, %553
%555 = trunc i64 %554 to i32
%556 = call i32 @formatstring_error(i8* %549, i32 %555, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%557 = load i32, i32* @ERANGE
store i32 %557, i32* @errno
store i32 -1, i32* %9
br label %561
558: ; preds = %537
%559 = load i64, i64* %45
%560 = trunc i64 %559 to i32
store i32 %560, i32* %9
br label %561
561: ; preds = %558, %548, %502, %225, %170
%562 = load i32, i32* %9
ret i32 %562
}

LLVM IR (-O2):
@.str = [13 x i8] c"expected '}'\00"
@EINVAL = global i32 0
@errno = global i32 0
@.str.1 = [25 x i8] c"expected a variable name\00"
@.str.2 = [9 x i8] c"filename\00"
@.str.3 = [4 x i8] c"ext\00"
@.str.4 = [7 x i8] c"offset\00"
@.str.5 = [17 x i8] c"0123456789ABCDEF\00"
@.str.6 = [6 x i8] c"index\00"
@.str.7 = [5 x i8] c"size\00"
@.str.8 = [22 x i8] c"unknown variable name\00"
@SSIZE_MAX = constant i64 0
@.str.9 = [16 x i8] c"string too long\00"
@ERANGE = global i32 0
define i32 @formatstring(i8* %0, i64 %1, i8* %2, i8* %3, i64 %4, i64 %5, i64 %6, i8* %7) {
%9 = icmp eq i64 %1, 0
%10 = icmp ne i8* %0, null
%11 = or i1 %10, %9
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = icmp ne i8* %2, null
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = icmp ne i8* %3, null
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = icmp ne i8* %7, null
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = select i1 %9, i8* null, i8* %0
%24 = getelementptr inbounds i8, i8* %23, i64 %1
%25 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%26 = tail call i64 @strlen(i8* dereferenceable(1) %7)
%27 = load i8, i8* %2
%28 = icmp eq i8 %27, 0
br i1 %28, label %321, label %29
29: ; preds = %8
%30 = ptrtoint i8* %24 to i64
%31 = icmp eq i64 %6, 0
%32 = icmp eq i64 %4, 0
%33 = lshr i64 %5, 4
%34 = and i64 %33, 15
%35 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %34
%36 = and i64 %5, 15
%37 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %36
%38 = lshr i64 %5, 8
%39 = lshr i64 %5, 12
%40 = and i64 %39, 15
%41 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %40
%42 = and i64 %38, 15
%43 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %42
%44 = lshr i64 %5, 16
%45 = lshr i64 %5, 20
%46 = and i64 %45, 15
%47 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %46
%48 = and i64 %44, 15
%49 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %48
%50 = lshr i64 %5, 24
%51 = lshr i64 %5, 28
%52 = and i64 %51, 15
%53 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %52
%54 = and i64 %50, 15
%55 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %54
%56 = lshr i64 %5, 32
%57 = lshr i64 %5, 36
%58 = and i64 %57, 15
%59 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %58
%60 = and i64 %56, 15
%61 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %60
%62 = lshr i64 %5, 40
%63 = lshr i64 %5, 44
%64 = and i64 %63, 15
%65 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %64
%66 = and i64 %62, 15
%67 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %66
%68 = lshr i64 %5, 48
%69 = lshr i64 %5, 52
%70 = and i64 %69, 15
%71 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %70
%72 = and i64 %68, 15
%73 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %72
%74 = lshr i64 %5, 56
%75 = lshr i64 %5, 60
%76 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %75
%77 = and i64 %74, 15
%78 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.5, i64 0, i64 %77
br label %79
79: ; preds = %29, %316
%80 = phi i8 [ %27, %29 ], [ %319, %316 ]
%81 = phi i8* [ %2, %29 ], [ %318, %316 ]
%82 = phi i8* [ %23, %29 ], [ %317, %316 ]
br label %83
83: ; preds = %79, %86
%84 = phi i8 [ %88, %86 ], [ %80, %79 ]
%85 = phi i8* [ %87, %86 ], [ %81, %79 ]
switch i8 %84, label %86 [
i8 0, label %89
i8 123, label %89
i8 125, label %89
]
86: ; preds = %83
%87 = getelementptr inbounds i8, i8* %85, i64 1
%88 = load i8, i8* %87
br label %83
89: ; preds = %83, %83, %83
%90 = icmp eq i8* %85, %81
br i1 %90, label %104, label %91
91: ; preds = %89
%92 = ptrtoint i8* %85 to i64
%93 = ptrtoint i8* %81 to i64
%94 = sub i64 %92, %93
%95 = icmp ugt i8* %24, %82
%96 = ptrtoint i8* %82 to i64
%97 = sub i64 %30, %96
%98 = select i1 %95, i64 %97, i64 0
%99 = icmp ult i64 %94, %98
%100 = select i1 %99, i64 %94, i64 %98
%101 = tail call i32 @memcpy(i8* %82, i8* %81, i64 %100)
%102 = getelementptr inbounds i8, i8* %82, i64 %94
%103 = load i8, i8* %85
br label %104
104: ; preds = %91, %89
%105 = phi i8 [ %103, %91 ], [ %80, %89 ]
%106 = phi i8* [ %102, %91 ], [ %82, %89 ]
%107 = phi i8* [ %85, %91 ], [ %81, %89 ]
switch i8 %105, label %316 [
i8 125, label %108
i8 123, label %120
]
108: ; preds = %104
%109 = getelementptr inbounds i8, i8* %107, i64 1
%110 = load i8, i8* %109
%111 = icmp eq i8 %110, 125
br i1 %111, label %112, label %118
112: ; preds = %108
%113 = icmp ult i8* %106, %24
br i1 %113, label %114, label %115
114: ; preds = %112
store i8 125, i8* %106
br label %115
115: ; preds = %114, %112
%116 = getelementptr inbounds i8, i8* %106, i64 1
%117 = getelementptr inbounds i8, i8* %107, i64 2
br label %316
118: ; preds = %108
%119 = getelementptr inbounds i8, i8* %107, i64 1
br label %334
120: ; preds = %104
%121 = getelementptr inbounds i8, i8* %107, i64 1
%122 = load i8, i8* %121
%123 = icmp eq i8 %122, 123
br i1 %123, label %124, label %130
124: ; preds = %120
%125 = icmp ult i8* %106, %24
br i1 %125, label %126, label %127
126: ; preds = %124
store i8 123, i8* %106
br label %127
127: ; preds = %126, %124
%128 = getelementptr inbounds i8, i8* %106, i64 1
%129 = getelementptr inbounds i8, i8* %107, i64 2
br label %316
130: ; preds = %120, %133
%131 = phi i8 [ %136, %133 ], [ %122, %120 ]
%132 = phi i64 [ %134, %133 ], [ 1, %120 ]
switch i8 %131, label %133 [
i8 0, label %137
i8 125, label %137
]
133: ; preds = %130
%134 = add nuw nsw i64 %132, 1
%135 = getelementptr inbounds i8, i8* %107, i64 %134
%136 = load i8, i8* %135
br label %130
137: ; preds = %130, %130
%138 = getelementptr inbounds i8, i8* %107, i64 1
%139 = icmp eq i64 %132, 1
br i1 %139, label %334, label %140
140: ; preds = %137
%141 = add nsw i64 %132, -1
%142 = icmp ult i64 %141, 9
%143 = select i1 %142, i64 %141, i64 9
%144 = trunc i64 %143 to i32
%145 = tail call i64 @strncmp(i8* %121, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %144)
%146 = icmp eq i64 %145, 0
br i1 %146, label %147, label %155
147: ; preds = %140
%148 = icmp ugt i8* %24, %106
%149 = ptrtoint i8* %106 to i64
%150 = sub i64 %30, %149
%151 = select i1 %148, i64 %150, i64 0
%152 = icmp ult i64 %25, %151
%153 = select i1 %152, i64 %25, i64 %151
%154 = tail call i32 @memcpy(i8* %106, i8* %3, i64 %153)
br label %312
155: ; preds = %140
%156 = icmp ult i64 %141, 4
%157 = select i1 %156, i64 %141, i64 4
%158 = trunc i64 %157 to i32
%159 = tail call i64 @strncmp(i8* %121, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %158)
%160 = icmp eq i64 %159, 0
br i1 %160, label %161, label %169
161: ; preds = %155
%162 = icmp ugt i8* %24, %106
%163 = ptrtoint i8* %106 to i64
%164 = sub i64 %30, %163
%165 = select i1 %162, i64 %164, i64 0
%166 = icmp ult i64 %26, %165
%167 = select i1 %166, i64 %26, i64 %165
%168 = tail call i32 @memcpy(i8* %106, i8* %7, i64 %167)
br label %312
169: ; preds = %155
%170 = icmp ult i64 %141, 7
%171 = select i1 %170, i64 %141, i64 7
%172 = trunc i64 %171 to i32
%173 = tail call i64 @strncmp(i8* %121, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %172)
%174 = icmp eq i64 %173, 0
br i1 %174, label %175, label %254
175: ; preds = %169
%176 = getelementptr inbounds i8, i8* %106, i64 14
%177 = icmp ult i8* %176, %24
br i1 %177, label %178, label %180
178: ; preds = %175
%179 = load i8, i8* %35
store i8 %179, i8* %176
br label %180
180: ; preds = %178, %175
%181 = getelementptr inbounds i8, i8* %106, i64 15
%182 = icmp ult i8* %181, %24
br i1 %182, label %183, label %185
183: ; preds = %180
%184 = load i8, i8* %37
store i8 %184, i8* %181
br label %185
185: ; preds = %183, %180
%186 = getelementptr inbounds i8, i8* %106, i64 12
%187 = icmp ult i8* %186, %24
br i1 %187, label %188, label %190
188: ; preds = %185
%189 = load i8, i8* %41
store i8 %189, i8* %186
br label %190
190: ; preds = %188, %185
%191 = getelementptr inbounds i8, i8* %106, i64 13
%192 = icmp ult i8* %191, %24
br i1 %192, label %193, label %195
193: ; preds = %190
%194 = load i8, i8* %43
store i8 %194, i8* %191
br label %195
195: ; preds = %193, %190
%196 = getelementptr inbounds i8, i8* %106, i64 10
%197 = icmp ult i8* %196, %24
br i1 %197, label %198, label %200
198: ; preds = %195
%199 = load i8, i8* %47
store i8 %199, i8* %196
br label %200
200: ; preds = %198, %195
%201 = getelementptr inbounds i8, i8* %106, i64 11
%202 = icmp ult i8* %201, %24
br i1 %202, label %203, label %205
203: ; preds = %200
%204 = load i8, i8* %49
store i8 %204, i8* %201
br label %205
205: ; preds = %203, %200
%206 = getelementptr inbounds i8, i8* %106, i64 8
%207 = icmp ult i8* %206, %24
br i1 %207, label %208, label %210
208: ; preds = %205
%209 = load i8, i8* %53
store i8 %209, i8* %206
br label %210
210: ; preds = %208, %205
%211 = getelementptr inbounds i8, i8* %106, i64 9
%212 = icmp ult i8* %211, %24
br i1 %212, label %213, label %215
213: ; preds = %210
%214 = load i8, i8* %55
store i8 %214, i8* %211
br label %215
215: ; preds = %213, %210
%216 = getelementptr inbounds i8, i8* %106, i64 6
%217 = icmp ult i8* %216, %24
br i1 %217, label %218, label %220
218: ; preds = %215
%219 = load i8, i8* %59
store i8 %219, i8* %216
br label %220
220: ; preds = %218, %215
%221 = getelementptr inbounds i8, i8* %106, i64 7
%222 = icmp ult i8* %221, %24
br i1 %222, label %223, label %225
223: ; preds = %220
%224 = load i8, i8* %61
store i8 %224, i8* %221
br label %225
225: ; preds = %223, %220
%226 = getelementptr inbounds i8, i8* %106, i64 4
%227 = icmp ult i8* %226, %24
br i1 %227, label %228, label %230
228: ; preds = %225
%229 = load i8, i8* %65
store i8 %229, i8* %226
br label %230
230: ; preds = %228, %225
%231 = getelementptr inbounds i8, i8* %106, i64 5
%232 = icmp ult i8* %231, %24
br i1 %232, label %233, label %235
233: ; preds = %230
%234 = load i8, i8* %67
store i8 %234, i8* %231
br label %235
235: ; preds = %233, %230
%236 = getelementptr inbounds i8, i8* %106, i64 2
%237 = icmp ult i8* %236, %24
br i1 %237, label %238, label %240
238: ; preds = %235
%239 = load i8, i8* %71
store i8 %239, i8* %236
br label %240
240: ; preds = %238, %235
%241 = getelementptr inbounds i8, i8* %106, i64 3
%242 = icmp ult i8* %241, %24
br i1 %242, label %243, label %245
243: ; preds = %240
%244 = load i8, i8* %73
store i8 %244, i8* %241
br label %245
245: ; preds = %243, %240
%246 = icmp ult i8* %106, %24
br i1 %246, label %247, label %249
247: ; preds = %245
%248 = load i8, i8* %76
store i8 %248, i8* %106
br label %249
249: ; preds = %247, %245
%250 = getelementptr inbounds i8, i8* %106, i64 1
%251 = icmp ult i8* %250, %24
br i1 %251, label %252, label %312
252: ; preds = %249
%253 = load i8, i8* %78
store i8 %253, i8* %250
br label %312
254: ; preds = %169
%255 = icmp ult i64 %141, 6
%256 = select i1 %255, i64 %141, i64 6
%257 = trunc i64 %256 to i32
%258 = tail call i64 @strncmp(i8* %121, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %257)
%259 = icmp eq i64 %258, 0
br i1 %259, label %260, label %283
260: ; preds = %254
br i1 %32, label %261, label %264
261: ; preds = %260
%262 = icmp ult i8* %106, %24
br i1 %262, label %263, label %312
263: ; preds = %261
store i8 48, i8* %106
br label %312
264: ; preds = %260, %264
%265 = phi i64 [ %267, %264 ], [ %4, %260 ]
%266 = phi i64 [ %268, %264 ], [ 0, %260 ]
%267 = udiv i64 %265, 10
%268 = add i64 %266, 1
%269 = icmp ult i64 %265, 10
br i1 %269, label %270, label %264
270: ; preds = %264, %281
%271 = phi i64 [ %273, %281 ], [ %268, %264 ]
%272 = phi i64 [ %276, %281 ], [ %4, %264 ]
%273 = add i64 %271, -1
%274 = getelementptr inbounds i8, i8* %106, i64 %273
%275 = icmp ult i8* %274, %24
%276 = udiv i64 %272, 10
%277 = urem i64 %272, 10
br i1 %275, label %278, label %281
278: ; preds = %270
%279 = trunc i64 %277 to i8
%280 = or i8 %279, 48
store i8 %280, i8* %274
br label %281
281: ; preds = %278, %270
%282 = icmp ult i64 %272, 10
br i1 %282, label %312, label %270
283: ; preds = %254
%284 = icmp ult i64 %141, 5
%285 = select i1 %284, i64 %141, i64 5
%286 = trunc i64 %285 to i32
%287 = tail call i64 @strncmp(i8* %121, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %286)
%288 = icmp eq i64 %287, 0
br i1 %288, label %289, label %334
289: ; preds = %283
br i1 %31, label %290, label %293
290: ; preds = %289
%291 = icmp ult i8* %106, %24
br i1 %291, label %292, label %312
292: ; preds = %290
store i8 48, i8* %106
br label %312
293: ; preds = %289, %293
%294 = phi i64 [ %296, %293 ], [ %6, %289 ]
%295 = phi i64 [ %297, %293 ], [ 0, %289 ]
%296 = udiv i64 %294, 10
%297 = add i64 %295, 1
%298 = icmp ult i64 %294, 10
br i1 %298, label %299, label %293
299: ; preds = %293, %310
%300 = phi i64 [ %302, %310 ], [ %297, %293 ]
%301 = phi i64 [ %305, %310 ], [ %6, %293 ]
%302 = add i64 %300, -1
%303 = getelementptr inbounds i8, i8* %106, i64 %302
%304 = icmp ult i8* %303, %24
%305 = udiv i64 %301, 10
%306 = urem i64 %301, 10
br i1 %304, label %307, label %310
307: ; preds = %299
%308 = trunc i64 %306 to i8
%309 = or i8 %308, 48
store i8 %309, i8* %303
br label %310
310: ; preds = %307, %299
%311 = icmp ult i64 %301, 10
br i1 %311, label %312, label %299
312: ; preds = %310, %281, %290, %292, %261, %263, %249, %252, %147, %161
%313 = phi i64 [ %25, %147 ], [ %26, %161 ], [ 16, %252 ], [ 16, %249 ], [ 1, %263 ], [ 1, %261 ], [ 1, %292 ], [ 1, %290 ], [ %268, %281 ], [ %297, %310 ]
%314 = getelementptr inbounds i8, i8* %106, i64 %313
%315 = getelementptr inbounds i8, i8* %138, i64 %132
br label %316
316: ; preds = %115, %127, %104, %312
%317 = phi i8* [ %116, %115 ], [ %128, %127 ], [ %106, %104 ], [ %314, %312 ]
%318 = phi i8* [ %117, %115 ], [ %129, %127 ], [ %107, %104 ], [ %315, %312 ]
%319 = load i8, i8* %318
%320 = icmp eq i8 %319, 0
br i1 %320, label %321, label %79
321: ; preds = %316, %8
%322 = phi i8* [ %23, %8 ], [ %317, %316 ]
%323 = phi i8* [ %2, %8 ], [ %318, %316 ]
%324 = icmp ult i8* %322, %24
br i1 %324, label %329, label %325
325: ; preds = %321
br i1 %9, label %331, label %326
326: ; preds = %325
%327 = add i64 %1, -1
%328 = getelementptr inbounds i8, i8* %0, i64 %327
br label %329
329: ; preds = %321, %326
%330 = phi i8* [ %328, %326 ], [ %322, %321 ]
store i8 0, i8* %330
br label %331
331: ; preds = %329, %325
%332 = getelementptr inbounds i8, i8* %322, i64 1
%333 = icmp eq i8* %332, %0
br i1 %333, label %344, label %334
334: ; preds = %283, %137, %331, %118
%335 = phi i8* [ %119, %118 ], [ %323, %331 ], [ %121, %137 ], [ %121, %283 ]
%336 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %118 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), %331 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %283 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %137 ]
%337 = phi i32* [ @EINVAL, %118 ], [ @ERANGE, %331 ], [ @EINVAL, %137 ], [ @EINVAL, %283 ]
%338 = ptrtoint i8* %335 to i64
%339 = ptrtoint i8* %2 to i64
%340 = sub i64 %338, %339
%341 = trunc i64 %340 to i32
%342 = tail call i32 @formatstring_error(i8* %2, i32 %341, i8* %336)
%343 = load i32, i32* %337
store i32 %343, i32* @errno
br label %344
344: ; preds = %334, %331
%345 = phi i32 [ 0, %331 ], [ -1, %334 ]
ret i32 %345
}