#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int parc, char *parv[]) {
  FILE *fptr;
  char line[1024 + 1];
  char *ptr = line;
  int lineno = 1;
  int cleanfile = 1;
  int tabline = 1;
  if (parc < 2) {
    fprintf(stderr, "Usage: %s <filename>\n", parv[0]);
    exit(1);
  }
  if ((fptr = fopen(parv[1], "r")) == NULL) {
    fprintf(stderr, "Failed to open: %s\n", parv[1]);
    exit(2);
  }
  ptr = fgets(line, 1024, fptr);
  lineno++;
  printf("This language file contains %s", line);
  while ((ptr = fgets(line, 1024, fptr)) != NULL) {
    if (line[0] == ' ') {
      printf("ERROR: Line %d: Line starts with a space\n", lineno);
      cleanfile = 0;
    } else if (line[0] == '\n') {
      printf("ERROR: Line %d: Blank line\n", lineno);
      cleanfile = 0;
    }
    if (line[0] == '\t')
      tabline = 1;
    else {
      if (!tabline)
        printf("WARNING: Line %d: Previous section had no definition\n",
               lineno);
      tabline = 0;
    }
    lineno++;
  }
  if (cleanfile)
    printf("File %s is clear of errors\n", parv[1]);
  else
    printf("File %s has errors\n", parv[1]);
  fclose(fptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
movl   $0x1,-0x42c(%rbp)
movl   $0x1,-0x430(%rbp)
movl   $0x1,-0x434(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d5 <main+0x75>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3a(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe32(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    121e <main+0xbe>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe09(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,-0x428(%rbp)
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x42c(%rbp)
lea    -0x420(%rbp),%rsi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
je     1348 <main+0x1e8>
movsbl -0x420(%rbp),%eax
cmp    $0x20,%eax
jne    12b7 <main+0x157>
mov    -0x42c(%rbp),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x430(%rbp)
jmp    12ea <main+0x18a>
movsbl -0x420(%rbp),%eax
cmp    $0xa,%eax
jne    12e5 <main+0x185>
mov    -0x42c(%rbp),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x430(%rbp)
jmp    12ea <main+0x18a>
movsbl -0x420(%rbp),%eax
cmp    $0x9,%eax
jne    1309 <main+0x1a9>
movl   $0x1,-0x434(%rbp)
jmp    1334 <main+0x1d4>
cmpl   $0x0,-0x434(%rbp)
jne    132a <main+0x1ca>
mov    -0x42c(%rbp),%esi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x434(%rbp)
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x42c(%rbp)
jmp    125e <main+0xfe>
cmpl   $0x0,-0x430(%rbp)
je     1370 <main+0x210>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1386 <main+0x226>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jle    12b8 <main+0x158>
mov    0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12db <main+0x17b>
mov    %rax,%rbx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
lea    0xe77(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     128a <main+0x12a>
mov    %rbp,0x8(%rsp)
mov    $0x2,%ebp
mov    $0x1,%r13d
lea    0x10(%rsp),%r15
mov    $0x1,%r12d
jmp    121b <main+0xbb>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %r14d,%r13d
test   %rax,%rax
je     126e <main+0x10e>
movzbl 0x10(%rsp),%eax
lea    0xe24(%rip),%rdi
cmp    $0x20,%al
je     1236 <main+0xd6>
cmp    $0xa,%al
jne    1247 <main+0xe7>
lea    0xe3f(%rip),%rdi
xor    %r12d,%r12d
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x10(%rsp),%eax
mov    $0x1,%r14d
cmp    $0x9,%al
je     1200 <main+0xa0>
xor    %r14d,%r14d
test   %r13d,%r13d
jne    1200 <main+0xa0>
xor    %r14d,%r14d
lea    0xe2e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1200 <main+0xa0>
test   %r12d,%r12d
lea    0xe6b(%rip),%rax
lea    0xe48(%rip),%rdi
cmove  %rax,%rdi
mov    0x8(%rsp),%rbp
jmp    1291 <main+0x131>
lea    0xe36(%rip),%rdi
mov    0x8(%rbp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd34(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xd29(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Failed to open: %s\0A\00"
@.str.3 = [31 x i8] c"This language file contains %s\00"
@.str.4 = [42 x i8] c"ERROR: Line %d: Line starts with a space\0A\00"
@.str.5 = [28 x i8] c"ERROR: Line %d: Blank line\0A\00"
@.str.6 = [54 x i8] c"WARNING: Line %d: Previous section had no definition\0A\00"
@.str.7 = [28 x i8] c"File %s is clear of errors\0A\00"
@.str.8 = [20 x i8] c"File %s has errors\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1025 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
store i8* %12, i8** %8
store i32 1, i32* %9
store i32 1, i32* %10
store i32 1, i32* %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 2)
unreachable
35: ; preds = %22
%36 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%37 = load i32*, i32** %6
%38 = call i8* @fgets(i8* %36, i32 1024, i32* %37)
store i8* %38, i8** %8
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
%41 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %78, %35
%44 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%45 = load i32*, i32** %6
%46 = call i8* @fgets(i8* %44, i32 1024, i32* %45)
store i8* %46, i8** %8
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %81
48: ; preds = %43
%49 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 32
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i32, i32* %9
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %54)
store i32 0, i32* %10
br label %65
56: ; preds = %48
%57 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 10
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i32, i32* %9
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %62)
store i32 0, i32* %10
br label %64
64: ; preds = %61, %56
br label %65
65: ; preds = %64, %53
%66 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 9
br i1 %69, label %70, label %71
70: ; preds = %65
store i32 1, i32* %11
br label %78
71: ; preds = %65
%72 = load i32, i32* %11
%73 = icmp ne i32 %72, 0
br i1 %73, label %77, label %74
74: ; preds = %71
%75 = load i32, i32* %9
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %74, %71
store i32 0, i32* %11
br label %78
78: ; preds = %77, %70
%79 = load i32, i32* %9
%80 = add nsw i32 %79, 1
store i32 %80, i32* %9
br label %43
81: ; preds = %43
%82 = load i32, i32* %10
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = load i8*, i8** %86
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %87)
br label %94
89: ; preds = %81
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 1
%92 = load i8*, i8** %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %89, %84
%95 = load i32*, i32** %6
%96 = call i32 @fclose(i32* %95)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Failed to open: %s\0A\00"
@.str.3 = [31 x i8] c"This language file contains %s\00"
@.str.4 = [42 x i8] c"ERROR: Line %d: Line starts with a space\0A\00"
@.str.5 = [28 x i8] c"ERROR: Line %d: Blank line\0A\00"
@.str.6 = [54 x i8] c"WARNING: Line %d: Previous section had no definition\0A\00"
@.str.7 = [28 x i8] c"File %s is clear of errors\0A\00"
@.str.8 = [20 x i8] c"File %s has errors\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1025 x i8]
%4 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 2)
unreachable
21: ; preds = %11
%22 = call i8* @fgets(i8* %4, i32 1024, i32* %14)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%24 = call i8* @fgets(i8* %4, i32 1024, i32* %14)
%25 = icmp eq i8* %24, null
br i1 %25, label %52, label %26
26: ; preds = %21, %44
%27 = phi i32 [ %45, %44 ], [ 1, %21 ]
%28 = phi i32 [ %38, %44 ], [ 1, %21 ]
%29 = phi i32 [ %46, %44 ], [ 2, %21 ]
%30 = load i8, i8* %4
switch i8 %30, label %36 [
i8 32, label %32
i8 10, label %31
]
31: ; preds = %26
br label %32
32: ; preds = %26, %31
%33 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), %31 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), %26 ]
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %33, i32 %29)
%35 = load i8, i8* %4
br label %36
36: ; preds = %32, %26
%37 = phi i8 [ %35, %32 ], [ %30, %26 ]
%38 = phi i32 [ 0, %32 ], [ %28, %26 ]
%39 = icmp eq i8 %37, 9
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = icmp eq i32 %27, 0
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %29)
br label %44
44: ; preds = %40, %42, %36
%45 = phi i32 [ 1, %36 ], [ 0, %42 ], [ 0, %40 ]
%46 = add nuw nsw i32 %29, 1
%47 = call i8* @fgets(i8* %4, i32 1024, i32* %14)
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %26
49: ; preds = %44
%50 = icmp eq i32 %38, 0
%51 = select i1 %50, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0)
br label %52
52: ; preds = %49, %21
%53 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), %21 ], [ %51, %49 ]
%54 = load i8*, i8** %12
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %53, i8* %54)
%56 = call i32 @fclose(i32* %14)
ret i32 0
}