#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 option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ atoll(char *);
int check_fiemap(int, int /*<<< orphan*/);
scalar_t__ close(int);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int /*<<< orphan*/ no_argument;
int open(char *, int /*<<< orphan*/);
int optind;
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int c;
  struct option long_opts[] = {{"test", no_argument, 0, 't'},
                               {NULL, 0, NULL, 0}};
  int fd;
  int rc;
  optind = 0;
  while ((c = getopt_long(argc, argv, "t", long_opts, NULL)) != -1) {
    switch (c) {
    case 't':
      return 0;
    default:
      fprintf(stderr, "error: %s: option '%s' unrecognized\n", argv[0],
              argv[optind - 1]);
      return -1;
    }
  }
  if (optind != argc - 2) {
    fprintf(stderr, "Usage: %s <filename> <filesize>\n", argv[0]);
    return -1;
  }
  fd = open(argv[optind], O_RDONLY);
  if (fd < 0) {
    fprintf(stderr, "cannot open %s for reading, error %i", argv[optind],
            errno);
    return -1;
  }
  fprintf(stderr, "fd: %i\n", fd);
  rc = check_fiemap(fd, atoll(argv[optind + 1]));
  if (close(fd) < 0)
    fprintf(stderr, "closing %s, error %i", argv[optind], errno);
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    0xe63(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x58(%rbp)
movl   $0x74,-0x48(%rbp)
mov    0x2e25(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rcx
lea    0xe30(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1247 <main+0xd7>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
jne    1206 <main+0x96>
jmp    11fa <main+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    1386 <main+0x216>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x2dbf(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1386 <main+0x216>
mov    0x2d92(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
je     1288 <main+0x118>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1386 <main+0x216>
mov    -0x10(%rbp),%rax
mov    0x2d4d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d47(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    12f3 <main+0x183>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2d17(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
mov    0x2cf1(%rip),%rax
mov    (%rax),%ecx
lea    0xd6b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1386 <main+0x216>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    -0x64(%rbp),%edx
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x64(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2cc2(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoll@plt>
mov    -0x6c(%rbp),%edi
mov    %eax,%esi
call   1060 <check_fiemap@plt>
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%edi
call   1050 <close@plt>
cmp    $0x0,%rax
jge    1380 <main+0x210>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2c7e(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
mov    0x2c58(%rip),%rax
mov    (%rax),%ecx
lea    0xcff(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xe72(%rip),%rax
mov    %rax,(%rsp)
mov    0x2e27(%rip),%rax
mov    (%rax),%al
mov    %al,0x8(%rsp)
movl   $0x74,0x18(%rsp)
mov    0x2e32(%rip),%r15
movl   $0x0,(%r15)
lea    0xe47(%rip),%rdx
xor    %ebx,%ebx
mov    %rsp,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0xffffffff,%eax
je     11fe <main+0x9e>
cmp    $0x74,%eax
je     12c2 <main+0x162>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
movslq (%r15),%rax
mov    -0x8(%r14,%rax,8),%rcx
lea    0xe13(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12bd <main+0x15d>
movslq (%r15),%rax
add    $0xfffffffe,%ebp
cmp    %ebp,%eax
jne    1283 <main+0x123>
mov    (%r14,%rax,8),%rdi
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    0x2daf(%rip),%r12
mov    (%r12),%edi
test   %eax,%eax
js     129f <main+0x13f>
mov    %eax,%ebp
lea    0xe3e(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
movslq (%r15),%rax
mov    0x8(%r14,%rax,8),%rdi
call   1060 <atoll@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <check_fiemap@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <close@plt>
test   %rax,%rax
jns    12c2 <main+0x162>
mov    (%r12),%edi
movslq (%r15),%rax
mov    (%r14,%rax,8),%rdx
mov    0x2d57(%rip),%rax
mov    (%rax),%ecx
lea    0xdfe(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12c2 <main+0x162>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd94(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12bd <main+0x15d>
movslq (%r15),%rax
mov    (%r14,%rax,8),%rdx
mov    0x2d1b(%rip),%rax
mov    (%rax),%ecx
lea    0xd95(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"test\00"
@no_argument = global i32 0
@optind = global i32 0
@.str.1 = [2 x i8] c"t\00"
@stderr = global i32 0
@.str.2 = [37 x i8] c"error: %s: option '%s' unrecognized\0A\00"
@.str.3 = [33 x i8] c"Usage: %s <filename> <filesize>\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [37 x i8] c"cannot open %s for reading, error %i\00"
@errno = global i32 0
@.str.5 = [8 x i8] c"fd: %i\0A\00"
@.str.6 = [21 x i8] c"closing %s, error %i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2 x %struct.option]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [2 x %struct.option]* %7 to i8*
%11 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %7, i64 0, i64 0
%12 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 1
%14 = load i32, i32* @no_argument
%15 = trunc i32 %14 to i8
store i8 %15, i8* %13
%16 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 3
store i32 116, i32* %16
%17 = getelementptr inbounds %struct.option, %struct.option* %11, i64 1
store i32 0, i32* @optind
br label %18
18: ; preds = %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %7, i64 0, i64 0
%22 = call i32 @getopt_long(i32 %19, i8** %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* %21, i32* null)
store i32 %22, i32* %6
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %39
24: ; preds = %18
%25 = load i32, i32* %6
switch i32 %25, label %27 [
i32 116, label %26
]
26: ; preds = %24
store i32 0, i32* %3
br label %96
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = load i32, i32* @optind
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %32, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %37)
store i32 -1, i32* %3
br label %96
39: ; preds = %18
%40 = load i32, i32* @optind
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, 2
%43 = icmp ne i32 %40, %42
br i1 %43, label %44, label %50
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %48)
store i32 -1, i32* %3
br label %96
50: ; preds = %39
%51 = load i8**, i8*** %5
%52 = load i32, i32* @optind
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = load i32, i32* @O_RDONLY
%57 = call i32 @open(i8* %55, i32 %56)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %69
60: ; preds = %50
%61 = load i32, i32* @stderr
%62 = load i8**, i8*** %5
%63 = load i32, i32* @optind
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = load i32, i32* @errno
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %66, i32 %67)
store i32 -1, i32* %3
br label %96
69: ; preds = %50
%70 = load i32, i32* @stderr
%71 = load i32, i32* %8
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %8
%74 = load i8**, i8*** %5
%75 = load i32, i32* @optind
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %74, i64 %77
%79 = load i8*, i8** %78
%80 = call i32 @atoll(i8* %79)
%81 = call i32 @check_fiemap(i32 %73, i32 %80)
store i32 %81, i32* %9
%82 = load i32, i32* %8
%83 = call i64 @close(i32 %82)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %94
85: ; preds = %69
%86 = load i32, i32* @stderr
%87 = load i8**, i8*** %5
%88 = load i32, i32* @optind
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %87, i64 %89
%91 = load i8*, i8** %90
%92 = load i32, i32* @errno
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %91, i32 %92)
br label %94
94: ; preds = %85, %69
%95 = load i32, i32* %9
store i32 %95, i32* %3
br label %96
96: ; preds = %94, %60, %44, %27, %26
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"test\00"
@no_argument = global i32 0
@optind = global i32 0
@.str.1 = [2 x i8] c"t\00"
@stderr = global i32 0
@.str.2 = [37 x i8] c"error: %s: option '%s' unrecognized\0A\00"
@.str.3 = [33 x i8] c"Usage: %s <filename> <filesize>\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [37 x i8] c"cannot open %s for reading, error %i\00"
@errno = global i32 0
@.str.5 = [8 x i8] c"fd: %i\0A\00"
@.str.6 = [21 x i8] c"closing %s, error %i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x %struct.option]
%4 = bitcast [2 x %struct.option]* %3 to i8*
%5 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 1
%8 = load i32, i32* @no_argument
%9 = trunc i32 %8 to i8
store i8 %9, i8* %7
%10 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 3
store i32 116, i32* %10
store i32 0, i32* @optind
%11 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* %5, i32* null)
switch i32 %11, label %12 [
i32 -1, label %21
i32 116, label %63
]
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = load i32, i32* @optind
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %19)
br label %63
21: ; preds = %2
%22 = load i32, i32* @optind
%23 = add nsw i32 %0, -2
%24 = icmp eq i32 %22, %23
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %63
29: ; preds = %21
%30 = sext i32 %22 to i64
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = load i32, i32* @O_RDONLY
%34 = call i32 @open(i8* %32, i32 %33)
%35 = icmp slt i32 %34, 0
%36 = load i32, i32* @stderr
br i1 %35, label %37, label %44
37: ; preds = %29
%38 = load i32, i32* @optind
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = load i8*, i8** %40
%42 = load i32, i32* @errno
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %41, i32 %42)
br label %63
44: ; preds = %29
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%46 = load i32, i32* @optind
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %1, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @atoll(i8* %50)
%52 = call i32 @check_fiemap(i32 %34, i32 %51)
%53 = call i64 @close(i32 %34)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %63
55: ; preds = %44
%56 = load i32, i32* @stderr
%57 = load i32, i32* @optind
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = load i32, i32* @errno
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %60, i32 %61)
br label %63
63: ; preds = %44, %55, %2, %37, %25, %12
%64 = phi i32 [ -1, %12 ], [ -1, %25 ], [ -1, %37 ], [ 0, %2 ], [ %52, %55 ], [ %52, %44 ]
ret i32 %64
}