#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 {
  int /*<<< orphan*/ st_size;
};
struct fiemap {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ POSIX_FADV_SEQUENTIAL;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int fstat(int, struct stat *);
struct fiemap *getfm(int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ posix_fadvise(int, int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int infd, outfd;
  struct stat buf;
  struct fiemap *fm;
  infd = open(argv[1], O_RDONLY);
  if (fstat(infd, &buf) == -1) {
    exit(1);
  }
  fm = getfm(infd, buf.st_size);
  return 0;
  if (argc != 3)
    usage(argv[0]);
  if (stat(argv[1], &buf) < 0)
    do {
      perror(argv[1]);
      exit(1);
    } while (0);
  if (access(argv[2], F_OK) != -1) {
    printf("%s exist\n", argv[2]);
    exit(1);
  }
  if ((infd = open(argv[1], O_RDONLY)) < 0)
    do {
      perror(argv[1]);
      exit(1);
    } while (0);
  posix_fadvise(infd, 0, 0, POSIX_FADV_SEQUENTIAL);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1060 <fstat@plt>
cmp    $0xffffffff,%eax
jne    118e <main+0x4e>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <getfm@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1060 <fstat@plt>
cmp    $0xffffffff,%eax
je     117d <main+0x3d>
mov    0x8(%rsp),%esi
mov    %ebx,%edi
call   1030 <getfm@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.fiemap = type { i32 }
@O_RDONLY = global i32 0
@F_OK = global i32 0
@POSIX_FADV_SEQUENTIAL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.stat
%9 = alloca %struct.fiemap*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = call i32 @open(i8* %12, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i32 @fstat(i32 %15, %struct.stat* %8)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i32, i32* %6
%22 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call %struct.fiemap* @getfm(i32 %21, i32 %23)
store %struct.fiemap* %24, %struct.fiemap** %9
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.fiemap = type { i32 }
@O_RDONLY = global i32 0
@F_OK = global i32 0
@POSIX_FADV_SEQUENTIAL = global i32 0
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 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %6, i32 %7)
%9 = call i32 @fstat(i32 %8, %struct.stat* %3)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = tail call %struct.fiemap* @getfm(i32 %8, i32 %15)
ret i32 0
}