#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int scanPlaylist(FILE *pFile, int *pwOffsetBytes) {
  int wChar = 0;
  int wByteCnt = 0;
  int wLineCnt = 0;
  *pwOffsetBytes = 0;
  do {
    wChar = fgetc(pFile);
    wByteCnt++;
    if (wChar == '\n') {
      wLineCnt++;
      pwOffsetBytes++;
      *pwOffsetBytes = wByteCnt;
    }
  } while (wChar != EOF);
  return wLineCnt;
}


x86 assembly (clang, -O0):
<scanPlaylist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    117c <scanPlaylist+0x6c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1181 <scanPlaylist+0x71>
mov    -0x14(%rbp),%eax
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
jne    113f <scanPlaylist+0x2f>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanPlaylist>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x0,(%rsi)
xor    %r15d,%r15d
mov    $0x1,%ebp
mov    0x2eb5(%rip),%r12
jmp    1149 <scanPlaylist+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    (%r12),%eax
je     1163 <scanPlaylist+0x53>
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%eax
jne    1140 <scanPlaylist+0x30>
add    $0x1,%r15d
mov    %ebp,0x4(%rbx)
add    $0x4,%rbx
jmp    1140 <scanPlaylist+0x30>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @scanPlaylist(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i32*, i32** %4
store i32 0, i32* %8
br label %9
9: ; preds = %24, %2
%10 = load i32*, i32** %3
%11 = call i32 @fgetc(i32* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %23
16: ; preds = %9
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %7
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %4
%21 = load i32, i32* %6
%22 = load i32*, i32** %4
store i32 %21, i32* %22
br label %23
23: ; preds = %16, %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %5
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %9, label %28
28: ; preds = %24
%29 = load i32, i32* %7
ret i32 %29
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @scanPlaylist(i32* nocapture %0, i32* nocapture writeonly %1) {
store i32 0, i32* %1
br label %3
3: ; preds = %13, %2
%4 = phi i32* [ %1, %2 ], [ %14, %13 ]
%5 = phi i32 [ 0, %2 ], [ %8, %13 ]
%6 = phi i32 [ 0, %2 ], [ %15, %13 ]
%7 = tail call i32 @fgetc(i32* %0)
%8 = add nuw nsw i32 %5, 1
%9 = icmp eq i32 %7, 10
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = add nsw i32 %6, 1
%12 = getelementptr inbounds i32, i32* %4, i64 1
store i32 %8, i32* %12
br label %13
13: ; preds = %3, %10
%14 = phi i32* [ %12, %10 ], [ %4, %3 ]
%15 = phi i32 [ %11, %10 ], [ %6, %3 ]
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %7, %16
br i1 %17, label %18, label %3
18: ; preds = %13
ret i32 %15
}