#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*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
int get_input_file_line(FILE *f, char line[], int line_buf_size) {
  if (fgets(line, line_buf_size, f) == NULL)
    return (1);
  line[strlen(line) - 1] = '\0';
  if (strlen(line) == ((size_t)(line_buf_size - 1))) {
    fprintf(stderr,
            "The line size in config file should be lower than %d bytes.\n",
            1024);
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_input_file_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1179 <get_input_file_line+0x39>
movl   $0x1,-0x4(%rbp)
jmp    11df <get_input_file_line+0x9f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    11d8 <get_input_file_line+0x98>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0x400,%edx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input_file_line>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    %rsi,%rdi
mov    %ebp,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11a3 <get_input_file_line+0x63>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
add    $0xffffffff,%ebp
movslq %ebp,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
jne    11a8 <get_input_file_line+0x68>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
mov    $0x400,%edx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"The line size in config file should be lower than %d bytes.\0A\00"
define i32 @get_input_file_line(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %6
%9 = load i32, i32* %7
%10 = load i32*, i32** %5
%11 = call i32* @fgets(i8* %8, i32 %9, i32* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 1, i32* %4
br label %31
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = load i8*, i8** %6
%17 = call i64 @strlen(i8* %16)
%18 = sub i64 %17, 1
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 0, i8* %19
%20 = load i8*, i8** %6
%21 = call i64 @strlen(i8* %20)
%22 = load i32, i32* %7
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = icmp eq i64 %21, %24
br i1 %25, label %26, label %30
26: ; preds = %14
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 1024)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %14
store i32 0, i32* %4
br label %31
31: ; preds = %30, %13
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"The line size in config file should be lower than %d bytes.\0A\00"
define i32 @get_input_file_line(i32* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i32* @fgets(i8* %1, i32 %2, i32* %0)
%5 = icmp eq i32* %4, null
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = add i64 %7, -1
%9 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 0, i8* %9
%10 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%11 = add nsw i32 %2, -1
%12 = sext i32 %11 to i64
%13 = icmp eq i64 %10, %12
br i1 %13, label %14, label %18
14: ; preds = %6
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 1024)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %6, %3
%19 = phi i32 [ 1, %3 ], [ 0, %6 ]
ret i32 %19
}