#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*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
char *strchr(char *, char);
char *strstr(char *, char *);
void process(char *name, int width) {
  FILE *ff = fopen(name, "r");
  char buffer[256];
  int count = 0;
  if (ff == NULL) {
    printf("File=%s does not exist\n", name);
    return;
  }
  while (1) {
    char *p;
    if (fgets(buffer, 255, ff) == NULL)
      break;
    count++;
    p = strchr(buffer, '\n');
    if (p == NULL || (p - buffer) > width) {
      printf("File=%s Line=%d:\n%s\n", name, count, buffer);
    }
    p = strchr(buffer, '\t');
    if (p != NULL)
      printf("File=%s Line=%d tab at %d\n%s\n", name, count, p - buffer,
             buffer);
    p = strstr(buffer, " \n");
    if (p != NULL)
      printf("File=%s Line=%d extra space at %d\n%s\n", name, count, p - buffer,
             buffer);
  }
  fclose(ff);
  return;
}


x86 assembly (clang, -O0):
<process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x124(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b2 <process+0x52>
mov    -0x8(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1309 <process+0x1a9>
jmp    11b7 <process+0x57>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11db <process+0x7b>
jmp    1300 <process+0x1a0>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
je     122e <process+0xce>
mov    -0x130(%rbp),%rax
lea    -0x120(%rbp),%rcx
sub    %rcx,%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jle    124d <process+0xed>
mov    -0x8(%rbp),%rsi
mov    -0x124(%rbp),%edx
lea    -0x120(%rbp),%rcx
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    $0x9,%esi
call   1040 <strchr@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
je     12a3 <process+0x143>
mov    -0x8(%rbp),%rsi
mov    -0x124(%rbp),%edx
mov    -0x130(%rbp),%rcx
lea    -0x120(%rbp),%rax
sub    %rax,%rcx
lea    -0x120(%rbp),%r8
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x120(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
je     12fb <process+0x19b>
mov    -0x8(%rbp),%rsi
mov    -0x124(%rbp),%edx
mov    -0x130(%rbp),%rcx
lea    -0x120(%rbp),%rax
sub    %rax,%rcx
lea    -0x120(%rbp),%r8
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11b7 <process+0x57>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xe83(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1289 <process+0x129>
mov    %rax,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     126f <process+0x10f>
movslq %ebp,%r12
mov    $0x1,%ebp
lea    0xe94(%rip),%r13
jmp    11dc <process+0x7c>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     126f <process+0x10f>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11f6 <process+0x96>
sub    %rbx,%rax
cmp    %r12,%rax
jle    120c <process+0xac>
lea    0xe1d(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     123a <process+0xda>
sub    %rbx,%rax
lea    0xe07(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %rax,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11c0 <process+0x60>
sub    %rbx,%rax
lea    0xdf8(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %rax,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c0 <process+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd72(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"File=%s does not exist\0A\00"
@.str.2 = [21 x i8] c"File=%s Line=%d:\0A%s\0A\00"
@.str.3 = [30 x i8] c"File=%s Line=%d tab at %d\0A%s\0A\00"
@.str.4 = [3 x i8] c" \0A\00"
@.str.5 = [38 x i8] c"File=%s Line=%d extra space at %d\0A%s\0A\00"
define void @process(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %5
store i32 0, i32* %7
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %78
16: ; preds = %2
br label %17
17: ; preds = %16, %74
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = load i32*, i32** %5
%20 = call i32* @fgets(i8* %18, i32 255, i32* %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %23
22: ; preds = %17
br label %75
23: ; preds = %17
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%27 = call i8* @strchr(i8* %26, i8 signext 10)
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = icmp eq i8* %28, null
br i1 %29, label %39, label %30
30: ; preds = %23
%31 = load i8*, i8** %8
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%33 = ptrtoint i8* %31 to i64
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %33, %34
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = icmp sgt i64 %35, %37
br i1 %38, label %39, label %44
39: ; preds = %30, %23
%40 = load i8*, i8** %3
%41 = load i32, i32* %7
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%43 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %40, i32 %41, i8* %42)
br label %44
44: ; preds = %39, %30
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%46 = call i8* @strchr(i8* %45, i8 signext 9)
store i8* %46, i8** %8
%47 = load i8*, i8** %8
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %59
49: ; preds = %44
%50 = load i8*, i8** %3
%51 = load i32, i32* %7
%52 = load i8*, i8** %8
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%54 = ptrtoint i8* %52 to i64
%55 = ptrtoint i8* %53 to i64
%56 = sub i64 %54, %55
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%58 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %50, i32 %51, i64 %56, i8* %57)
br label %59
59: ; preds = %49, %44
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%61 = call i8* @strstr(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i8* %61, i8** %8
%62 = load i8*, i8** %8
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %74
64: ; preds = %59
%65 = load i8*, i8** %3
%66 = load i32, i32* %7
%67 = load i8*, i8** %8
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%69 = ptrtoint i8* %67 to i64
%70 = ptrtoint i8* %68 to i64
%71 = sub i64 %69, %70
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%73 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %65, i32 %66, i64 %71, i8* %72)
br label %74
74: ; preds = %64, %59
br label %17
75: ; preds = %22
%76 = load i32*, i32** %5
%77 = call i32 @fclose(i32* %76)
br label %78
78: ; preds = %75, %13
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"File=%s does not exist\0A\00"
@.str.2 = [21 x i8] c"File=%s Line=%d:\0A%s\0A\00"
@.str.3 = [30 x i8] c"File=%s Line=%d tab at %d\0A%s\0A\00"
@.str.4 = [3 x i8] c" \0A\00"
@.str.5 = [38 x i8] c"File=%s Line=%d extra space at %d\0A%s\0A\00"
define void @process(i8* %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32* %4, null
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = call i32* @fgets(i8* %5, i32 255, i32* %4)
%9 = icmp eq i32* %8, null
br i1 %9, label %43, label %10
10: ; preds = %7
%11 = ptrtoint [256 x i8]* %3 to i64
%12 = sext i32 %1 to i64
br label %15
13: ; preds = %2
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %45
15: ; preds = %10, %40
%16 = phi i32 [ 0, %10 ], [ %17, %40 ]
%17 = add nuw nsw i32 %16, 1
%18 = call i8* @strchr(i8* %5, i8 signext 10)
%19 = icmp eq i8* %18, null
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %20, %11
%22 = icmp sgt i64 %21, %12
%23 = select i1 %19, i1 true, i1 %22
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %17, i8* %5)
br label %26
26: ; preds = %15, %24
%27 = call i8* @strchr(i8* %5, i8 signext 9)
%28 = icmp eq i8* %27, null
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = ptrtoint i8* %27 to i64
%31 = sub i64 %30, %11
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %17, i64 %31, i8* %5)
br label %33
33: ; preds = %29, %26
%34 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i8* %34, null
br i1 %35, label %40, label %36
36: ; preds = %33
%37 = ptrtoint i8* %34 to i64
%38 = sub i64 %37, %11
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %17, i64 %38, i8* %5)
br label %40
40: ; preds = %33, %36
%41 = call i32* @fgets(i8* %5, i32 255, i32* %4)
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %15
43: ; preds = %40, %7
%44 = call i32 @fclose(i32* %4)
br label %45
45: ; preds = %43, %13
ret void
}