#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ ferror(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *ftell(int /*<<< orphan*/ *);
scalar_t__ isnvt(int);
int /*<<< orphan*/ isspace(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int c;
  size_t i;
  FILE *fin;
  if (argc < 2) {
    fprintf(stderr, "Usage:\n\tnvt-check <filename>...\n");
    return 1;
  }
  for (++argv; *argv; ++argv) {
    fin = fopen(*argv, "rb");
    if (!fin) {
      fprintf(stderr, "I/O Error: Could not open %s!\n", *argv);
      continue;
    }
    while (isnvt(fgetc(fin)) && !feof(fin) && !ferror(fin))
      ;
    printf("%s is ", *argv);
    if (feof(fin)) {
      puts("NVT.");
    } else {
      printf("not NVT. Position: %ld, Context: ", ftell(fin));
      i = 0;
      while (i < 5 && !feof(fin) && !ferror(fin))
        if (isnvt(c = fgetc(fin)) && !isspace(c)) {
          putchar(c);
          ++i;
        }
      putchar('\n');
    }
    fclose(fin);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    1203 <main+0x43>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e8 <main+0x228>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     13e1 <main+0x221>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf6(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1262 <main+0xa2>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    13d0 <main+0x210>
jmp    1267 <main+0xa7>
mov    -0x28(%rbp),%rdi
call   1090 <fgetc@plt>
mov    %eax,%edi
call   1060 <isnvt@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     12b8 <main+0xf8>
mov    -0x28(%rbp),%rdi
call   10d0 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
jne    12b8 <main+0xf8>
mov    -0x28(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    12c8 <main+0x108>
jmp    12cd <main+0x10d>
jmp    1267 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd68(%rip),%rdi
call   1080 <printf@plt>
mov    -0x28(%rbp),%rdi
call   10d0 <feof@plt>
cmp    $0x0,%rax
je     1304 <main+0x144>
lea    0xd50(%rip),%rdi
call   1040 <puts@plt>
jmp    13c7 <main+0x207>
mov    -0x28(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %rax,%rsi
lea    0xd38(%rip),%rdi
call   1080 <printf@plt>
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x5,-0x20(%rbp)
mov    %al,-0x2a(%rbp)
jae    1363 <main+0x1a3>
mov    -0x28(%rbp),%rdi
call   10d0 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x2a(%rbp)
jne    1363 <main+0x1a3>
mov    -0x28(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    1373 <main+0x1b3>
jmp    13bd <main+0x1fd>
mov    -0x28(%rbp),%rdi
call   1090 <fgetc@plt>
mov    %eax,%edi
mov    %edi,-0x14(%rbp)
call   1060 <isnvt@plt>
cmp    $0x0,%rax
je     13b8 <main+0x1f8>
mov    -0x14(%rbp),%edi
call   10a0 <isspace@plt>
cmp    $0x0,%eax
jne    13b8 <main+0x1f8>
mov    -0x14(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1324 <main+0x164>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x28(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    120f <main+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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
jge    11f1 <main+0x31>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%eax
jmp    1359 <main+0x199>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1357 <main+0x197>
add    $0x8,%rbx
lea    0xe15(%rip),%r14
lea    0xe30(%rip),%r12
jmp    124b <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdf1(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1357 <main+0x197>
mov    %r14,%rsi
call   10e0 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
je     1220 <main+0x60>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1090 <fgetc@plt>
mov    %eax,%edi
call   1060 <isnvt@plt>
test   %rax,%rax
je     128d <main+0xcd>
mov    %r13,%rdi
call   10d0 <feof@plt>
test   %rax,%rax
jne    128d <main+0xcd>
mov    %r13,%rdi
call   1050 <ferror@plt>
test   %eax,%eax
je     1260 <main+0xa0>
mov    (%rbx),%rsi
mov    %r12,%rdi
call   1080 <printf@plt>
mov    %r13,%rdi
call   10d0 <feof@plt>
test   %rax,%rax
je     12c0 <main+0x100>
lea    0xd9e(%rip),%rdi
call   1040 <puts@plt>
jmp    134a <main+0x18a>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   10c0 <ftell@plt>
lea    0xd80(%rip),%rdi
mov    %rax,%rsi
call   1080 <printf@plt>
xor    %ebp,%ebp
jmp    12e6 <main+0x126>
nopl   0x0(%rax,%rax,1)
cmp    $0x5,%rbp
jae    1340 <main+0x180>
mov    %r13,%rdi
call   10d0 <feof@plt>
test   %rax,%rax
jne    1340 <main+0x180>
mov    %r13,%rdi
call   1050 <ferror@plt>
test   %eax,%eax
jne    1340 <main+0x180>
mov    %r13,%rdi
call   1090 <fgetc@plt>
mov    %eax,%r15d
mov    %eax,%edi
call   1060 <isnvt@plt>
test   %rax,%rax
je     12e0 <main+0x120>
mov    %r15d,%edi
call   10a0 <isspace@plt>
test   %eax,%eax
jne    12e0 <main+0x120>
movsbl %r15b,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
jmp    12e0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
call   1070 <fclose@plt>
jmp    123a <main+0x7a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Usage:\0A\09nvt-check <filename>...\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [31 x i8] c"I/O Error: Could not open %s!\0A\00"
@.str.3 = [7 x i8] c"%s is \00"
@.str.4 = [5 x i8] c"NVT.\00"
@.str.5 = [34 x i8] c"not NVT. Position: %ld, Context: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %102
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
br label %17
17: ; preds = %98, %14
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %101
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %8
%25 = load i32*, i32** %8
%26 = icmp ne i32* %25, null
br i1 %26, label %32, label %27
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %98
32: ; preds = %21
br label %33
33: ; preds = %49, %32
%34 = load i32*, i32** %8
%35 = call i32 @fgetc(i32* %34)
%36 = call i64 @isnvt(i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %33
%39 = load i32*, i32** %8
%40 = call i64 @feof(i32* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %38
%43 = load i32*, i32** %8
%44 = call i32 @ferror(i32* %43)
%45 = icmp ne i32 %44, 0
%46 = xor i1 %45, true
br label %47
47: ; preds = %42, %38, %33
%48 = phi i1 [ false, %38 ], [ false, %33 ], [ %46, %42 ]
br i1 %48, label %49, label %50
49: ; preds = %47
br label %33
50: ; preds = %47
%51 = load i8**, i8*** %5
%52 = load i8*, i8** %51
%53 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = load i32*, i32** %8
%55 = call i64 @feof(i32* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %50
%58 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %95
59: ; preds = %50
%60 = load i32*, i32** %8
%61 = call i8* @ftell(i32* %60)
%62 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %61)
store i64 0, i64* %7
br label %63
63: ; preds = %92, %59
%64 = load i64, i64* %7
%65 = icmp ult i64 %64, 5
br i1 %65, label %66, label %75
66: ; preds = %63
%67 = load i32*, i32** %8
%68 = call i64 @feof(i32* %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %75, label %70
70: ; preds = %66
%71 = load i32*, i32** %8
%72 = call i32 @ferror(i32* %71)
%73 = icmp ne i32 %72, 0
%74 = xor i1 %73, true
br label %75
75: ; preds = %70, %66, %63
%76 = phi i1 [ false, %66 ], [ false, %63 ], [ %74, %70 ]
br i1 %76, label %77, label %93
77: ; preds = %75
%78 = load i32*, i32** %8
%79 = call i32 @fgetc(i32* %78)
store i32 %79, i32* %6
%80 = call i64 @isnvt(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %92
82: ; preds = %77
%83 = load i32, i32* %6
%84 = call i32 @isspace(i32 %83)
%85 = icmp ne i32 %84, 0
br i1 %85, label %92, label %86
86: ; preds = %82
%87 = load i32, i32* %6
%88 = trunc i32 %87 to i8
%89 = call i32 @putchar(i8 signext %88)
%90 = load i64, i64* %7
%91 = add i64 %90, 1
store i64 %91, i64* %7
br label %92
92: ; preds = %86, %82, %77
br label %63
93: ; preds = %75
%94 = call i32 @putchar(i8 signext 10)
br label %95
95: ; preds = %93, %57
%96 = load i32*, i32** %8
%97 = call i32 @fclose(i32* %96)
br label %98
98: ; preds = %95, %27
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i32 1
store i8** %100, i8*** %5
br label %17
101: ; preds = %17
store i32 0, i32* %3
br label %102
102: ; preds = %101, %11
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Usage:\0A\09nvt-check <filename>...\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [31 x i8] c"I/O Error: Could not open %s!\0A\00"
@.str.3 = [7 x i8] c"%s is \00"
@.str.4 = [5 x i8] c"NVT.\00"
@.str.5 = [34 x i8] c"not NVT. Position: %ld, Context: \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %69, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %69
11: ; preds = %4, %65
%12 = phi i8* [ %67, %65 ], [ %6, %4 ]
%13 = phi i8** [ %66, %65 ], [ %5, %4 ]
%14 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %13
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %65
20: ; preds = %11, %27
%21 = tail call i32 @fgetc(i32* %14)
%22 = tail call i64 @isnvt(i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %20
%25 = tail call i64 @feof(i32* %14)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = tail call i32 @ferror(i32* %14)
%29 = icmp eq i32 %28, 0
br i1 %29, label %20, label %30
30: ; preds = %20, %24, %27
%31 = load i8*, i8** %13
%32 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = tail call i64 @feof(i32* %14)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %63
37: ; preds = %30
%38 = tail call i8* @ftell(i32* %14)
%39 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %37, %58
%41 = phi i64 [ 0, %37 ], [ %59, %58 ]
%42 = tail call i64 @feof(i32* %14)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %61
44: ; preds = %40
%45 = tail call i32 @ferror(i32* %14)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %61
47: ; preds = %44
%48 = tail call i32 @fgetc(i32* %14)
%49 = tail call i64 @isnvt(i32 %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %47
%52 = tail call i32 @isspace(i32 %48)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = trunc i32 %48 to i8
%56 = tail call i32 @putchar(i8 signext %55)
%57 = add nuw nsw i64 %41, 1
br label %58
58: ; preds = %54, %51, %47
%59 = phi i64 [ %41, %51 ], [ %57, %54 ], [ %41, %47 ]
%60 = icmp ult i64 %59, 5
br i1 %60, label %40, label %61
61: ; preds = %58, %40, %44
%62 = tail call i32 @putchar(i8 signext 10)
br label %63
63: ; preds = %61, %35
%64 = tail call i32 @fclose(i32* %14)
br label %65
65: ; preds = %63, %16
%66 = getelementptr inbounds i8*, i8** %13, i64 1
%67 = load i8*, i8** %66
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %11
69: ; preds = %65, %4, %8
%70 = phi i32 [ 1, %8 ], [ 0, %4 ], [ 0, %65 ]
ret i32 %70
}