#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 */

/* Variables and functions */
int /*<<< orphan*/ _fatal_error(char *);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
size_t strlen(char *);
void read_line(char *buffer, char *error_message) {
  char *status;
  size_t length;
  buffer[0] = 0;
  status = fgets(buffer, 128 + 1, stdin);
  length = strlen(buffer);
  if (status == NULL || length == 0 || length > 128) {
    _fatal_error(error_message);
  }
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
mov    $0x81,%esi
call   1040 <fgets@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1193 <read_line+0x63>
cmpq   $0x0,-0x20(%rbp)
je     1193 <read_line+0x63>
cmpq   $0x80,-0x20(%rbp)
jbe    119c <read_line+0x6c>
mov    -0x10(%rbp),%rdi
call   1050 <_fatal_error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,(%rdi)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
mov    $0x81,%esi
call   1040 <fgets@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %r15,%r15
je     1174 <read_line+0x44>
test   %rax,%rax
je     1174 <read_line+0x44>
cmp    $0x81,%rax
jae    1174 <read_line+0x44>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <_fatal_error@plt>

LLVM IR (-O0):
@stdin = global i32 0
define void @read_line(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 0, i8* %8
%9 = load i8*, i8** %3
%10 = load i32, i32* @stdin
%11 = call i8* @fgets(i8* %9, i32 129, i32 %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %3
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %6
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %2
%17 = load i64, i64* %6
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i64, i64* %6
%21 = icmp ugt i64 %20, 128
br i1 %21, label %22, label %25
22: ; preds = %19, %16, %2
%23 = load i8*, i8** %4
%24 = call i32 @_fatal_error(i8* %23)
br label %25
25: ; preds = %22, %19
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
define void @read_line(i8* %0, i8* %1) {
store i8 0, i8* %0
%3 = load i32, i32* @stdin
%4 = tail call i8* @fgets(i8* %0, i32 129, i32 %3)
%5 = tail call i64 @strlen(i8* %0)
%6 = icmp eq i8* %4, null
%7 = icmp eq i64 %5, 0
%8 = select i1 %6, i1 true, i1 %7
%9 = icmp ugt i64 %5, 128
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @_fatal_error(i8* %1)
br label %13
13: ; preds = %2, %11
ret void
}