#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 stat {
  long st_size;
};
typedef int /*<<< orphan*/ caddr_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_PRIVATE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ fstat(int, struct stat *);
char *mmap(int /*<<< orphan*/, long, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int main() {
  char *fName =
      "/storage3/1000genomes/ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/"
      "20130502/"
      "ALL.chr22.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf";
  struct stat sb;
  long cntr = 0;
  int fd, lineLen;
  char *data;
  char *line;
  fd = open(fName, O_RDONLY);
  fstat(fd, &sb);
  data = mmap((caddr_t)0, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
  line = data;
  while (cntr < sb.st_size) {
    lineLen = 0;
    line = data;
    while (*data != '\n' && cntr < sb.st_size) {
      data++;
      cntr++;
      lineLen++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1050 <fstat@plt>
mov    -0x18(%rbp),%rsi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
mov    0x2e49(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    121f <main+0xef>
movl   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x39(%rbp)
je     11e4 <main+0xb4>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11f4 <main+0xc4>
jmp    121a <main+0xea>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c1 <main+0x91>
jmp    11a4 <main+0x74>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
lea    0xebb(%rip),%rdi
call   1040 <open@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1050 <fstat@plt>
mov    0x8(%rsp),%rsi
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
mov    0x2e63(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [146 x i8] c"/storage3/1000genomes/ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20130502/ALL.chr22.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf\00"
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i8** %2
store i64 0, i64* %4
%9 = load i8*, i8** %2
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i8* %9, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = call i32 @fstat(i32 %12, %struct.stat* %3)
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%15 = load i64, i64* %14
%16 = load i32, i32* @PROT_READ
%17 = load i32, i32* @MAP_PRIVATE
%18 = load i32, i32* %5
%19 = call i8* @mmap(i32 0, i64 %15, i32 %16, i32 %17, i32 %18, i32 0)
store i8* %19, i8** %7
%20 = load i8*, i8** %7
store i8* %20, i8** %8
br label %21
21: ; preds = %47, %0
%22 = load i64, i64* %4
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%24 = load i64, i64* %23
%25 = icmp slt i64 %22, %24
br i1 %25, label %26, label %48
26: ; preds = %21
store i32 0, i32* %6
%27 = load i8*, i8** %7
store i8* %27, i8** %8
br label %28
28: ; preds = %40, %26
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i64, i64* %4
%35 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%36 = load i64, i64* %35
%37 = icmp slt i64 %34, %36
br label %38
38: ; preds = %33, %28
%39 = phi i1 [ false, %28 ], [ %37, %33 ]
br i1 %39, label %40, label %47
40: ; preds = %38
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %7
%43 = load i64, i64* %4
%44 = add nsw i64 %43, 1
store i64 %44, i64* %4
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %28
47: ; preds = %38
br label %21
48: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [146 x i8] c"/storage3/1000genomes/ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20130502/ALL.chr22.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf\00"
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @fstat(i32 %4, %struct.stat* %1)
%6 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%7 = load i64, i64* %6
%8 = load i32, i32* @PROT_READ
%9 = load i32, i32* @MAP_PRIVATE
%10 = tail call i8* @mmap(i32 0, i64 %7, i32 %8, i32 %9, i32 %4, i32 0)
ret i32 0
}