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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ printf(char *, char const *, ...);
void checkSpacing(const char *zFile, unsigned flags) {
  FILE *in = fopen(zFile, "rb");
  int i;
  int seenSpace;
  int seenTab;
  int ln = 0;
  int lastNonspace = 0;
  char zLine[2000];
  if (in == 0) {
    printf("cannot open %s\n", zFile);
    return;
  }
  while (fgets(zLine, sizeof(zLine), in)) {
    seenSpace = 0;
    seenTab = 0;
    ln++;
    for (i = 0; zLine[i]; i++) {
      if (zLine[i] == '\t' && seenTab == 0) {
        printf("%s:%d: tab (\\t) character\n", zFile, ln);
        seenTab = 1;
      } else if (zLine[i] == '\r') {
        if ((flags & 0x001) == 0) {
          printf("%s:%d: carriage-return (\\r) character\n", zFile, ln);
        }
      } else if (zLine[i] == ' ') {
        seenSpace = 1;
      } else if (zLine[i] != '\n') {
        lastNonspace = ln;
        seenSpace = 0;
      }
    }
    if (seenSpace && (flags & 0x002) == 0) {
      printf("%s:%d: whitespace at end-of-line\n", zFile, ln);
    }
  }
  fclose(in);
  if (lastNonspace < ln) {
    printf("%s:%d: blank lines at end of file (%d)\n", zFile, ln,
           ln - lastNonspace);
  }
}


x86 assembly (clang, -O0):
<checkSpacing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1196 <checkSpacing+0x56>
mov    -0x8(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1330 <checkSpacing+0x1f0>
jmp    119b <checkSpacing+0x5b>
lea    -0x800(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x7d0,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1300 <checkSpacing+0x1c0>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmpb   $0x0,-0x800(%rbp,%rax,1)
je     12cd <checkSpacing+0x18d>
movslq -0x1c(%rbp),%rax
movsbl -0x800(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
jne    122a <checkSpacing+0xea>
cmpl   $0x0,-0x24(%rbp)
jne    122a <checkSpacing+0xea>
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%edx
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
jmp    12ba <checkSpacing+0x17a>
movslq -0x1c(%rbp),%rax
movsbl -0x800(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    1268 <checkSpacing+0x128>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1263 <checkSpacing+0x123>
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%edx
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b5 <checkSpacing+0x175>
movslq -0x1c(%rbp),%rax
movsbl -0x800(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    1289 <checkSpacing+0x149>
movl   $0x1,-0x20(%rbp)
jmp    12b0 <checkSpacing+0x170>
movslq -0x1c(%rbp),%rax
movsbl -0x800(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     12ab <checkSpacing+0x16b>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
jmp    12b0 <checkSpacing+0x170>
jmp    12b5 <checkSpacing+0x175>
jmp    12ba <checkSpacing+0x17a>
jmp    12bf <checkSpacing+0x17f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d8 <checkSpacing+0x98>
cmpl   $0x0,-0x20(%rbp)
je     12fb <checkSpacing+0x1bb>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    12fb <checkSpacing+0x1bb>
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%edx
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    119b <checkSpacing+0x5b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1330 <checkSpacing+0x1f0>
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x28(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkSpacing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7f8,%rsp
mov    %esi,0xc(%rsp)
mov    %rdi,%rbx
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     12c7 <checkSpacing+0x187>
mov    %rax,%r14
lea    0x20(%rsp),%rdi
mov    $0x7d0,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12e9 <checkSpacing+0x1a9>
lea    0xe81(%rip),%r13
movl   $0x0,0x8(%rsp)
xor    %ebp,%ebp
mov    %r14,0x10(%rsp)
jmp    11d0 <checkSpacing+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%r14
lea    0x20(%rsp),%rdi
mov    $0x7d0,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     129c <checkSpacing+0x15c>
mov    %ebp,%ecx
mov    %rcx,%rax
mov    %rcx,0x18(%rsp)
lea    0x1(%rcx),%ebp
mov    0x20(%rsp),%al
test   %al,%al
je     11b5 <checkSpacing+0x75>
xor    %r15d,%r15d
lea    0x21(%rsp),%r14
xor    %r12d,%r12d
jmp    1221 <checkSpacing+0xe1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r15d
movzbl (%r14),%eax
add    $0x1,%r14
test   %al,%al
je     1270 <checkSpacing+0x130>
cmp    $0x9,%al
jne    122a <checkSpacing+0xea>
test   %r15d,%r15d
je     1200 <checkSpacing+0xc0>
cmp    $0xa,%al
je     1215 <checkSpacing+0xd5>
cmp    $0x20,%al
je     1252 <checkSpacing+0x112>
cmp    $0xd,%al
jne    125a <checkSpacing+0x11a>
testb  $0x1,0xc(%rsp)
jne    1215 <checkSpacing+0xd5>
lea    0xdea(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1215 <checkSpacing+0xd5>
mov    $0x1,%r12d
jmp    1215 <checkSpacing+0xd5>
xor    %r12d,%r12d
mov    %ebp,0x8(%rsp)
jmp    1215 <checkSpacing+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testb  $0x2,0xc(%rsp)
jne    11b0 <checkSpacing+0x70>
test   %r12d,%r12d
je     11b0 <checkSpacing+0x70>
lea    0xdca(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b0 <checkSpacing+0x70>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%eax
cmp    %eax,0x18(%rsp)
jl     12f1 <checkSpacing+0x1b1>
mov    %ebp,%ecx
sub    %eax,%ecx
lea    0xdbe(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12f1 <checkSpacing+0x1b1>
lea    0xd35(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [16 x i8] c"cannot open %s\0A\00"
@.str.2 = [27 x i8] c"%s:%d: tab (\\t) character\0A\00"
@.str.3 = [39 x i8] c"%s:%d: carriage-return (\\r) character\0A\00"
@.str.4 = [34 x i8] c"%s:%d: whitespace at end-of-line\0A\00"
@.str.5 = [40 x i8] c"%s:%d: blank lines at end of file (%d)\0A\00"
define void @checkSpacing(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2000 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %5
store i32 0, i32* %9
store i32 0, i32* %10
%14 = load i32*, i32** %5
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %113
19: ; preds = %2
br label %20
20: ; preds = %99, %19
%21 = getelementptr inbounds [2000 x i8], [2000 x i8]* %11, i64 0, i64 0
%22 = load i32*, i32** %5
%23 = call i64 @fgets(i8* %21, i32 2000, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %100
25: ; preds = %20
store i32 0, i32* %7
store i32 0, i32* %8
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
store i32 0, i32* %6
br label %28
28: ; preds = %85, %25
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2000 x i8], [2000 x i8]* %11, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = icmp ne i8 %32, 0
br i1 %33, label %34, label %88
34: ; preds = %28
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [2000 x i8], [2000 x i8]* %11, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 9
br i1 %40, label %41, label %48
41: ; preds = %34
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i8*, i8** %3
%46 = load i32, i32* %9
%47 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %45, i32 %46)
store i32 1, i32* %8
br label %84
48: ; preds = %41, %34
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [2000 x i8], [2000 x i8]* %11, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 13
br i1 %54, label %55, label %64
55: ; preds = %48
%56 = load i32, i32* %4
%57 = and i32 %56, 1
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i8*, i8** %3
%61 = load i32, i32* %9
%62 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %60, i32 %61)
br label %63
63: ; preds = %59, %55
br label %83
64: ; preds = %48
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [2000 x i8], [2000 x i8]* %11, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 32
br i1 %70, label %71, label %72
71: ; preds = %64
store i32 1, i32* %7
br label %82
72: ; preds = %64
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [2000 x i8], [2000 x i8]* %11, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp ne i32 %77, 10
br i1 %78, label %79, label %81
79: ; preds = %72
%80 = load i32, i32* %9
store i32 %80, i32* %10
store i32 0, i32* %7
br label %81
81: ; preds = %79, %72
br label %82
82: ; preds = %81, %71
br label %83
83: ; preds = %82, %63
br label %84
84: ; preds = %83, %44
br label %85
85: ; preds = %84
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 1
store i32 %87, i32* %6
br label %28
88: ; preds = %28
%89 = load i32, i32* %7
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %99
91: ; preds = %88
%92 = load i32, i32* %4
%93 = and i32 %92, 2
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %91
%96 = load i8*, i8** %3
%97 = load i32, i32* %9
%98 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %96, i32 %97)
br label %99
99: ; preds = %95, %91, %88
br label %20
100: ; preds = %20
%101 = load i32*, i32** %5
%102 = call i32 @fclose(i32* %101)
%103 = load i32, i32* %10
%104 = load i32, i32* %9
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %113
106: ; preds = %100
%107 = load i8*, i8** %3
%108 = load i32, i32* %9
%109 = load i32, i32* %9
%110 = load i32, i32* %10
%111 = sub nsw i32 %109, %110
%112 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %107, i32 %108, i32 %111)
br label %113
113: ; preds = %16, %106, %100
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [16 x i8] c"cannot open %s\0A\00"
@.str.2 = [27 x i8] c"%s:%d: tab (\\t) character\0A\00"
@.str.3 = [39 x i8] c"%s:%d: carriage-return (\\r) character\0A\00"
@.str.4 = [34 x i8] c"%s:%d: whitespace at end-of-line\0A\00"
@.str.5 = [40 x i8] c"%s:%d: blank lines at end of file (%d)\0A\00"
define void @checkSpacing(i8* %0, i32 %1) {
%3 = alloca [2000 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32* %4, null
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = call i64 @fgets(i8* %5, i32 2000, i32* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @fclose(i32* %4)
br label %65
12: ; preds = %7
%13 = and i32 %1, 1
%14 = icmp eq i32 %13, 0
%15 = and i32 %1, 2
%16 = icmp eq i32 %15, 0
br label %19
17: ; preds = %2
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %65
19: ; preds = %12, %55
%20 = phi i32 [ 0, %12 ], [ %56, %55 ]
%21 = phi i32 [ 0, %12 ], [ %22, %55 ]
%22 = add nuw nsw i32 %21, 1
%23 = load i8, i8* %5
%24 = icmp eq i8 %23, 0
br i1 %24, label %55, label %25
25: ; preds = %19, %42
%26 = phi i64 [ %46, %42 ], [ 0, %19 ]
%27 = phi i8 [ %48, %42 ], [ %23, %19 ]
%28 = phi i32 [ %45, %42 ], [ %20, %19 ]
%29 = phi i32 [ %44, %42 ], [ 0, %19 ]
%30 = phi i32 [ %43, %42 ], [ 0, %19 ]
%31 = icmp eq i8 %27, 9
%32 = icmp eq i32 %29, 0
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %34, label %36
34: ; preds = %25
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %22)
br label %42
36: ; preds = %25
switch i8 %27, label %40 [
i8 13, label %37
i8 32, label %42
i8 10, label %41
]
37: ; preds = %36
br i1 %14, label %38, label %42
38: ; preds = %37
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %22)
br label %42
40: ; preds = %36
br label %42
41: ; preds = %36
br label %42
42: ; preds = %36, %41, %34, %40, %37, %38
%43 = phi i32 [ %30, %34 ], [ %30, %38 ], [ %30, %37 ], [ 0, %40 ], [ 1, %36 ], [ %30, %41 ]
%44 = phi i32 [ 1, %34 ], [ %29, %38 ], [ %29, %37 ], [ %29, %40 ], [ %29, %36 ], [ %29, %41 ]
%45 = phi i32 [ %28, %34 ], [ %28, %38 ], [ %28, %37 ], [ %22, %40 ], [ %28, %36 ], [ %28, %41 ]
%46 = add nuw i64 %26, 1
%47 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 0
br i1 %49, label %50, label %25
50: ; preds = %42
%51 = icmp ne i32 %43, 0
%52 = and i1 %16, %51
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 %22)
br label %55
55: ; preds = %19, %53, %50
%56 = phi i32 [ %45, %53 ], [ %45, %50 ], [ %20, %19 ]
%57 = call i64 @fgets(i8* %5, i32 2000, i32* %4)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %19
59: ; preds = %55
%60 = call i32 @fclose(i32* %4)
%61 = icmp slt i32 %21, %56
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = sub nsw i32 %22, %56
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %22, i32 %63)
br label %65
65: ; preds = %10, %59, %62, %17
ret void
}