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

/* Variables and functions */
int getchar();
char *get_string(void) {
  static char text_buffer[256];
  int character;
  register size_t i;
  do {
    for (i = 0; i < sizeof(text_buffer); i++) {
      text_buffer[i] = '\0';
      character = getchar();
      if (character == '\n')
        return &(text_buffer[0]);
      if (character < 32 || character > 126)
        return NULL;
      text_buffer[i] = (char)character;
    }
  } while (text_buffer[0] == '\0');
  return NULL;
}


x86 assembly (clang, -O0):
<get_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x18(%rbp)
cmpq   $0x100,-0x18(%rbp)
jae    11a6 <get_string+0x96>
mov    -0x18(%rbp),%rcx
lea    0x2f07(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    1161 <get_string+0x51>
lea    0x2ee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <get_string+0xb3>
cmpl   $0x20,-0xc(%rbp)
jl     1175 <get_string+0x65>
cmpl   $0x7e,-0xc(%rbp)
jle    1182 <get_string+0x72>
movq   $0x0,-0x8(%rbp)
jmp    11c3 <get_string+0xb3>
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rcx
lea    0x2eae(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <get_string+0x10>
jmp    11ab <get_string+0x9b>
movsbl 0x2e8e(%rip),%eax
cmp    $0x0,%eax
je     1118 <get_string+0x8>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_string>:
push   %r15
push   %r14
push   %rbx
xor    %r14d,%r14d
lea    0x2f21(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx,%r15,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%eax
je     116a <get_string+0x5a>
lea    -0x7f(%rax),%ecx
cmp    $0xffffffa1,%ecx
jb     116d <get_string+0x5d>
mov    %al,(%rbx,%r15,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1130 <get_string+0x20>
cmpb   $0x0,0x2edf(%rip)
mov    $0x0,%ebx
je     1130 <get_string+0x20>
jmp    116d <get_string+0x5d>
mov    %r15,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_string.text_buffer = internal global [256 x i8] zeroinitializer
define i8* @get_string() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i64
br label %4
4: ; preds = %31, %0
store i64 0, i64* %3
br label %5
5: ; preds = %27, %4
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 256
br i1 %7, label %8, label %30
8: ; preds = %5
%9 = load i64, i64* %3
%10 = getelementptr inbounds [256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 (...) @getchar()
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %8
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 0), i8** %1
br label %36
15: ; preds = %8
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 32
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 126
br i1 %20, label %21, label %22
21: ; preds = %18, %15
store i8* null, i8** %1
br label %36
22: ; preds = %18
%23 = load i32, i32* %2
%24 = trunc i32 %23 to i8
%25 = load i64, i64* %3
%26 = getelementptr inbounds [256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 %25
store i8 %24, i8* %26
br label %27
27: ; preds = %22
%28 = load i64, i64* %3
%29 = add i64 %28, 1
store i64 %29, i64* %3
br label %5
30: ; preds = %5
br label %31
31: ; preds = %30
%32 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 0)
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %4, label %35
35: ; preds = %31
store i8* null, i8** %1
br label %36
36: ; preds = %35, %21, %14
%37 = load i8*, i8** %1
ret i8* %37
}

LLVM IR (-O2):
@get_string.text_buffer = internal global [256 x i8] zeroinitializer
define i8* @get_string() {
br label %1
1: ; preds = %13, %0
%2 = phi i64 [ 0, %0 ], [ %14, %13 ]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 %2
store i8 0, i8* %3
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, 10
br i1 %5, label %18, label %6
6: ; preds = %1
%7 = add i32 %4, -127
%8 = icmp ult i32 %7, -95
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = trunc i32 %4 to i8
store i8 %10, i8* %3
%11 = add nuw nsw i64 %2, 1
%12 = icmp eq i64 %11, 256
br i1 %12, label %15, label %13
13: ; preds = %9, %15
%14 = phi i64 [ %11, %9 ], [ 0, %15 ]
br label %1
15: ; preds = %9
%16 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 0)
%17 = icmp eq i8 %16, 0
br i1 %17, label %13, label %18
18: ; preds = %15, %6, %1
%19 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @get_string.text_buffer, i64 0, i64 0), %1 ], [ null, %6 ], [ null, %15 ]
ret i8* %19
}