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

/* Forward declarations */

/* Type definitions */
struct chrm_entry {
  int dummy;
};

/* Variables and functions */
unsigned long atol(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
struct chrm_entry *lookup_chrm(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
struct chrm_entry *put_chrm(char *, int);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
void check_bed_file_sorted(unsigned char no_header) {
  char line[1024];
  char chrname[32] = "";
  char tmp_chrname[32] = "";
  unsigned long start;
  unsigned long tmp_start = -999999999;
  unsigned char strand;
  unsigned char tmp_strand;
  unsigned int reads = 0;
  char *ptr;
  char *ptrend;
  int cs = 0;
  int lenptr;
  char token[32] = "";
  unsigned int dif_strand = 0;
  unsigned int sorted = 1;
  struct chrm_entry *ce;
  while (fgets(line, 1024, stdin) != NULL) {
    if (line[0] == '\n' || line[1] == '\n') {
      continue;
    } else if (no_header ||
               (strncmp(line, "#", 1) != 0 && strncmp(line, "track", 5) != 0 &&
                strncmp(line, "browser", 7) != 0)) {
      ptr = line;
      ptrend = strchr(ptr, '\t');
      lenptr = ptrend - ptr;
      strncpy(chrname, ptr, lenptr);
      chrname[lenptr] = '\0';
      ptr = ptrend + 1;
      ptrend = strchr(ptr, '\t');
      lenptr = ptrend - ptr;
      strncpy(token, ptr, lenptr);
      token[lenptr] = '\0';
      start = atol(token);
      cs = strcmp(chrname, tmp_chrname);
      if (cs != 0) {
        if ((ce = lookup_chrm(chrname)) != NULL) {
          sorted = 0;
          break;
        } else {
          ce = put_chrm(chrname, 1);
        }
      } else {
        if (start < tmp_start) {
          sorted = 0;
          break;
        } else if (reads == 0) {
          ce = put_chrm(chrname, 1);
        } else if (start == tmp_start) {
          ptr = ptrend + 1;
          ptrend = strchr(ptr, '\t');
          ptr = ptrend + 1;
          ptrend = strchr(ptr, '\t');
          ptr = ptrend + 1;
          ptrend = strchr(ptr, '\t');
          ptr = ptrend + 1;
          ptrend = strchr(ptr, '\t');
          if (ptrend == NULL) {
            if (*ptr == '+') {
              strand = 0;
            } else {
              strand = 1;
            }
          } else {
            lenptr = ptrend - ptr;
            strncpy(token, ptr, lenptr);
            if (token[0] == '+') {
              strand = 0;
            } else {
              strand = 1;
            }
          }
          if (tmp_strand != strand) {
            if (dif_strand) {
              sorted = 0;
              break;
            }
            dif_strand = 1;
          }
          strcpy(tmp_chrname, chrname);
          tmp_start = start;
          tmp_strand = strand;
          reads++;
          continue;
        } else {
          dif_strand = 0;
        }
      }
      ptr = ptrend + 1;
      ptrend = strchr(ptr, '\t');
      ptr = ptrend + 1;
      ptrend = strchr(ptr, '\t');
      ptr = ptrend + 1;
      ptrend = strchr(ptr, '\t');
      ptr = ptrend + 1;
      ptrend = strchr(ptr, '\t');
      if (ptrend == NULL) {
        if (*ptr == '+') {
          strand = 0;
        } else {
          strand = 1;
        }
      } else {
        lenptr = ptrend - ptr;
        strncpy(token, ptr, lenptr);
        if (token[0] == '+') {
          strand = 0;
        } else {
          strand = 1;
        }
      }
      strcpy(tmp_chrname, chrname);
      tmp_start = start;
      tmp_strand = strand;
      reads++;
    }
  }
  printf("%d\n", sorted);
  return;
}


x86 assembly (clang, -O0):
<check_bed_file_sorted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
lea    -0x450(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
movq   $0xffffffffc4653601,-0x460(%rbp)
01 36 65 c4
movl   $0x0,-0x468(%rbp)
movl   $0x0,-0x47c(%rbp)
lea    -0x4a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
movl   $0x0,-0x4a4(%rbp)
movl   $0x1,-0x4a8(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2dad(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     17e8 <check_bed_file_sorted+0x638>
movsbl -0x410(%rbp),%eax
cmp    $0xa,%eax
je     1271 <check_bed_file_sorted+0xc1>
movsbl -0x40f(%rbp),%eax
cmp    $0xa,%eax
jne    1276 <check_bed_file_sorted+0xc6>
jmp    122d <check_bed_file_sorted+0x7d>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    12e9 <check_bed_file_sorted+0x139>
lea    -0x410(%rbp),%rdi
lea    0xd6f(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     17de <check_bed_file_sorted+0x62e>
lea    -0x410(%rbp),%rdi
lea    0xd4f(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     17de <check_bed_file_sorted+0x62e>
lea    -0x410(%rbp),%rdi
lea    0xd33(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     17de <check_bed_file_sorted+0x62e>
lea    -0x410(%rbp),%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
mov    -0x470(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x480(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x470(%rbp),%rsi
mov    -0x480(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x480(%rbp),%rax
movb   $0x0,-0x430(%rbp,%rax,1)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
mov    -0x470(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x480(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    -0x470(%rbp),%rsi
mov    -0x480(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x480(%rbp),%rax
movb   $0x0,-0x4a0(%rbp,%rax,1)
lea    -0x4a0(%rbp),%rdi
call   10c0 <atol@plt>
mov    %rax,-0x458(%rbp)
lea    -0x430(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   10a0 <strcmp@plt>
mov    %eax,-0x47c(%rbp)
cmpl   $0x0,-0x47c(%rbp)
je     1439 <check_bed_file_sorted+0x289>
lea    -0x430(%rbp),%rdi
call   10d0 <lookup_chrm@plt>
mov    %rax,-0x4b0(%rbp)
cmp    $0x0,%rax
je     141c <check_bed_file_sorted+0x26c>
movl   $0x0,-0x4a8(%rbp)
jmp    17e8 <check_bed_file_sorted+0x638>
lea    -0x430(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <put_chrm@plt>
mov    %rax,-0x4b0(%rbp)
jmp    1669 <check_bed_file_sorted+0x4b9>
mov    -0x458(%rbp),%rax
cmp    -0x460(%rbp),%rax
jae    145c <check_bed_file_sorted+0x2ac>
movl   $0x0,-0x4a8(%rbp)
jmp    17e8 <check_bed_file_sorted+0x638>
cmpl   $0x0,-0x468(%rbp)
jne    1486 <check_bed_file_sorted+0x2d6>
lea    -0x430(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <put_chrm@plt>
mov    %rax,-0x4b0(%rbp)
jmp    165f <check_bed_file_sorted+0x4af>
mov    -0x458(%rbp),%rax
cmp    -0x460(%rbp),%rax
jne    1650 <check_bed_file_sorted+0x4a0>
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
cmpq   $0x0,-0x478(%rbp)
jne    157b <check_bed_file_sorted+0x3cb>
mov    -0x470(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    156f <check_bed_file_sorted+0x3bf>
movb   $0x0,-0x461(%rbp)
jmp    1576 <check_bed_file_sorted+0x3c6>
movb   $0x1,-0x461(%rbp)
jmp    15d3 <check_bed_file_sorted+0x423>
mov    -0x478(%rbp),%rax
mov    -0x470(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x480(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    -0x470(%rbp),%rsi
mov    -0x480(%rbp),%edx
call   1030 <strncpy@plt>
movsbl -0x4a0(%rbp),%eax
cmp    $0x2b,%eax
jne    15c7 <check_bed_file_sorted+0x417>
movb   $0x0,-0x461(%rbp)
jmp    15ce <check_bed_file_sorted+0x41e>
movb   $0x1,-0x461(%rbp)
jmp    15d3 <check_bed_file_sorted+0x423>
movzbl -0x462(%rbp),%eax
movzbl -0x461(%rbp),%ecx
cmp    %ecx,%eax
je     160f <check_bed_file_sorted+0x45f>
cmpl   $0x0,-0x4a4(%rbp)
je     1605 <check_bed_file_sorted+0x455>
movl   $0x0,-0x4a8(%rbp)
jmp    17e8 <check_bed_file_sorted+0x638>
movl   $0x1,-0x4a4(%rbp)
lea    -0x450(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x458(%rbp),%rax
mov    %rax,-0x460(%rbp)
mov    -0x461(%rbp),%al
mov    %al,-0x462(%rbp)
mov    -0x468(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x468(%rbp)
jmp    122d <check_bed_file_sorted+0x7d>
movl   $0x0,-0x4a4(%rbp)
jmp    165f <check_bed_file_sorted+0x4af>
jmp    1664 <check_bed_file_sorted+0x4b4>
jmp    1669 <check_bed_file_sorted+0x4b9>
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x470(%rbp),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,-0x478(%rbp)
cmpq   $0x0,-0x478(%rbp)
jne    174a <check_bed_file_sorted+0x59a>
mov    -0x470(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    173e <check_bed_file_sorted+0x58e>
movb   $0x0,-0x461(%rbp)
jmp    1745 <check_bed_file_sorted+0x595>
movb   $0x1,-0x461(%rbp)
jmp    17a2 <check_bed_file_sorted+0x5f2>
mov    -0x478(%rbp),%rax
mov    -0x470(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x480(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    -0x470(%rbp),%rsi
mov    -0x480(%rbp),%edx
call   1030 <strncpy@plt>
movsbl -0x4a0(%rbp),%eax
cmp    $0x2b,%eax
jne    1796 <check_bed_file_sorted+0x5e6>
movb   $0x0,-0x461(%rbp)
jmp    179d <check_bed_file_sorted+0x5ed>
movb   $0x1,-0x461(%rbp)
jmp    17a2 <check_bed_file_sorted+0x5f2>
lea    -0x450(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x458(%rbp),%rax
mov    %rax,-0x460(%rbp)
mov    -0x461(%rbp),%al
mov    %al,-0x462(%rbp)
mov    -0x468(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x468(%rbp)
jmp    17e3 <check_bed_file_sorted+0x633>
jmp    122d <check_bed_file_sorted+0x7d>
mov    -0x4a8(%rbp),%esi
lea    0x81b(%rip),%rdi
call   1070 <printf@plt>
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_bed_file_sorted>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x498,%rsp
mov    %edi,%r15d
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
xor    %r12d,%r12d
movq   $0xffffffffc4653601,0x18(%rsp)
65 c4
mov    0x2dfd(%rip),%r14
lea    0x90(%rsp),%rbx
lea    0xe06(%rip),%rbp
xor    %r13d,%r13d
nopl   (%rax)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1481 <check_bed_file_sorted+0x2e1>
cmpb   $0xa,0x90(%rsp)
0a
je     1200 <check_bed_file_sorted+0x60>
cmpb   $0xa,0x91(%rsp)
0a
je     1200 <check_bed_file_sorted+0x60>
test   %r15b,%r15b
jne    1279 <check_bed_file_sorted+0xd9>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1200 <check_bed_file_sorted+0x60>
mov    %rbx,%rdi
lea    0xdb1(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1200 <check_bed_file_sorted+0x60>
mov    %rbx,%rdi
lea    0xd9e(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1200 <check_bed_file_sorted+0x60>
mov    %r12d,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,%r12
mov    %rax,%rbp
sub    %rbx,%rbp
lea    0x50(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,0x50(%rsp,%rax,1)
add    $0x1,%r12
mov    %r12,%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,%rbp
mov    %rax,0x10(%rsp)
sub    %r12,%rbp
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
lea    0x50(%rsp),%r12
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0x20(%rsp),%rdi
call   10b0 <atol@plt>
mov    %rax,%rbp
mov    %r12,%rdi
lea    0x70(%rsp),%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
mov    %rbp,0x48(%rsp)
je     1393 <check_bed_file_sorted+0x1f3>
mov    %r12,%rdi
call   10c0 <lookup_chrm@plt>
test   %rax,%rax
jne    147d <check_bed_file_sorted+0x2dd>
mov    %r12,%rdi
mov    $0x1,%esi
call   10a0 <put_chrm@plt>
mov    %r13d,%ebp
mov    0x10(%rsp),%rdi
add    $0x1,%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,%r13
add    $0x1,%r13
mov    %r13,%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     141b <check_bed_file_sorted+0x27b>
sub    %r13d,%eax
lea    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movzbl 0x20(%rsp),%eax
jmp    1420 <check_bed_file_sorted+0x280>
mov    0x18(%rsp),%rcx
cmp    %rcx,%rbp
mov    0xc(%rsp),%eax
jb     147d <check_bed_file_sorted+0x2dd>
test   %eax,%eax
je     131b <check_bed_file_sorted+0x17b>
mov    %rbp,%rax
xor    %ebp,%ebp
cmp    %rcx,%rax
jne    132b <check_bed_file_sorted+0x18b>
mov    0x10(%rsp),%rdi
add    $0x1,%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
mov    %rax,%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x9,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     145d <check_bed_file_sorted+0x2bd>
sub    %ebp,%eax
lea    0x20(%rsp),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movzbl 0x20(%rsp),%eax
jmp    1461 <check_bed_file_sorted+0x2c1>
movzbl 0x0(%r13),%eax
cmp    $0x2b,%al
setne  %r12b
mov    0x48(%rsp),%rax
mov    %rax,0x18(%rsp)
lea    0x70(%rsp),%rdi
lea    0x50(%rsp),%rsi
call   1050 <strcpy@plt>
mov    0xc(%rsp),%eax
add    $0x1,%eax
mov    %r12b,0xb(%rsp)
mov    %ebp,%r13d
mov    %eax,%r12d
lea    0xba8(%rip),%rbp
jmp    1200 <check_bed_file_sorted+0x60>
movzbl 0x0(%rbp),%eax
cmp    $0x2b,%al
setne  %r12b
cmp    %r12b,0xb(%rsp)
jne    1473 <check_bed_file_sorted+0x2d3>
mov    %r13d,%ebp
jmp    1430 <check_bed_file_sorted+0x290>
mov    $0x1,%ebp
test   %r13d,%r13d
je     1430 <check_bed_file_sorted+0x290>
xor    %esi,%esi
jmp    1486 <check_bed_file_sorted+0x2e6>
mov    $0x1,%esi
lea    0xb83(%rip),%rdi
call   1070 <printf@plt>
add    $0x498,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.chrm_entry = type { i32 }
@stdin = global i32 0
@.str = [2 x i8] c"#\00"
@.str.1 = [6 x i8] c"track\00"
@.str.2 = [8 x i8] c"browser\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @check_bed_file_sorted(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca [1024 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca [32 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.chrm_entry*
store i8 %0, i8* %2
%19 = bitcast [32 x i8]* %4 to i8*
%20 = bitcast [32 x i8]* %5 to i8*
store i64 -999999999, i64* %7
store i32 0, i32* %10
store i32 0, i32* %13
%21 = bitcast [32 x i8]* %15 to i8*
store i32 0, i32* %16
store i32 1, i32* %17
br label %22
22: ; preds = %241, %175, %37, %1
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = load i32, i32* @stdin
%25 = call i32* @fgets(i8* %23, i32 1024, i32 %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %242
27: ; preds = %22
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br i1 %31, label %37, label %32
32: ; preds = %27
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %38
37: ; preds = %32, %27
br label %22
38: ; preds = %32
%39 = load i8, i8* %2
%40 = zext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %54, label %42
42: ; preds = %38
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%44 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %240
46: ; preds = %42
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %240
50: ; preds = %46
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%52 = call i64 @strncmp(i8* %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %240
54: ; preds = %50, %38
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8* %55, i8** %11
%56 = load i8*, i8** %11
%57 = call i8* @strchr(i8* %56, i8 signext 9)
store i8* %57, i8** %12
%58 = load i8*, i8** %12
%59 = load i8*, i8** %11
%60 = ptrtoint i8* %58 to i64
%61 = ptrtoint i8* %59 to i64
%62 = sub i64 %60, %61
%63 = trunc i64 %62 to i32
store i32 %63, i32* %14
%64 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%65 = load i8*, i8** %11
%66 = load i32, i32* %14
%67 = call i32 @strncpy(i8* %64, i8* %65, i32 %66)
%68 = load i32, i32* %14
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 %69
store i8 0, i8* %70
%71 = load i8*, i8** %12
%72 = getelementptr inbounds i8, i8* %71, i64 1
store i8* %72, i8** %11
%73 = load i8*, i8** %11
%74 = call i8* @strchr(i8* %73, i8 signext 9)
store i8* %74, i8** %12
%75 = load i8*, i8** %12
%76 = load i8*, i8** %11
%77 = ptrtoint i8* %75 to i64
%78 = ptrtoint i8* %76 to i64
%79 = sub i64 %77, %78
%80 = trunc i64 %79 to i32
store i32 %80, i32* %14
%81 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%82 = load i8*, i8** %11
%83 = load i32, i32* %14
%84 = call i32 @strncpy(i8* %81, i8* %82, i32 %83)
%85 = load i32, i32* %14
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 %86
store i8 0, i8* %87
%88 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%89 = call i64 @atol(i8* %88)
store i64 %89, i64* %6
%90 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%91 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%92 = call i32 @strcmp(i8* %90, i8* %91)
store i32 %92, i32* %13
%93 = load i32, i32* %13
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %104
95: ; preds = %54
%96 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%97 = call %struct.chrm_entry* @lookup_chrm(i8* %96)
store %struct.chrm_entry* %97, %struct.chrm_entry** %18
%98 = icmp ne %struct.chrm_entry* %97, null
br i1 %98, label %99, label %100
99: ; preds = %95
store i32 0, i32* %17
br label %242
100: ; preds = %95
%101 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%102 = call %struct.chrm_entry* @put_chrm(i8* %101, i32 1)
store %struct.chrm_entry* %102, %struct.chrm_entry** %18
br label %103
103: ; preds = %100
br label %187
104: ; preds = %54
%105 = load i64, i64* %6
%106 = load i64, i64* %7
%107 = icmp ult i64 %105, %106
br i1 %107, label %108, label %109
108: ; preds = %104
store i32 0, i32* %17
br label %242
109: ; preds = %104
%110 = load i32, i32* %10
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %109
%113 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%114 = call %struct.chrm_entry* @put_chrm(i8* %113, i32 1)
store %struct.chrm_entry* %114, %struct.chrm_entry** %18
br label %185
115: ; preds = %109
%116 = load i64, i64* %6
%117 = load i64, i64* %7
%118 = icmp eq i64 %116, %117
br i1 %118, label %119, label %183
119: ; preds = %115
%120 = load i8*, i8** %12
%121 = getelementptr inbounds i8, i8* %120, i64 1
store i8* %121, i8** %11
%122 = load i8*, i8** %11
%123 = call i8* @strchr(i8* %122, i8 signext 9)
store i8* %123, i8** %12
%124 = load i8*, i8** %12
%125 = getelementptr inbounds i8, i8* %124, i64 1
store i8* %125, i8** %11
%126 = load i8*, i8** %11
%127 = call i8* @strchr(i8* %126, i8 signext 9)
store i8* %127, i8** %12
%128 = load i8*, i8** %12
%129 = getelementptr inbounds i8, i8* %128, i64 1
store i8* %129, i8** %11
%130 = load i8*, i8** %11
%131 = call i8* @strchr(i8* %130, i8 signext 9)
store i8* %131, i8** %12
%132 = load i8*, i8** %12
%133 = getelementptr inbounds i8, i8* %132, i64 1
store i8* %133, i8** %11
%134 = load i8*, i8** %11
%135 = call i8* @strchr(i8* %134, i8 signext 9)
store i8* %135, i8** %12
%136 = load i8*, i8** %12
%137 = icmp eq i8* %136, null
br i1 %137, label %138, label %146
138: ; preds = %119
%139 = load i8*, i8** %11
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = icmp eq i32 %141, 43
br i1 %142, label %143, label %144
143: ; preds = %138
store i8 0, i8* %8
br label %145
144: ; preds = %138
store i8 1, i8* %8
br label %145
145: ; preds = %144, %143
br label %164
146: ; preds = %119
%147 = load i8*, i8** %12
%148 = load i8*, i8** %11
%149 = ptrtoint i8* %147 to i64
%150 = ptrtoint i8* %148 to i64
%151 = sub i64 %149, %150
%152 = trunc i64 %151 to i32
store i32 %152, i32* %14
%153 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%154 = load i8*, i8** %11
%155 = load i32, i32* %14
%156 = call i32 @strncpy(i8* %153, i8* %154, i32 %155)
%157 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%158 = load i8, i8* %157
%159 = sext i8 %158 to i32
%160 = icmp eq i32 %159, 43
br i1 %160, label %161, label %162
161: ; preds = %146
store i8 0, i8* %8
br label %163
162: ; preds = %146
store i8 1, i8* %8
br label %163
163: ; preds = %162, %161
br label %164
164: ; preds = %163, %145
%165 = load i8, i8* %9
%166 = zext i8 %165 to i32
%167 = load i8, i8* %8
%168 = zext i8 %167 to i32
%169 = icmp ne i32 %166, %168
br i1 %169, label %170, label %175
170: ; preds = %164
%171 = load i32, i32* %16
%172 = icmp ne i32 %171, 0
br i1 %172, label %173, label %174
173: ; preds = %170
store i32 0, i32* %17
br label %242
174: ; preds = %170
store i32 1, i32* %16
br label %175
175: ; preds = %174, %164
%176 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%177 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%178 = call i32 @strcpy(i8* %176, i8* %177)
%179 = load i64, i64* %6
store i64 %179, i64* %7
%180 = load i8, i8* %8
store i8 %180, i8* %9
%181 = load i32, i32* %10
%182 = add i32 %181, 1
store i32 %182, i32* %10
br label %22
183: ; preds = %115
store i32 0, i32* %16
br label %184
184: ; preds = %183
br label %185
185: ; preds = %184, %112
br label %186
186: ; preds = %185
br label %187
187: ; preds = %186, %103
%188 = load i8*, i8** %12
%189 = getelementptr inbounds i8, i8* %188, i64 1
store i8* %189, i8** %11
%190 = load i8*, i8** %11
%191 = call i8* @strchr(i8* %190, i8 signext 9)
store i8* %191, i8** %12
%192 = load i8*, i8** %12
%193 = getelementptr inbounds i8, i8* %192, i64 1
store i8* %193, i8** %11
%194 = load i8*, i8** %11
%195 = call i8* @strchr(i8* %194, i8 signext 9)
store i8* %195, i8** %12
%196 = load i8*, i8** %12
%197 = getelementptr inbounds i8, i8* %196, i64 1
store i8* %197, i8** %11
%198 = load i8*, i8** %11
%199 = call i8* @strchr(i8* %198, i8 signext 9)
store i8* %199, i8** %12
%200 = load i8*, i8** %12
%201 = getelementptr inbounds i8, i8* %200, i64 1
store i8* %201, i8** %11
%202 = load i8*, i8** %11
%203 = call i8* @strchr(i8* %202, i8 signext 9)
store i8* %203, i8** %12
%204 = load i8*, i8** %12
%205 = icmp eq i8* %204, null
br i1 %205, label %206, label %214
206: ; preds = %187
%207 = load i8*, i8** %11
%208 = load i8, i8* %207
%209 = sext i8 %208 to i32
%210 = icmp eq i32 %209, 43
br i1 %210, label %211, label %212
211: ; preds = %206
store i8 0, i8* %8
br label %213
212: ; preds = %206
store i8 1, i8* %8
br label %213
213: ; preds = %212, %211
br label %232
214: ; preds = %187
%215 = load i8*, i8** %12
%216 = load i8*, i8** %11
%217 = ptrtoint i8* %215 to i64
%218 = ptrtoint i8* %216 to i64
%219 = sub i64 %217, %218
%220 = trunc i64 %219 to i32
store i32 %220, i32* %14
%221 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%222 = load i8*, i8** %11
%223 = load i32, i32* %14
%224 = call i32 @strncpy(i8* %221, i8* %222, i32 %223)
%225 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%226 = load i8, i8* %225
%227 = sext i8 %226 to i32
%228 = icmp eq i32 %227, 43
br i1 %228, label %229, label %230
229: ; preds = %214
store i8 0, i8* %8
br label %231
230: ; preds = %214
store i8 1, i8* %8
br label %231
231: ; preds = %230, %229
br label %232
232: ; preds = %231, %213
%233 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%234 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%235 = call i32 @strcpy(i8* %233, i8* %234)
%236 = load i64, i64* %6
store i64 %236, i64* %7
%237 = load i8, i8* %8
store i8 %237, i8* %9
%238 = load i32, i32* %10
%239 = add i32 %238, 1
store i32 %239, i32* %10
br label %240
240: ; preds = %232, %50, %46, %42
br label %241
241: ; preds = %240
br label %22
242: ; preds = %173, %108, %99, %22
%243 = load i32, i32* %17
%244 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %243)
ret void
}

LLVM IR (-O2):
%struct.chrm_entry = type { i32 }
@stdin = global i32 0
@.str = [2 x i8] c"#\00"
@.str.1 = [6 x i8] c"track\00"
@.str.2 = [8 x i8] c"browser\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @check_bed_file_sorted(i8 zeroext %0) {
%2 = alloca [1024 x i8]
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1
%11 = icmp eq i8 %0, 0
%12 = ptrtoint [1024 x i8]* %2 to i64
br label %13
13: ; preds = %123, %1
%14 = phi i64 [ %124, %123 ], [ -999999999, %1 ]
%15 = phi i8 [ %125, %123 ], [ undef, %1 ]
%16 = phi i32 [ %128, %123 ], [ 0, %1 ]
%17 = phi i32 [ %126, %123 ], [ 0, %1 ]
br label %18
18: ; preds = %39, %13
br label %19
19: ; preds = %18, %23
%20 = load i32, i32* @stdin
%21 = call i32* @fgets(i8* %6, i32 1024, i32 %20)
%22 = icmp eq i32* %21, null
br i1 %22, label %129, label %23
23: ; preds = %19
%24 = load i8, i8* %6
%25 = icmp eq i8 %24, 10
%26 = load i8, i8* %10
%27 = icmp eq i8 %26, 10
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %19, label %29
29: ; preds = %23
br i1 %11, label %30, label %40
30: ; preds = %29
%31 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%35 = icmp eq i64 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36, %33, %30
br label %18
40: ; preds = %36, %29
%41 = call i8* @strchr(i8* %6, i8 signext 9)
%42 = ptrtoint i8* %41 to i64
%43 = sub i64 %42, %12
%44 = trunc i64 %43 to i32
%45 = call i32 @strncpy(i8* %7, i8* %6, i32 %44)
%46 = shl i64 %43, 32
%47 = ashr exact i64 %46, 32
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %47
store i8 0, i8* %48
%49 = getelementptr inbounds i8, i8* %41, i64 1
%50 = call i8* @strchr(i8* %49, i8 signext 9)
%51 = ptrtoint i8* %50 to i64
%52 = ptrtoint i8* %49 to i64
%53 = sub i64 %51, %52
%54 = trunc i64 %53 to i32
%55 = call i32 @strncpy(i8* %9, i8* %49, i32 %54)
%56 = shl i64 %53, 32
%57 = ashr exact i64 %56, 32
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %57
store i8 0, i8* %58
%59 = call i64 @atol(i8* %9)
%60 = call i32 @strcmp(i8* %7, i8* %8)
%61 = icmp eq i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %40
%63 = call %struct.chrm_entry* @lookup_chrm(i8* %7)
%64 = icmp eq %struct.chrm_entry* %63, null
br i1 %64, label %97, label %129
65: ; preds = %40
%66 = icmp ult i64 %59, %14
br i1 %66, label %129, label %67
67: ; preds = %65
%68 = icmp eq i32 %16, 0
br i1 %68, label %97, label %69
69: ; preds = %67
%70 = icmp eq i64 %59, %14
br i1 %70, label %71, label %99
71: ; preds = %69
%72 = getelementptr inbounds i8, i8* %50, i64 1
%73 = call i8* @strchr(i8* %72, i8 signext 9)
%74 = getelementptr inbounds i8, i8* %73, i64 1
%75 = call i8* @strchr(i8* %74, i8 signext 9)
%76 = getelementptr inbounds i8, i8* %75, i64 1
%77 = call i8* @strchr(i8* %76, i8 signext 9)
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = call i8* @strchr(i8* %78, i8 signext 9)
%80 = icmp eq i8* %79, null
br i1 %80, label %81, label %83
81: ; preds = %71
%82 = load i8, i8* %78
br label %90
83: ; preds = %71
%84 = ptrtoint i8* %79 to i64
%85 = ptrtoint i8* %78 to i64
%86 = sub i64 %84, %85
%87 = trunc i64 %86 to i32
%88 = call i32 @strncpy(i8* %9, i8* %78, i32 %87)
%89 = load i8, i8* %9
br label %90
90: ; preds = %83, %81
%91 = phi i8 [ %82, %81 ], [ %89, %83 ]
%92 = icmp ne i8 %91, 43
%93 = zext i1 %92 to i8
%94 = icmp eq i8 %15, %93
br i1 %94, label %123, label %95
95: ; preds = %90
%96 = icmp eq i32 %17, 0
br i1 %96, label %123, label %129
97: ; preds = %67, %62
%98 = call %struct.chrm_entry* @put_chrm(i8* %7, i32 1)
br label %99
99: ; preds = %97, %69
%100 = phi i32 [ 0, %69 ], [ %17, %97 ]
%101 = getelementptr inbounds i8, i8* %50, i64 1
%102 = call i8* @strchr(i8* %101, i8 signext 9)
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = call i8* @strchr(i8* %103, i8 signext 9)
%105 = getelementptr inbounds i8, i8* %104, i64 1
%106 = call i8* @strchr(i8* %105, i8 signext 9)
%107 = getelementptr inbounds i8, i8* %106, i64 1
%108 = call i8* @strchr(i8* %107, i8 signext 9)
%109 = icmp eq i8* %108, null
br i1 %109, label %110, label %112
110: ; preds = %99
%111 = load i8, i8* %107
br label %119
112: ; preds = %99
%113 = ptrtoint i8* %108 to i64
%114 = ptrtoint i8* %107 to i64
%115 = sub i64 %113, %114
%116 = trunc i64 %115 to i32
%117 = call i32 @strncpy(i8* %9, i8* %107, i32 %116)
%118 = load i8, i8* %9
br label %119
119: ; preds = %112, %110
%120 = phi i8 [ %111, %110 ], [ %118, %112 ]
%121 = icmp ne i8 %120, 43
%122 = zext i1 %121 to i8
br label %123
123: ; preds = %90, %95, %119
%124 = phi i64 [ %59, %119 ], [ %14, %95 ], [ %14, %90 ]
%125 = phi i8 [ %122, %119 ], [ %93, %95 ], [ %93, %90 ]
%126 = phi i32 [ %100, %119 ], [ 1, %95 ], [ %17, %90 ]
%127 = call i32 @strcpy(i8* %8, i8* %7)
%128 = add i32 %16, 1
br label %13
129: ; preds = %95, %65, %62, %19
%130 = phi i32 [ 1, %19 ], [ 0, %62 ], [ 0, %65 ], [ 0, %95 ]
%131 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %130)
ret void
}