#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*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ flock(int /*<<< orphan*/, int);
int /*<<< orphan*/ *fopen(char *, char *);
int parse_line_from_file_nolock(int /*<<< orphan*/ *, char **, int *);
int parse_line_from_file(char *path, char **linep, int *sizep) {
  int result;
  FILE *f = fopen(path, "r");
  if (f == NULL)
    return 1;
  flock(fileno(f), 1);
  result = parse_line_from_file_nolock(f, linep, sizep);
  fclose(f);
  return result;
}


x86 assembly (clang, -O0):
<parse_line_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    118f <parse_line_from_file+0x3f>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <parse_line_from_file+0x77>
mov    -0x30(%rbp),%rdi
call   1050 <fileno@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1070 <flock@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <parse_line_from_file_nolock@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line_from_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xe9c(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a1 <parse_line_from_file+0x51>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fileno@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1070 <flock@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <parse_line_from_file_nolock@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
jmp    11a6 <parse_line_from_file+0x56>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @parse_line_from_file(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %9
%12 = load i32*, i32** %9
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 1, i32* %4
br label %26
15: ; preds = %3
%16 = load i32*, i32** %9
%17 = call i32 @fileno(i32* %16)
%18 = call i32 @flock(i32 %17, i32 1)
%19 = load i32*, i32** %9
%20 = load i8**, i8*** %6
%21 = load i32*, i32** %7
%22 = call i32 @parse_line_from_file_nolock(i32* %19, i8** %20, i32* %21)
store i32 %22, i32* %8
%23 = load i32*, i32** %9
%24 = call i32 @fclose(i32* %23)
%25 = load i32, i32* %8
store i32 %25, i32* %4
br label %26
26: ; preds = %15, %14
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @parse_line_from_file(i8* nocapture %0, i8** %1, i32* %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 @fileno(i32* %4)
%8 = tail call i32 @flock(i32 %7, i32 1)
%9 = tail call i32 @parse_line_from_file_nolock(i32* %4, i8** %1, i32* %2)
%10 = tail call i32 @fclose(i32* %4)
br label %11
11: ; preds = %3, %6
%12 = phi i32 [ %9, %6 ], [ 1, %3 ]
ret i32 %12
}