#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*/ tmp;
typedef int /*<<< orphan*/ *gzFile;

/* Variables and functions */
scalar_t__ Z_NULL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gzclose(int /*<<< orphan*/ *);
char *gzerror(int /*<<< orphan*/ *, int *);
scalar_t__ gzgets(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ *gzopen(char *, char *);
scalar_t__ mystrcmp(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int sscanf(char *, char *, char *, char *, long long *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
long long find_seq_in_hash(char *filename, char *sname) {
  char file_name[512];
  int error;
  char sname1[1024];
  char sname2[1024];
  long long gz_chunk = 0;
  char tmp[10000];
  long long res = -1;
  char min_name[1024];
  char max_name[1024];
  long long current_chunk = 0;
  strcpy(min_name, "");
  strcpy(max_name, "");
  snprintf(file_name, 512, "%s.index", filename);
  gzFile gzhash_file = gzopen(file_name, "r");
  if (gzhash_file == NULL) {
    fprintf(stderr, "error opening gzhash_file :%s\n",
            gzerror(gzhash_file, &error));
    return -2;
  }
  while (gzgets(gzhash_file, tmp, sizeof(tmp)) != Z_NULL) {
    int reads = sscanf(tmp, "%s %s %lld", sname1, sname2, &gz_chunk);
    if (reads == 3) {
      if ((mystrcmp(sname, sname1) >= 0) && (mystrcmp(sname, sname2) <= 0)) {
        printf("%s in [%s,%s]\n", sname, sname1, sname2);
        res = gz_chunk;
        break;
      } else {
        printf("%s NOT IN [%s,%s]\n", sname, sname1, sname2);
      }
    }
  }
  gzclose(gzhash_file);
  return res;
}


x86 assembly (clang, -O0):
<find_seq_in_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3980,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0xa38(%rbp)
movq   $0xffffffffffffffff,-0x3158(%rbp)
ff ff ff ff
movq   $0x0,-0x3968(%rbp)
lea    -0x3560(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0x3960(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xdef(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0x220(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   10c0 <gzopen@plt>
mov    %rax,-0x3970(%rbp)
cmpq   $0x0,-0x3970(%rbp)
jne    1282 <find_seq_in_hash+0xe2>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3978(%rbp)
mov    -0x3970(%rbp),%rdi
lea    -0x224(%rbp),%rsi
call   10a0 <gzerror@plt>
mov    -0x3978(%rbp),%edi
mov    %rax,%rdx
lea    0xd9b(%rip),%rsi
call   1090 <fprintf@plt>
movq   $0xfffffffffffffffe,-0x8(%rbp)
ff
jmp    138e <find_seq_in_hash+0x1ee>
jmp    1287 <find_seq_in_hash+0xe7>
mov    -0x3970(%rbp),%rdi
lea    -0x3150(%rbp),%rsi
mov    $0x2710,%edx
call   1060 <gzgets@plt>
mov    0x2d32(%rip),%rcx
cmp    (%rcx),%rax
je     1377 <find_seq_in_hash+0x1d7>
lea    -0x3150(%rbp),%rdi
lea    -0x630(%rbp),%rdx
lea    -0xa30(%rbp),%rcx
lea    0xd5f(%rip),%rsi
lea    -0xa38(%rbp),%r8
call   10b0 <sscanf@plt>
mov    %eax,-0x3974(%rbp)
cmpl   $0x3,-0x3974(%rbp)
jne    1372 <find_seq_in_hash+0x1d2>
mov    -0x18(%rbp),%rdi
lea    -0x630(%rbp),%rsi
call   1040 <mystrcmp@plt>
cmp    $0x0,%rax
jl     134f <find_seq_in_hash+0x1af>
mov    -0x18(%rbp),%rdi
lea    -0xa30(%rbp),%rsi
call   1040 <mystrcmp@plt>
cmp    $0x0,%rax
jg     134f <find_seq_in_hash+0x1af>
mov    -0x18(%rbp),%rsi
lea    -0x630(%rbp),%rdx
lea    -0xa30(%rbp),%rcx
lea    0xcfe(%rip),%rdi
call   1070 <printf@plt>
mov    -0xa38(%rbp),%rax
mov    %rax,-0x3158(%rbp)
jmp    1377 <find_seq_in_hash+0x1d7>
mov    -0x18(%rbp),%rsi
lea    -0x630(%rbp),%rdx
lea    -0xa30(%rbp),%rcx
lea    0xcdc(%rip),%rdi
call   1070 <printf@plt>
jmp    1372 <find_seq_in_hash+0x1d2>
jmp    1287 <find_seq_in_hash+0xe7>
mov    -0x3970(%rbp),%rdi
call   1030 <gzclose@plt>
mov    -0x3158(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x3980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_seq_in_hash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3928,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
lea    0xe8f(%rip),%rbp
lea    0xe10(%rsp),%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
lea    0xa10(%rsp),%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
lea    0xe12(%rip),%rdx
lea    0x810(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
call   1080 <snprintf@plt>
lea    0xdfc(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <gzopen@plt>
test   %rax,%rax
je     1305 <find_seq_in_hash+0x165>
mov    %rax,%r13
lea    0x1210(%rsp),%rsi
mov    %rax,%rdi
mov    $0x2710,%edx
call   1060 <gzgets@plt>
mov    0x2d9b(%rip),%rcx
mov    $0xffffffffffffffff,%rbx
cmp    (%rcx),%rax
je     133e <find_seq_in_hash+0x19e>
lea    0x1210(%rsp),%rbx
lea    0x410(%rsp),%rbp
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
jmp    12a5 <find_seq_in_hash+0x105>
nopl   0x0(%rax)
lea    0xdcd(%rip),%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1070 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x2710,%edx
call   1060 <gzgets@plt>
mov    0x2d3c(%rip),%rcx
cmp    (%rcx),%rax
je     1337 <find_seq_in_hash+0x197>
mov    %rbx,%rdi
lea    0xd7b(%rip),%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   10b0 <sscanf@plt>
cmp    $0x3,%eax
jne    1285 <find_seq_in_hash+0xe5>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1040 <mystrcmp@plt>
test   %rax,%rax
js     1270 <find_seq_in_hash+0xd0>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <mystrcmp@plt>
test   %rax,%rax
jg     1270 <find_seq_in_hash+0xd0>
lea    0xd4c(%rip),%rdi
lea    0x410(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r14,%rsi
call   1070 <printf@plt>
mov    0x8(%rsp),%rbx
jmp    133e <find_seq_in_hash+0x19e>
mov    0x2cd4(%rip),%rax
mov    (%rax),%ebx
lea    0x1210(%rsp),%rsi
xor    %edi,%edi
call   10a0 <gzerror@plt>
lea    0xce7(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1090 <fprintf@plt>
mov    $0xfffffffffffffffe,%rbx
jmp    1346 <find_seq_in_hash+0x1a6>
mov    $0xffffffffffffffff,%rbx
mov    %r13,%rdi
call   1030 <gzclose@plt>
mov    %rbx,%rax
add    $0x3928,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%s.index\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"error opening gzhash_file :%s\0A\00"
@Z_NULL = global i64 0
@.str.4 = [11 x i8] c"%s %s %lld\00"
@.str.5 = [15 x i8] c"%s in [%s,%s]\0A\00"
@.str.6 = [19 x i8] c"%s NOT IN [%s,%s]\0A\00"
define i64 @find_seq_in_hash(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [512 x i8]
%7 = alloca i32
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i64
%11 = alloca [10000 x i8]
%12 = alloca i64
%13 = alloca [1024 x i8]
%14 = alloca [1024 x i8]
%15 = alloca i64
%16 = alloca i32*
%17 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 0, i64* %10
store i64 -1, i64* %12
store i64 0, i64* %15
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%23 = load i8*, i8** %4
%24 = call i32 @snprintf(i8* %22, i32 512, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%26 = call i32* @gzopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %16
%27 = load i32*, i32** %16
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %34
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = load i32*, i32** %16
%32 = call i8* @gzerror(i32* %31, i32* %7)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %32)
store i64 -2, i64* %3
br label %75
34: ; preds = %2
br label %35
35: ; preds = %70, %34
%36 = load i32*, i32** %16
%37 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%38 = call i64 @gzgets(i32* %36, i8* %37, i32 10000)
%39 = load i64, i64* @Z_NULL
%40 = icmp ne i64 %38, %39
br i1 %40, label %41, label %71
41: ; preds = %35
%42 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i64 0, i64 0
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%45 = call i32 @sscanf(i8* %42, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %43, i8* %44, i64* %10)
store i32 %45, i32* %17
%46 = load i32, i32* %17
%47 = icmp eq i32 %46, 3
br i1 %47, label %48, label %70
48: ; preds = %41
%49 = load i8*, i8** %5
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%51 = call i64 @mystrcmp(i8* %49, i8* %50)
%52 = icmp sge i64 %51, 0
br i1 %52, label %53, label %64
53: ; preds = %48
%54 = load i8*, i8** %5
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%56 = call i64 @mystrcmp(i8* %54, i8* %55)
%57 = icmp sle i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %53
%59 = load i8*, i8** %5
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%62 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %59, i8* %60, i8* %61)
%63 = load i64, i64* %10
store i64 %63, i64* %12
br label %71
64: ; preds = %53, %48
%65 = load i8*, i8** %5
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%68 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %65, i8* %66, i8* %67)
br label %69
69: ; preds = %64
br label %70
70: ; preds = %69, %41
br label %35
71: ; preds = %58, %35
%72 = load i32*, i32** %16
%73 = call i32 @gzclose(i32* %72)
%74 = load i64, i64* %12
store i64 %74, i64* %3
br label %75
75: ; preds = %71, %29
%76 = load i64, i64* %3
ret i64 %76
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%s.index\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"error opening gzhash_file :%s\0A\00"
@Z_NULL = global i64 0
@.str.4 = [11 x i8] c"%s %s %lld\00"
@.str.5 = [15 x i8] c"%s in [%s,%s]\0A\00"
@.str.6 = [19 x i8] c"%s NOT IN [%s,%s]\0A\00"
define i64 @find_seq_in_hash(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i64
%8 = alloca [10000 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%12 = bitcast i32* %4 to i8*
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%16 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%19 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @snprintf(i8* %11, i32 512, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%22 = call i32* @gzopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %28, label %24
24: ; preds = %2
%25 = call i64 @gzgets(i32* %22, i8* %16, i32 10000)
%26 = load i64, i64* @Z_NULL
%27 = icmp eq i64 %25, %26
br i1 %27, label %50, label %32
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = call i8* @gzerror(i32* null, i32* %4)
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %53
32: ; preds = %24, %46
%33 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* %14, i64* %7)
%34 = icmp eq i32 %33, 3
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = call i64 @mystrcmp(i8* %1, i8* %13)
%37 = icmp sgt i64 %36, -1
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = call i64 @mystrcmp(i8* %1, i8* %14)
%40 = icmp slt i64 %39, 1
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %13, i8* %14)
%43 = load i64, i64* %7
br label %50
44: ; preds = %38, %35
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %1, i8* %13, i8* %14)
br label %46
46: ; preds = %32, %44
%47 = call i64 @gzgets(i32* %22, i8* %16, i32 10000)
%48 = load i64, i64* @Z_NULL
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %32
50: ; preds = %46, %24, %41
%51 = phi i64 [ %43, %41 ], [ -1, %24 ], [ -1, %46 ]
%52 = call i32 @gzclose(i32* %22)
br label %53
53: ; preds = %50, %28
%54 = phi i64 [ -2, %28 ], [ %51, %50 ]
ret i64 %54
}