#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*/ buffer;
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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ process(int /*<<< orphan*/, char *);
int strlen(char *);
int main() {
  char buffer[1024];
  int lineNum = 1, len;
  FILE *fp;
  fp = fopen("days_of_week.txt", "r");
  while (1) {
    memset(buffer, 0, sizeof(buffer));
    fgets(buffer, sizeof(buffer), fp);
    len = strlen(buffer);
    if (len == 0 || buffer[len - 1] == '\0') {
      break;
    }
    process(lineNum++, buffer);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x414(%rbp)
lea    0xe7d(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x0,-0x418(%rbp)
je     11fc <main+0x9c>
mov    -0x418(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    1201 <main+0xa1>
jmp    1223 <main+0xc3>
mov    -0x414(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rsi
call   1060 <process@plt>
jmp    1196 <main+0x36>
mov    -0x420(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1201 <main+0xa1>
mov    $0x1,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltq
cmpb   $0x0,-0x1(%rax,%rbx,1)
je     1201 <main+0xa1>
lea    0x1(%rdi),%ebp
mov    %rbx,%rsi
call   1060 <process@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
test   %eax,%eax
jne    11c0 <main+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"days_of_week.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %3
%6 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
br label %7
7: ; preds = %0, %26
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 1024)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %5
%12 = call i32 @fgets(i8* %10, i32 1024, i32* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %7
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17, %7
br label %31
26: ; preds = %17
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%30 = call i32 @process(i32 %27, i8* %29)
br label %7
31: ; preds = %25
%32 = load i32*, i32** %5
%33 = call i32 @fclose(i32* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"days_of_week.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @memset(i8* %2, i32 0, i32 1024)
%5 = call i32 @fgets(i8* %2, i32 1024, i32* %3)
%6 = call i32 @strlen(i8* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %0, %16
%9 = phi i32 [ %21, %16 ], [ %6, %0 ]
%10 = phi i32 [ %17, %16 ], [ 1, %0 ]
%11 = add nsw i32 %9, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %8
%17 = add nuw nsw i32 %10, 1
%18 = call i32 @process(i32 %10, i8* %2)
%19 = call i32 @memset(i8* %2, i32 0, i32 1024)
%20 = call i32 @fgets(i8* %2, i32 1024, i32* %3)
%21 = call i32 @strlen(i8* %2)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %8
23: ; preds = %8, %16, %0
%24 = call i32 @fclose(i32* %3)
ret i32 0
}