#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 EOF;
int /*<<< orphan*/ exit(int);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
void read_line(FILE *file, char *line_buffer) {
  if (file == NULL || line_buffer == NULL) {
    printf("Error: file or line buffer pointer is null.");
    exit(1);
  }
  int ch = getc(file);
  int count = 0;
  while ((ch != '\n') && (ch != EOF)) {
    line_buffer[count] = ch;
    count++;
    ch = getc(file);
  }
  line_buffer[count] = '\0';
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1156 <read_line+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    116c <read_line+0x3c>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x14(%rbp)
mov    %al,-0x19(%rbp)
je     11a0 <read_line+0x70>
mov    -0x14(%rbp),%eax
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b0 <read_line+0x80>
jmp    11da <read_line+0xaa>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    117f <read_line+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     119d <read_line+0x6d>
mov    %rsi,%r14
test   %rsi,%rsi
je     119d <read_line+0x6d>
mov    %rdi,%r12
call   1050 <getc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
je     118c <read_line+0x5c>
mov    0x2e8d(%rip),%r15
cmp    (%r15),%eax
je     118c <read_line+0x5c>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1050 <getc@plt>
cmp    $0xa,%eax
je     118a <read_line+0x5a>
cmp    (%r15),%eax
jne    1170 <read_line+0x40>
mov    %ebx,%ecx
movb   $0x0,(%r14,%rcx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"Error: file or line buffer pointer is null.\00"
@EOF = global i32 0
define void @read_line(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9, %2
%13 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %9
%16 = load i32*, i32** %3
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %5
store i32 0, i32* %6
br label %18
18: ; preds = %27, %15
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %5
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
br label %25
25: ; preds = %21, %18
%26 = phi i1 [ false, %18 ], [ %24, %21 ]
br i1 %26, label %27, label %38
27: ; preds = %25
%28 = load i32, i32* %5
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
%36 = load i32*, i32** %3
%37 = call i32 @getc(i32* %36)
store i32 %37, i32* %5
br label %18
38: ; preds = %25
%39 = load i8*, i8** %4
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8 0, i8* %42
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"Error: file or line buffer pointer is null.\00"
@EOF = global i32 0
define void @read_line(i32* %0, i8* writeonly %1) {
%3 = icmp eq i32* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i32 @getc(i32* %0)
%11 = icmp ne i32 %10, 10
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %10, %12
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %28
15: ; preds = %9, %15
%16 = phi i64 [ %20, %15 ], [ 0, %9 ]
%17 = phi i32 [ %21, %15 ], [ %10, %9 ]
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds i8, i8* %1, i64 %16
store i8 %18, i8* %19
%20 = add nuw i64 %16, 1
%21 = tail call i32 @getc(i32* %0)
%22 = icmp ne i32 %21, 10
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %21, %23
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %15, label %26
26: ; preds = %15
%27 = and i64 %20, 4294967295
br label %28
28: ; preds = %26, %9
%29 = phi i64 [ 0, %9 ], [ %27, %26 ]
%30 = getelementptr inbounds i8, i8* %1, i64 %29
store i8 0, i8* %30
ret void
}