#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*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
int is_pls_file(FILE *fp) {
  char buffer[500];
  fgets(buffer, 500, fp);
  if (strcmp(buffer, "[playlist]\n") != 0) {
    fseek(fp, 0, SEEK_SET);
    return 0;
  }
  while (!feof(fp)) {
    fgets(buffer, 500, fp);
  }
  if (strstr(buffer, "Version=") != NULL) {
    fseek(fp, 0, SEEK_SET);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_pls_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1f4,%esi
call   1030 <fgets@plt>
lea    -0x210(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b1 <is_pls_file+0x61>
mov    -0x10(%rbp),%rdi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
movl   $0x0,-0x4(%rbp)
jmp    1232 <is_pls_file+0xe2>
jmp    11b6 <is_pls_file+0x66>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d4 <is_pls_file+0x84>
jmp    11ee <is_pls_file+0x9e>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1f4,%esi
call   1030 <fgets@plt>
jmp    11b6 <is_pls_file+0x66>
lea    -0x210(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     122b <is_pls_file+0xdb>
mov    -0x10(%rbp),%rdi
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
movl   $0x1,-0x4(%rbp)
jmp    1232 <is_pls_file+0xe2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_pls_file>:
push   %rbp
push   %rbx
sub    $0x1f8,%rsp
mov    %rdi,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
lea    0xe8a(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11d5 <is_pls_file+0x85>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11bc <is_pls_file+0x6c>
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     11a0 <is_pls_file+0x50>
lea    0xe49(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strstr@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11f4 <is_pls_file+0xa4>
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %ebp,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ebp,%ebp
jmp    11e8 <is_pls_file+0x98>

LLVM IR (-O0):
@.str = [12 x i8] c"[playlist]\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [9 x i8] c"Version=\00"
define i32 @is_pls_file(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [500 x i8]
store i32* %0, i32** %3
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%6 = load i32*, i32** %3
%7 = call i32 @fgets(i8* %5, i32 500, i32* %6)
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %12, i32 0, i32 %13)
store i32 0, i32* %2
br label %34
15: ; preds = %1
br label %16
16: ; preds = %21, %15
%17 = load i32*, i32** %3
%18 = call i32 @feof(i32* %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%23 = load i32*, i32** %3
%24 = call i32 @fgets(i8* %22, i32 500, i32* %23)
br label %16
25: ; preds = %16
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%27 = call i32* @strstr(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32*, i32** %3
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
store i32 1, i32* %2
br label %34
33: ; preds = %25
store i32 0, i32* %2
br label %34
34: ; preds = %33, %29, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [12 x i8] c"[playlist]\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [9 x i8] c"Version=\00"
define i32 @is_pls_file(i32* nocapture %0) {
%2 = alloca [500 x i8]
%3 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%4 = call i32 @fgets(i8* %3, i32 500, i32* %0)
%5 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = call i32 @feof(i32* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7, %10
%11 = call i32 @fgets(i8* %3, i32 500, i32* %0)
%12 = call i32 @feof(i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %10, label %14
14: ; preds = %10, %7
%15 = call i32* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %21, label %17
17: ; preds = %14, %1
%18 = phi i32 [ 0, %1 ], [ 1, %14 ]
%19 = load i32, i32* @SEEK_SET
%20 = call i32 @fseek(i32* %0, i32 0, i32 %19)
br label %21
21: ; preds = %17, %14
%22 = phi i32 [ 0, %14 ], [ %18, %17 ]
ret i32 %22
}