#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int getline(char **, size_t *, int /*<<< orphan*/ *);
char *strtok(char *, char *);
char *read_file_line(FILE *fp) {
  if (!fp)
    return NULL;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  if ((read = getline(&line, &len, fp)) == -1) {
    return NULL;
  }
  char *retval = strtok(line, "\n");
  return retval;
}


x86 assembly (clang, -O0):
<read_file_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <read_file_line+0x24>
movq   $0x0,-0x8(%rbp)
jmp    119a <read_file_line+0x7a>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <getline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    117e <read_file_line+0x5e>
movq   $0x0,-0x8(%rbp)
jmp    119a <read_file_line+0x7a>
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file_line>:
test   %rdi,%rdi
je     1168 <read_file_line+0x48>
sub    $0x18,%rsp
mov    %rdi,%rdx
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <getline@plt>
cmp    $0xffffffff,%eax
je     116b <read_file_line+0x4b>
mov    0x8(%rsp),%rdi
lea    0xea2(%rip),%rsi
call   1030 <strtok@plt>
add    $0x18,%rsp
ret
xor    %eax,%eax
ret
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i8* @read_file_line(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %3
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i8* null, i8** %2
br label %20
11: ; preds = %1
store i8* null, i8** %4
store i64 0, i64* %5
%12 = load i32*, i32** %3
%13 = call i32 @getline(i8** %4, i64* %5, i32* %12)
store i32 %13, i32* %6
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %11
store i8* null, i8** %2
br label %20
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %7
%19 = load i8*, i8** %7
store i8* %19, i8** %2
br label %20
20: ; preds = %16, %15, %10
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i8* @read_file_line(i32* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = icmp eq i32* %0, null
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%7 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%8 = call i32 @getline(i8** %2, i64* %3, i32* %0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %5, %10
%14 = phi i8* [ %12, %10 ], [ null, %5 ]
br label %15
15: ; preds = %1, %13
%16 = phi i8* [ %14, %13 ], [ null, %1 ]
ret i8* %16
}