#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, size_t const, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, char *, int *, int *);
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  FILE *fptr = stdin;
  if (fptr == NULL) {
    printf("No stdin was presents");
    return 0;
  }
  const size_t line_size = 31;
  char line[line_size];
  int last_depth = -1;
  int last_loc = 0;
  int prev_loc = -1;
  char prev_chr[line_size];
  prev_chr[0] = 0;
  char chr[line_size];
  int loc, depth;
  char track_name[line_size];
  if (argc > 1)
    strcpy(track_name, argv[1]);
  else
    strcpy(track_name, "cov_track");
  while (fgets(line, line_size, fptr) != NULL) {
    sscanf(line, "%s\t%d\t%d", chr, &loc, &depth);
    if (strcmp(prev_chr, chr) != 0 || depth != last_depth) {
      if (last_depth != -1) {
        printf("%s\t%d\t%d\t%d\n", prev_chr, prev_loc - 1, last_loc,
               last_depth);
        strcpy(prev_chr, chr);
        prev_loc = loc;
      } else {
        strcpy(prev_chr, chr);
        prev_loc = loc;
      }
    }
    last_depth = depth;
    last_loc = loc;
  }
  printf("%s\t%d\t%d\t%d\n", prev_chr, prev_loc - 1, last_loc - 1, last_depth);
  fclose(fptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a9 <main+0x49>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    133f <main+0x1df>
movq   $0x1f,-0x20(%rbp)
mov    %rsp,%rax
mov    %rax,-0x28(%rbp)
mov    %rsp,%rax
add    $0xffffffffffffffe0,%rax
mov    %rax,-0x60(%rbp)
mov    %rax,%rsp
movl   $0xffffffff,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
mov    %rsp,%rax
mov    %rax,%rcx
add    $0xffffffffffffffe0,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
movb   $0x0,-0x20(%rax)
mov    %rsp,%rax
add    $0xffffffffffffffe0,%rax
mov    %rax,-0x50(%rbp)
mov    %rax,%rsp
mov    %rsp,%rax
add    $0xffffffffffffffe0,%rax
mov    %rax,-0x48(%rbp)
mov    %rax,%rsp
cmpl   $0x1,-0x8(%rbp)
jle    122c <main+0xcc>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
jmp    123c <main+0xdc>
mov    -0x48(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1241 <main+0xe1>
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1f,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1306 <main+0x1a6>
mov    -0x50(%rbp),%rdx
mov    -0x60(%rbp),%rdi
lea    0xdb4(%rip),%rsi
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1080 <sscanf@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    129c <main+0x13c>
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     12f5 <main+0x195>
cmpl   $0xffffffff,-0x2c(%rbp)
je     12dd <main+0x17d>
mov    -0x58(%rbp),%rsi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    12f0 <main+0x190>
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    12f5 <main+0x195>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1241 <main+0xe1>
mov    -0x58(%rbp),%rsi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x2c(%rbp),%r8d
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e70(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
test   %rax,%rax
je     11c6 <main+0x66>
mov    %rsp,%rcx
mov    %rsp,%rbx
add    $0xffffffffffffffe0,%rbx
mov    %rbx,%rsp
mov    %rsp,%rax
lea    -0x20(%rax),%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
movb   $0x0,-0x20(%rax)
mov    %rsp,%r14
add    $0xffffffffffffffe0,%r14
mov    %r14,%rsp
mov    %rsp,%rax
add    $0xffffffffffffffe0,%rax
mov    %rax,%rsp
cmp    $0x2,%edi
mov    %rcx,-0x50(%rbp)
jl     11d9 <main+0x79>
mov    0x8(%rsi),%rsi
jmp    11e0 <main+0x80>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1318 <main+0x1b8>
lea    0xe36(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x1f,%esi
mov    %rbx,%rdi
mov    -0x48(%rbp),%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12d6 <main+0x176>
movl   $0xffffffff,-0x30(%rbp)
lea    0xe10(%rip),%r12
lea    -0x34(%rbp),%r13
movl   $0x0,-0x2c(%rbp)
mov    $0xffffffff,%r15d
jmp    1254 <main+0xf4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%r15d
mov    $0x1f,%esi
mov    %rbx,%rdi
mov    -0x48(%rbp),%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12ea <main+0x18a>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
lea    -0x38(%rbp),%r8
call   1080 <sscanf@plt>
mov    -0x40(%rbp),%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1280 <main+0x120>
cmp    %r15d,-0x38(%rbp)
je     1230 <main+0xd0>
cmp    $0xffffffff,%r15d
je     12bc <main+0x15c>
mov    -0x30(%rbp),%edx
add    $0xffffffff,%edx
lea    0xd96(%rip),%rdi
mov    %r14,%r13
mov    %r12,%r14
mov    -0x40(%rbp),%r12
mov    %r12,%rsi
mov    -0x2c(%rbp),%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r14,%r12
mov    %r13,%r14
lea    -0x34(%rbp),%r13
jmp    12c0 <main+0x160>
mov    -0x40(%rbp),%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    %eax,-0x30(%rbp)
jmp    1236 <main+0xd6>
movl   $0x0,-0x2c(%rbp)
mov    $0xffffffff,%r15d
movl   $0xffffffff,-0x30(%rbp)
mov    -0x30(%rbp),%edx
add    $0xffffffff,%edx
mov    -0x2c(%rbp),%ecx
add    $0xffffffff,%ecx
lea    0xd2c(%rip),%rdi
mov    -0x40(%rbp),%rsi
mov    %r15d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x50(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [22 x i8] c"No stdin was presents\00"
@.str.1 = [10 x i8] c"cov_track\00"
@.str.2 = [9 x i8] c"%s\09%d\09%d\00"
@.str.3 = [13 x i8] c"%s\09%d\09%d\09%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32*, i32** @stdin
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %76
19: ; preds = %2
store i64 31, i64* %7
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %8
%21 = alloca i8, i64 31
store i32 -1, i32* %9
store i32 0, i32* %10
store i32 -1, i32* %11
%22 = alloca i8, i64 31
%23 = getelementptr inbounds i8, i8* %22, i64 0
store i8 0, i8* %23
%24 = alloca i8, i64 31
%25 = alloca i8, i64 31
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %33
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcpy(i8* %25, i8* %31)
br label %35
33: ; preds = %19
%34 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
br label %36
36: ; preds = %63, %35
%37 = load i32*, i32** %6
%38 = call i32* @fgets(i8* %21, i64 31, i32* %37)
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %66
40: ; preds = %36
%41 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32* %12, i32* %13)
%42 = call i64 @strcmp(i8* %22, i8* %24)
%43 = icmp ne i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i32, i32* %13
%46 = load i32, i32* %9
%47 = icmp ne i32 %45, %46
br i1 %47, label %48, label %63
48: ; preds = %44, %40
%49 = load i32, i32* %9
%50 = icmp ne i32 %49, -1
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i32, i32* %11
%53 = sub nsw i32 %52, 1
%54 = load i32, i32* %10
%55 = load i32, i32* %9
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %22, i32 %53, i32 %54, i32 %55)
%57 = call i32 @strcpy(i8* %22, i8* %24)
%58 = load i32, i32* %12
store i32 %58, i32* %11
br label %62
59: ; preds = %48
%60 = call i32 @strcpy(i8* %22, i8* %24)
%61 = load i32, i32* %12
store i32 %61, i32* %11
br label %62
62: ; preds = %59, %51
br label %63
63: ; preds = %62, %44
%64 = load i32, i32* %13
store i32 %64, i32* %9
%65 = load i32, i32* %12
store i32 %65, i32* %10
br label %36
66: ; preds = %36
%67 = load i32, i32* %11
%68 = sub nsw i32 %67, 1
%69 = load i32, i32* %10
%70 = sub nsw i32 %69, 1
%71 = load i32, i32* %9
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %22, i32 %68, i32 %70, i32 %71)
%73 = load i32*, i32** %6
%74 = call i32 @fclose(i32* %73)
store i32 0, i32* %3
%75 = load i8*, i8** %8
br label %76
76: ; preds = %66, %17
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [22 x i8] c"No stdin was presents\00"
@.str.1 = [10 x i8] c"cov_track\00"
@.str.2 = [9 x i8] c"%s\09%d\09%d\00"
@.str.3 = [13 x i8] c"%s\09%d\09%d\09%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = load i32*, i32** @stdin
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %66
9: ; preds = %2
%10 = tail call i8* @llvm.stacksave()
%11 = alloca [31 x i8]
%12 = alloca [31 x i8]
%13 = getelementptr inbounds [31 x i8], [31 x i8]* %12, i64 0, i64 0
%14 = getelementptr inbounds [31 x i8], [31 x i8]* %11, i64 0, i64 0
store i8 0, i8* %13
%15 = alloca [31 x i8]
%16 = getelementptr inbounds [31 x i8], [31 x i8]* %15, i64 0, i64 0
%17 = bitcast i32* %3 to i8*
%18 = bitcast i32* %4 to i8*
%19 = alloca [31 x i8]
%20 = getelementptr inbounds [31 x i8], [31 x i8]* %19, i64 0, i64 0
%21 = icmp sgt i32 %0, 1
br i1 %21, label %22, label %25
22: ; preds = %9
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
br label %25
25: ; preds = %9, %22
%26 = phi i8* [ %24, %22 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %9 ]
%27 = call i32 @strcpy(i8* %20, i8* %26)
%28 = call i32* @fgets(i8* %14, i64 31, i32* %5)
%29 = icmp eq i32* %28, null
br i1 %29, label %58, label %30
30: ; preds = %25, %52
%31 = phi i32 [ %54, %52 ], [ -1, %25 ]
%32 = phi i32 [ %53, %52 ], [ 0, %25 ]
%33 = phi i32 [ %55, %52 ], [ -1, %25 ]
%34 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32* %3, i32* %4)
%35 = call i64 @strcmp(i8* %13, i8* %16)
%36 = icmp eq i64 %35, 0
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, %33
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %40, label %42
40: ; preds = %30
%41 = load i32, i32* %3
br label %52
42: ; preds = %30
%43 = icmp eq i32 %33, -1
br i1 %43, label %49, label %44
44: ; preds = %42
%45 = add nsw i32 %31, -1
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %13, i32 %45, i32 %32, i32 %33)
%47 = call i32 @strcpy(i8* %13, i8* %16)
%48 = load i32, i32* %3
br label %52
49: ; preds = %42
%50 = call i32 @strcpy(i8* %13, i8* %16)
%51 = load i32, i32* %3
br label %52
52: ; preds = %40, %44, %49
%53 = phi i32 [ %48, %44 ], [ %51, %49 ], [ %41, %40 ]
%54 = phi i32 [ %48, %44 ], [ %51, %49 ], [ %31, %40 ]
%55 = load i32, i32* %4
%56 = call i32* @fgets(i8* %14, i64 31, i32* %5)
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %30
58: ; preds = %52, %25
%59 = phi i32 [ -1, %25 ], [ %55, %52 ]
%60 = phi i32 [ 0, %25 ], [ %53, %52 ]
%61 = phi i32 [ -1, %25 ], [ %54, %52 ]
%62 = add nsw i32 %61, -1
%63 = add nsw i32 %60, -1
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %13, i32 %62, i32 %63, i32 %59)
%65 = call i32 @fclose(i32* %5)
br label %66
66: ; preds = %58, %7
ret i32 0
}