#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*/ z_stream;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
struct stat {
  long st_size;
};
typedef int /*<<< orphan*/ gz_header;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ fstat(int, struct stat *);
int ftell(int /*<<< orphan*/ *);
int get_header_for_zstream(int /*<<< orphan*/ *, char *, int, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *f;
  int err;
  char *inname;
  gz_header zhead;
  z_stream zs;
  int ret;
  char zname[512];
  struct tm *mtimeinfo;
  time_t mtime;
  struct stat filestat;
  long filesize;
  long fposa;
  long fposb;
  inname = argv[1];
  f = fopen(inname, "r");
  if (f == NULL) {
    fprintf(stderr, "ERROR: Unable to open file %s\n", inname);
    exit(1);
  }
  int fd = fileno(f);
  fstat(fd, &filestat);
  filesize = filestat.st_size;
  fposa = ftell(f);
  fposb = fposa;
  int loopctr = 1;
  while (!feof(f) && fposb != filesize) {
    fposa = ftell(f);
    printf("----------------\n");
    printf("Byte position (0-based) of beginning of member %d is %d.\n",
           loopctr, ftell(f));
    ret = get_header_for_zstream(f, inname, loopctr, filesize);
    fseek(f, (fposa + ret), SEEK_SET);
    fposb = ftell(f);
    printf("Byte position (0-based) of end of member %d is %d.\n", loopctr,
           (ftell(f) - 1));
    printf("----------------\n");
    loopctr++;
  }
  fclose(f);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1217 <main+0x67>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdfa(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1080 <fileno@plt>
mov    %eax,-0x274(%rbp)
mov    -0x274(%rbp),%edi
lea    -0x258(%rbp),%rsi
call   10d0 <fstat@plt>
mov    -0x258(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
cltq
mov    %rax,-0x268(%rbp)
mov    -0x268(%rbp),%rax
mov    %rax,-0x270(%rbp)
movl   $0x1,-0x278(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x279(%rbp)
jne    12a3 <main+0xf3>
mov    -0x270(%rbp),%rax
cmp    -0x260(%rbp),%rax
setne  %al
mov    %al,-0x279(%rbp)
mov    -0x279(%rbp),%al
test   $0x1,%al
jne    12b6 <main+0x106>
jmp    13a0 <main+0x1f0>
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
cltq
mov    %rax,-0x268(%rbp)
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x278(%rbp),%eax
mov    %eax,-0x284(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
mov    -0x284(%rbp),%esi
mov    %eax,%edx
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x278(%rbp),%edx
mov    -0x260(%rbp),%rcx
call   1090 <get_header_for_zstream@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x268(%rbp),%rsi
movslq -0x34(%rbp),%rax
add    %rax,%rsi
mov    0x2ca1(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
cltq
mov    %rax,-0x270(%rbp)
mov    -0x278(%rbp),%eax
mov    %eax,-0x280(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
mov    -0x280(%rbp),%esi
mov    %eax,%edx
sub    $0x1,%edx
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x278(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x278(%rbp)
jmp    1270 <main+0xc0>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x34(%rbp),%eax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
lea    0xe27(%rip),%rsi
mov    %rdi,0x8(%rsp)
call   10c0 <fopen@plt>
test   %rax,%rax
je     12fc <main+0x13c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <fileno@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   10e0 <fstat@plt>
mov    0x10(%rsp),%r15
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    12e2 <main+0x122>
movslq %ebp,%rax
cmp    %rax,%r15
je     12e2 <main+0x122>
mov    $0x1,%ebp
lea    0xe55(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <ftell@plt>
movslq %eax,%r14
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
lea    0xdbf(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    %ebp,%edx
mov    %r15,%rcx
call   10a0 <get_header_for_zstream@plt>
mov    %eax,%r13d
movslq %eax,%rsi
add    %r14,%rsi
mov    0x2d49(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   10b0 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1070 <ftell@plt>
lea    -0x1(%rax),%edx
lea    0xda5(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    12e2 <main+0x122>
add    $0x1,%ebp
movslq %r14d,%rax
cmp    %rax,%r15
jne    1240 <main+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xcf6(%rip),%rsi
mov    0x8(%rsp),%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.stat = type { i64 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"ERROR: Unable to open file %s\0A\00"
@.str.2 = [18 x i8] c"----------------\0A\00"
@.str.3 = [58 x i8] c"Byte position (0-based) of beginning of member %d is %d.\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [52 x i8] c"Byte position (0-based) of end of member %d is %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [512 x i8]
%13 = alloca %struct.tm*
%14 = alloca i32
%15 = alloca %struct.stat
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %33
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %8
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %2
%34 = load i32*, i32** %6
%35 = call i32 @fileno(i32* %34)
store i32 %35, i32* %19
%36 = load i32, i32* %19
%37 = call i32 @fstat(i32 %36, %struct.stat* %15)
%38 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%39 = load i64, i64* %38
store i64 %39, i64* %16
%40 = load i32*, i32** %6
%41 = call i32 @ftell(i32* %40)
%42 = sext i32 %41 to i64
store i64 %42, i64* %17
%43 = load i64, i64* %17
store i64 %43, i64* %18
store i32 1, i32* %20
br label %44
44: ; preds = %54, %33
%45 = load i32*, i32** %6
%46 = call i32 @feof(i32* %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = load i64, i64* %18
%50 = load i64, i64* %16
%51 = icmp ne i64 %49, %50
br label %52
52: ; preds = %48, %44
%53 = phi i1 [ false, %44 ], [ %51, %48 ]
br i1 %53, label %54, label %86
54: ; preds = %52
%55 = load i32*, i32** %6
%56 = call i32 @ftell(i32* %55)
%57 = sext i32 %56 to i64
store i64 %57, i64* %17
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%59 = load i32, i32* %20
%60 = load i32*, i32** %6
%61 = call i32 @ftell(i32* %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %59, i32 %61)
%63 = load i32*, i32** %6
%64 = load i8*, i8** %8
%65 = load i32, i32* %20
%66 = load i64, i64* %16
%67 = call i32 @get_header_for_zstream(i32* %63, i8* %64, i32 %65, i64 %66)
store i32 %67, i32* %11
%68 = load i32*, i32** %6
%69 = load i64, i64* %17
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = add nsw i64 %69, %71
%73 = load i32, i32* @SEEK_SET
%74 = call i32 @fseek(i32* %68, i64 %72, i32 %73)
%75 = load i32*, i32** %6
%76 = call i32 @ftell(i32* %75)
%77 = sext i32 %76 to i64
store i64 %77, i64* %18
%78 = load i32, i32* %20
%79 = load i32*, i32** %6
%80 = call i32 @ftell(i32* %79)
%81 = sub nsw i32 %80, 1
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %78, i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%84 = load i32, i32* %20
%85 = add nsw i32 %84, 1
store i32 %85, i32* %20
br label %44
86: ; preds = %52
%87 = load i32*, i32** %6
%88 = call i32 @fclose(i32* %87)
%89 = load i32, i32* %11
ret i32 %89
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.tm = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"ERROR: Unable to open file %s\0A\00"
@.str.3 = [58 x i8] c"Byte position (0-based) of beginning of member %d is %d.\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [52 x i8] c"Byte position (0-based) of end of member %d is %d.\0A\00"
@str.5 = [17 x i8] c"----------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = tail call i32 @fileno(i32* %7)
%15 = call i32 @fstat(i32 %14, %struct.stat* %3)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%17 = load i64, i64* %16
%18 = tail call i32 @ftell(i32* %7)
%19 = sext i32 %18 to i64
%20 = tail call i32 @feof(i32* %7)
%21 = icmp eq i32 %20, 0
%22 = icmp ne i64 %17, %19
%23 = select i1 %21, i1 %22, i1 false
br i1 %23, label %24, label %47
24: ; preds = %13, %24
%25 = phi i32 [ %41, %24 ], [ 1, %13 ]
%26 = tail call i32 @ftell(i32* %7)
%27 = sext i32 %26 to i64
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%29 = tail call i32 @ftell(i32* %7)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %29)
%31 = tail call i32 @get_header_for_zstream(i32* %7, i8* %6, i32 %25, i64 %17)
%32 = sext i32 %31 to i64
%33 = add nsw i64 %32, %27
%34 = load i32, i32* @SEEK_SET
%35 = tail call i32 @fseek(i32* %7, i64 %33, i32 %34)
%36 = tail call i32 @ftell(i32* %7)
%37 = tail call i32 @ftell(i32* %7)
%38 = add nsw i32 %37, -1
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %38)
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%41 = add nuw nsw i32 %25, 1
%42 = sext i32 %36 to i64
%43 = tail call i32 @feof(i32* %7)
%44 = icmp eq i32 %43, 0
%45 = icmp ne i64 %17, %42
%46 = select i1 %44, i1 %45, i1 false
br i1 %46, label %24, label %47
47: ; preds = %24, %13
%48 = phi i32 [ undef, %13 ], [ %31, %24 ]
%49 = tail call i32 @fclose(i32* %7)
ret i32 %48
}