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

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int conf_get_line(FILE *stream, char *buf, u_int32_t len) {
  int c;
  while (len-- > 1) {
    c = fgetc(stream);
    if (c == '\n') {
      *buf = 0;
      return (1);
    } else if (c == EOF)
      break;
    *buf++ = c;
  }
  *buf = 0;
  return (0);
}


x86 assembly (clang, -O0):
<conf_get_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x1,%eax
jle    1197 <conf_get_line+0x87>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xa,-0x20(%rbp)
jne    1160 <conf_get_line+0x50>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a5 <conf_get_line+0x95>
mov    -0x20(%rbp),%eax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
jne    1177 <conf_get_line+0x67>
jmp    1197 <conf_get_line+0x87>
jmp    117c <conf_get_line+0x6c>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1123 <conf_get_line+0x13>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_get_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
xor    %r14d,%r14d
cmp    $0x2,%edx
jl     1169 <conf_get_line+0x59>
mov    %edx,%ebp
mov    %rdi,%r15
add    $0x1,%ebp
mov    0x2eb6(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%eax
je     1163 <conf_get_line+0x53>
cmp    (%r12),%eax
je     1169 <conf_get_line+0x59>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
ja     1140 <conf_get_line+0x30>
jmp    1169 <conf_get_line+0x59>
mov    $0x1,%r14d
movb   $0x0,(%rbx)
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @conf_get_line(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %7
%11 = add nsw i32 %10, -1
store i32 %11, i32* %7
%12 = icmp sgt i32 %10, 1
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load i32*, i32** %5
%15 = call i32 @fgetc(i32* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i8*, i8** %6
store i8 0, i8* %19
store i32 1, i32* %4
br label %33
20: ; preds = %13
%21 = load i32, i32* %8
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
br label %31
25: ; preds = %20
br label %26
26: ; preds = %25
%27 = load i32, i32* %8
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
store i8 %28, i8* %29
br label %9
31: ; preds = %24, %9
%32 = load i8*, i8** %6
store i8 0, i8* %32
store i32 0, i32* %4
br label %33
33: ; preds = %31, %18
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @conf_get_line(i32* nocapture %0, i8* nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 1
br i1 %4, label %5, label %18
5: ; preds = %3, %14
%6 = phi i32 [ %8, %14 ], [ %2, %3 ]
%7 = phi i8* [ %16, %14 ], [ %1, %3 ]
%8 = add nsw i32 %6, -1
%9 = tail call i32 @fgetc(i32* %0)
%10 = icmp eq i32 %9, 10
br i1 %10, label %18, label %11
11: ; preds = %5
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %9, %12
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = trunc i32 %9 to i8
%16 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %15, i8* %7
%17 = icmp ugt i32 %6, 2
br i1 %17, label %5, label %18
18: ; preds = %5, %11, %14, %3
%19 = phi i8* [ %1, %3 ], [ %16, %14 ], [ %7, %11 ], [ %7, %5 ]
%20 = phi i32 [ 0, %3 ], [ 0, %14 ], [ 0, %11 ], [ 1, %5 ]
store i8 0, i8* %19
ret i32 %20
}