#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*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int rowMax() {
  char c;
  int tempMax = 0, currentRowCount = 0, currentRowPos = 0, tempMaxPos = 0;
  FILE *f;
  f = fopen("car.txt", "r");
  while (!feof(f)) {
    c = fgetc(f);
    if (c == '\n' || feof(f)) {
      ++currentRowPos;
      if (currentRowCount > tempMax) {
        tempMax = currentRowCount;
        tempMaxPos = currentRowPos;
      }
      currentRowCount = 0;
    } else {
      ++currentRowCount;
    }
  }
  fclose(f);
  return tempMaxPos;
}


x86 assembly (clang, -O0):
<rowMax>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe95(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    119a <rowMax+0x5a>
jmp    1201 <rowMax+0xc1>
mov    -0x20(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
je     11c6 <rowMax+0x86>
mov    -0x20(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11f3 <rowMax+0xb3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11e7 <rowMax+0xa7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    11fc <rowMax+0xbc>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <rowMax+0x3b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rowMax>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeb1(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <feof@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1182 <rowMax+0x42>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11ad <rowMax+0x6d>
xchg   %ax,%ax
add    $0x1,%ebx
cmp    %r12d,%ebp
cmovg  %ebx,%r14d
cmovg  %ebp,%r12d
xor    %ebp,%ebp
mov    %r15,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    116e <rowMax+0x2e>
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%al
je     1190 <rowMax+0x50>
mov    %r15,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    1190 <rowMax+0x50>
add    $0x1,%ebp
jmp    11a0 <rowMax+0x60>

LLVM IR (-O0):
@.str = [8 x i8] c"car.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @rowMax() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
br label %8
8: ; preds = %36, %0
%9 = load i32*, i32** %6
%10 = call i64 @feof(i32* %9)
%11 = icmp ne i64 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %37
13: ; preds = %8
%14 = load i32*, i32** %6
%15 = call signext i8 @fgetc(i32* %14)
store i8 %15, i8* %1
%16 = load i8, i8* %1
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 10
br i1 %18, label %23, label %19
19: ; preds = %13
%20 = load i32*, i32** %6
%21 = call i64 @feof(i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19, %13
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* %3
store i32 %30, i32* %2
%31 = load i32, i32* %4
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %23
store i32 0, i32* %3
br label %36
33: ; preds = %19
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %36
36: ; preds = %33, %32
br label %8
37: ; preds = %8
%38 = load i32*, i32** %6
%39 = call i32 @fclose(i32* %38)
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
@.str = [8 x i8] c"car.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @rowMax() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @feof(i32* %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %28
4: ; preds = %0, %21
%5 = phi i32 [ %25, %21 ], [ 0, %0 ]
%6 = phi i32 [ %24, %21 ], [ 0, %0 ]
%7 = phi i32 [ %23, %21 ], [ 0, %0 ]
%8 = phi i32 [ %22, %21 ], [ 0, %0 ]
%9 = tail call signext i8 @fgetc(i32* %1)
%10 = icmp eq i8 %9, 10
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = tail call i64 @feof(i32* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %11, %4
%15 = add nsw i32 %7, 1
%16 = icmp sgt i32 %8, %5
%17 = select i1 %16, i32 %15, i32 %6
%18 = select i1 %16, i32 %8, i32 %5
br label %21
19: ; preds = %11
%20 = add nsw i32 %8, 1
br label %21
21: ; preds = %19, %14
%22 = phi i32 [ 0, %14 ], [ %20, %19 ]
%23 = phi i32 [ %15, %14 ], [ %7, %19 ]
%24 = phi i32 [ %17, %14 ], [ %6, %19 ]
%25 = phi i32 [ %18, %14 ], [ %5, %19 ]
%26 = tail call i64 @feof(i32* %1)
%27 = icmp eq i64 %26, 0
br i1 %27, label %4, label %28
28: ; preds = %21, %0
%29 = phi i32 [ 0, %0 ], [ %24, %21 ]
%30 = tail call i32 @fclose(i32* %1)
ret i32 %29
}