#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 *name;
  char val;
  int /*<<< orphan*/ has_arg;
};

/* 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[] = {
      {.name = "test", .has_arg = no_argument, .val = 't'}, {.name = NULL}};
  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    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x40(%rbp)
movb   $0x74,-0x38(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
movq   $0x0,-0x30(%rbp)
movb   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e35(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rcx
lea    0xe40(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1237 <main+0xd7>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
jne    11f6 <main+0x96>
jmp    11ea <main+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    1376 <main+0x216>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x2dcf(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1376 <main+0x216>
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
je     1278 <main+0x118>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1376 <main+0x216>
mov    -0x10(%rbp),%rax
mov    0x2d5d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d57(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    12e3 <main+0x183>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2d27(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
mov    0x2d01(%rip),%rax
mov    (%rax),%ecx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1376 <main+0x216>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2cd2(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoll@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
call   1050 <check_fiemap@plt>
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%edi
call   1040 <close@plt>
cmp    $0x0,%rax
jge    1370 <main+0x210>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2c8e(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
mov    0x2c68(%rip),%rax
mov    (%rax),%ecx
lea    0xd0f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe88(%rip),%rax
mov    %rax,(%rsp)
movb   $0x74,0x8(%rsp)
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
movq   $0x0,0x10(%rsp)
movb   $0x0,0x18(%rsp)
movl   $0x0,0x1c(%rsp)
mov    0x2e35(%rip),%r15
movl   $0x0,(%r15)
lea    0xe4a(%rip),%rdx
xor    %ebx,%ebx
mov    %rsp,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0xffffffff,%eax
je     11fb <main+0x9b>
cmp    $0x74,%eax
je     12bf <main+0x15f>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
movslq (%r15),%rax
mov    -0x8(%r14,%rax,8),%rcx
lea    0xe16(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12ba <main+0x15a>
movslq (%r15),%rax
add    $0xfffffffe,%ebp
cmp    %ebp,%eax
jne    1280 <main+0x120>
mov    (%r14,%rax,8),%rdi
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    0x2db2(%rip),%r12
mov    (%r12),%edi
test   %eax,%eax
js     129c <main+0x13c>
mov    %eax,%ebp
lea    0xe41(%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    12bf <main+0x15f>
mov    (%r12),%edi
movslq (%r15),%rax
mov    (%r14,%rax,8),%rdx
mov    0x2d5a(%rip),%rax
mov    (%rax),%ecx
lea    0xe01(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12bf <main+0x15f>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd97(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12ba <main+0x15a>
movslq (%r15),%rax
mov    (%r14,%rax,8),%rdx
mov    0x2d1e(%rip),%rax
mov    (%rax),%ecx
lea    0xd98(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.option = type { i8*, i8, 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
store i8 116, i8* %7
%8 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0, i32 2
%9 = load i32, i32* @no_argument
store i32 %9, i32* %8
%10 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 0
store i8* null, i8** %10
%11 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 1
store i8 0, i8* %11
%12 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 1, i32 2
store i32 0, i32* %12
store i32 0, i32* @optind
%13 = 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 %13, label %14 [
i32 -1, label %23
i32 116, label %65
]
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = load i32, i32* @optind
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %21)
br label %65
23: ; preds = %2
%24 = load i32, i32* @optind
%25 = add nsw i32 %0, -2
%26 = icmp eq i32 %24, %25
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %1
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %65
31: ; preds = %23
%32 = sext i32 %24 to i64
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
%35 = load i32, i32* @O_RDONLY
%36 = call i32 @open(i8* %34, i32 %35)
%37 = icmp slt i32 %36, 0
%38 = load i32, i32* @stderr
br i1 %37, label %39, label %46
39: ; preds = %31
%40 = load i32, i32* @optind
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %1, i64 %41
%43 = load i8*, i8** %42
%44 = load i32, i32* @errno
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %43, i32 %44)
br label %65
46: ; preds = %31
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%48 = load i32, i32* @optind
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %1, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @atoll(i8* %52)
%54 = call i32 @check_fiemap(i32 %36, i32 %53)
%55 = call i64 @close(i32 %36)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %65
57: ; preds = %46
%58 = load i32, i32* @stderr
%59 = load i32, i32* @optind
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %1, i64 %60
%62 = load i8*, i8** %61
%63 = load i32, i32* @errno
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %62, i32 %63)
br label %65
65: ; preds = %46, %57, %2, %39, %27, %14
%66 = phi i32 [ -1, %14 ], [ -1, %27 ], [ -1, %39 ], [ 0, %2 ], [ %54, %57 ], [ %54, %46 ]
ret i32 %66
}