#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;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ POSIX_FADV_DONTNEED;
int close(int);
int /*<<< orphan*/ errno;
int fstat(int, struct stat *);
int open(char *, int /*<<< orphan*/);
scalar_t__ posix_fadvise(int, int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ warning(int /*<<< orphan*/, char *, char *);
int main(int argc, char *argv[]) {
  struct stat st;
  int i, fd;
  for (i = 1; i < argc; i++) {
    fd = open(argv[i], O_RDONLY);
    if (fd != -1) {
      if (fstat(fd, &st) == -1) {
        warning(errno, "Unable to stat '%s'", argv[i]);
        continue;
      }
      if (posix_fadvise(fd, 0, st.st_size, POSIX_FADV_DONTNEED) != 0) {
        warning(errno,
                "Unable to give cache hint for "
                "'%s'",
                argv[i]);
        continue;
      }
      if (close(fd) == -1)
        warning(errno, "Problem closing '%s'", argv[i]);
    } else
      warning(errno, "Unable to open '%s'", argv[i]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128c <main+0x13c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     1258 <main+0x108>
mov    -0x20(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1070 <fstat@plt>
cmp    $0xffffffff,%eax
jne    11db <main+0x8b>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe2f(%rip),%rsi
call   1030 <warning@plt>
jmp    127e <main+0x12e>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    0x2e08(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
call   1050 <posix_fadvise@plt>
cmp    $0x0,%rax
je     1221 <main+0xd1>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdfd(%rip),%rsi
call   1030 <warning@plt>
jmp    127e <main+0x12e>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    1253 <main+0x103>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde9(%rip),%rsi
call   1030 <warning@plt>
jmp    1279 <main+0x129>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdd8(%rip),%rsi
call   1030 <warning@plt>
jmp    127e <main+0x12e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1200 <main+0xb0>
mov    %rsi,%r12
mov    %edi,%r15d
mov    $0x1,%ebx
mov    0x2e6a(%rip),%r13
lea    0xecf(%rip),%r14
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
mov    0x0(%r13),%esi
call   1060 <open@plt>
mov    %r14,%rsi
cmp    $0xffffffff,%eax
je     11ce <main+0x7e>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rsp,%rsi
call   1070 <fstat@plt>
lea    0xe58(%rip),%rsi
cmp    $0xffffffff,%eax
je     11ce <main+0x7e>
mov    (%rsp),%edx
mov    0x2e39(%rip),%rax
mov    (%rax),%ecx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <posix_fadvise@plt>
lea    0xe4b(%rip),%rsi
test   %rax,%rax
je     11eb <main+0x9b>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%rbx,8),%rdx
call   1030 <warning@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <main+0x30>
jmp    1200 <main+0xb0>
mov    %ebp,%edi
call   1040 <close@plt>
lea    0xe3e(%rip),%rsi
cmp    $0xffffffff,%eax
jne    11e0 <main+0x90>
jmp    11ce <main+0x7e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@errno = global i32 0
@.str = [20 x i8] c"Unable to stat '%s'\00"
@POSIX_FADV_DONTNEED = global i32 0
@.str.1 = [35 x i8] c"Unable to give cache hint for '%s'\00"
@.str.2 = [21 x i8] c"Problem closing '%s'\00"
@.str.3 = [20 x i8] c"Unable to open '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
br label %9
9: ; preds = %72, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %75
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = load i32, i32* @O_RDONLY
%20 = call i32 @open(i8* %18, i32 %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %63
23: ; preds = %13
%24 = load i32, i32* %8
%25 = call i32 @fstat(i32 %24, %struct.stat* %6)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i32, i32* @errno
%29 = load i8**, i8*** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @warning(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %72
35: ; preds = %23
%36 = load i32, i32* %8
%37 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%38 = load i32, i32* %37
%39 = load i32, i32* @POSIX_FADV_DONTNEED
%40 = call i64 @posix_fadvise(i32 %36, i32 0, i32 %38, i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %35
%43 = load i32, i32* @errno
%44 = load i8**, i8*** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @warning(i32 %43, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %48)
br label %72
50: ; preds = %35
%51 = load i32, i32* %8
%52 = call i32 @close(i32 %51)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %62
54: ; preds = %50
%55 = load i32, i32* @errno
%56 = load i8**, i8*** %5
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @warning(i32 %55, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %54, %50
br label %71
63: ; preds = %13
%64 = load i32, i32* @errno
%65 = load i8**, i8*** %5
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @warning(i32 %64, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %63, %62
br label %72
72: ; preds = %71, %42, %27
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %9
75: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@errno = global i32 0
@.str = [20 x i8] c"Unable to stat '%s'\00"
@POSIX_FADV_DONTNEED = global i32 0
@.str.1 = [35 x i8] c"Unable to give cache hint for '%s'\00"
@.str.2 = [21 x i8] c"Problem closing '%s'\00"
@.str.3 = [20 x i8] c"Unable to open '%s'\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %35
6: ; preds = %2
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %32
%10 = phi i64 [ 1, %6 ], [ %33, %32 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %27, label %16
16: ; preds = %9
%17 = call i32 @fstat(i32 %14, %struct.stat* %3)
%18 = icmp eq i32 %17, -1
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = load i32, i32* %7
%21 = load i32, i32* @POSIX_FADV_DONTNEED
%22 = tail call i64 @posix_fadvise(i32 %14, i32 0, i32 %20, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = tail call i32 @close(i32 %14)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %32
27: ; preds = %9, %24, %19, %16
%28 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %16 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), %19 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %24 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %9 ]
%29 = load i32, i32* @errno
%30 = load i8*, i8** %11
%31 = tail call i32 @warning(i32 %29, i8* %28, i8* %30)
br label %32
32: ; preds = %27, %24
%33 = add nuw nsw i64 %10, 1
%34 = icmp eq i64 %33, %8
br i1 %34, label %35, label %9
35: ; preds = %32, %2
ret i32 0
}