#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
unsigned long long strtoll(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
unsigned long long readlines(FILE *apri, char *buff) {
  if (buff == NULL)
    buff = (char *)malloc(sizeof(char) * 16384);
  if (buff == NULL)
    return 0;
  while (!feof(apri)) {
    buff[0] = '\0';
    fgets(buff, 16384, apri);
    if (strstr(buff, "libc-") != NULL) {
      return strtoll(strtok(buff, "-"), NULL, 16);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<readlines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1189 <readlines+0x29>
mov    $0x4000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <readlines+0x41>
movq   $0x0,-0x8(%rbp)
jmp    122d <readlines+0xcd>
jmp    11a6 <readlines+0x46>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c4 <readlines+0x64>
jmp    1225 <readlines+0xc5>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4000,%esi
call   1030 <fgets@plt>
mov    -0x18(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1220 <readlines+0xc0>
mov    -0x18(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x8(%rbp)
jmp    122d <readlines+0xcd>
jmp    11a6 <readlines+0x46>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readlines>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rsi,%rsi
jne    1182 <readlines+0x22>
mov    $0x4000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11e1 <readlines+0x81>
lea    0xe77(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11e1 <readlines+0x81>
movb   $0x0,(%rbx)
mov    %rbx,%rdi
mov    $0x4000,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     1190 <readlines+0x30>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    $0x10,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strtoll@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"libc-\00"
@.str.1 = [2 x i8] c"-\00"
define i64 @readlines(i32* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = tail call i64 @malloc(i32 16384)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %20, label %8
8: ; preds = %2, %4
%9 = phi i8* [ %6, %4 ], [ %1, %2 ]
br label %10
10: ; preds = %8, %13
%11 = tail call i32 @feof(i32* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %10
store i8 0, i8* %9
%14 = tail call i32 @fgets(i8* %9, i32 16384, i32* %0)
%15 = tail call i32* @strstr(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %10, label %17
17: ; preds = %13
%18 = tail call i32 @strtok(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i64 @strtoll(i32 %18, i32* null, i32 16)
br label %20
20: ; preds = %10, %4, %17
%21 = phi i64 [ %19, %17 ], [ 0, %4 ], [ 0, %10 ]
ret i64 %21
}