#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;
scalar_t__ atoi(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char, char);
int /*<<< orphan*/ *strstr(char *, char *);
unsigned int pls_get_number_entries(FILE *fp) {
  char buffer[500];
  char number_entries_str[3];
  fseek(fp, 0, SEEK_SET);
  fgets(buffer, 500, fp);
  fgets(buffer, 500, fp);
  if (strstr(buffer, "NumberOfEntries=") != NULL) {
    sprintf(number_entries_str, "%c%c", buffer[16], buffer[17]);
    return (unsigned int)atoi(number_entries_str);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<pls_get_number_entries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1f4,%esi
call   1030 <fgets@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1f4,%esi
call   1030 <fgets@plt>
lea    -0x210(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11f1 <pls_get_number_entries+0xa1>
lea    -0x213(%rbp),%rdi
mov    -0x200(%rbp),%al
lea    0xe43(%rip),%rsi
movsbl %al,%edx
movsbl -0x1ff(%rbp),%ecx
call   1060 <sprintf@plt>
lea    -0x213(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <pls_get_number_entries+0xa8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pls_get_number_entries>:
push   %r15
push   %r14
push   %rbx
sub    $0x210,%rsp
mov    %rdi,%rbx
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
xor    %esi,%esi
call   1040 <fseek@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
mov    %r15,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
lea    0xe62(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11d4 <pls_get_number_entries+0x84>
movsbl 0x20(%rsp),%edx
movsbl 0x21(%rsp),%ecx
lea    0xe55(%rip),%rsi
lea    0xd(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %rax,%r14
mov    %r14d,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [17 x i8] c"NumberOfEntries=\00"
@.str.1 = [5 x i8] c"%c%c\00"
define i32 @pls_get_number_entries(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [500 x i8]
%5 = alloca [3 x i8]
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = load i32, i32* @SEEK_SET
%8 = call i32 @fseek(i32* %6, i32 0, i32 %7)
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%10 = load i32*, i32** %3
%11 = call i32 @fgets(i8* %9, i32 500, i32* %10)
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%13 = load i32*, i32** %3
%14 = call i32 @fgets(i8* %12, i32 500, i32* %13)
%15 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%16 = call i32* @strstr(i8* %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %28
18: ; preds = %1
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 16
%21 = load i8, i8* %20
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 17
%23 = load i8, i8* %22
%24 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 signext %21, i8 signext %23)
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%26 = call i64 @atoi(i8* %25)
%27 = trunc i64 %26 to i32
store i32 %27, i32* %2
br label %29
28: ; preds = %1
store i32 0, i32* %2
br label %29
29: ; preds = %28, %18
%30 = load i32, i32* %2
ret i32 %30
}

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