#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*/ exit(int /*<<< orphan*/);
char getchar();
void getline(char *s) {
  register char *rs;
  rs = s;
  while ((*rs = getchar()) == ' ')
    ;
  while (*rs != '\n')
    if (*rs == 0)
      exit(0);
    else if (rs >= &s[99]) {
      while ((*rs = getchar()) != '\n')
        if (*rs == '\0')
          exit(0);
    } else
      *++rs = getchar();
  while (*--rs == ' ')
    *rs = '\n';
}


x86 assembly (clang, -O0):
<getline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    -0x10(%rbp),%rcx
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x20,%eax
jne    1152 <getline+0x32>
jmp    1134 <getline+0x14>
jmp    1157 <getline+0x37>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     11f7 <getline+0xd7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117e <getline+0x5e>
xor    %edi,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x63,%rcx
cmp    %rcx,%rax
jb     11d2 <getline+0xb2>
jmp    1198 <getline+0x78>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    -0x10(%rbp),%rcx
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0xa,%eax
je     11cd <getline+0xad>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c8 <getline+0xa8>
xor    %edi,%edi
call   1040 <exit@plt>
jmp    1198 <getline+0x78>
jmp    11ed <getline+0xcd>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,0x1(%rax)
jmp    11f2 <getline+0xd2>
jmp    1157 <getline+0x37>
jmp    11fc <getline+0xdc>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    1224 <getline+0x104>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
jmp    11fc <getline+0xdc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getline>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %al,(%r14)
cmp    $0x20,%al
je     1130 <getline+0x10>
xor    %ecx,%ecx
lea    (%r14,%rcx,1),%rbx
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
cmp    $0xa,%al
je     1189 <getline+0x69>
test   %al,%al
je     11b3 <getline+0x93>
cmp    $0x63,%r15
jb     1173 <getline+0x53>
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %al,(%rbx)
cmp    $0xa,%al
je     1150 <getline+0x30>
test   %al,%al
jne    1160 <getline+0x40>
jmp    11b3 <getline+0x93>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %al,0x1(%r14,%r15,1)
add    $0x1,%r15
lea    (%r14,%r15,1),%rbx
jmp    1150 <getline+0x30>
cmpb   $0x20,-0x1(%rbx)
jne    11ad <getline+0x8d>
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0xa,(%rbx)
cmpb   $0x20,-0x1(%rbx)
lea    -0x1(%rbx),%rbx
je     11a0 <getline+0x80>
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define void @getline(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %10, %1
%6 = call signext i8 (...) @getchar()
%7 = load i8*, i8** %3
store i8 %6, i8* %7
%8 = sext i8 %6 to i32
%9 = icmp eq i32 %8, 32
br i1 %9, label %10, label %11
10: ; preds = %5
br label %5
11: ; preds = %5
br label %12
12: ; preds = %49, %11
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %50
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %17
%25 = load i8*, i8** %3
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 99
%28 = icmp uge i8* %25, %27
br i1 %28, label %29, label %44
29: ; preds = %24
br label %30
30: ; preds = %42, %29
%31 = call signext i8 (...) @getchar()
%32 = load i8*, i8** %3
store i8 %31, i8* %32
%33 = sext i8 %31 to i32
%34 = icmp ne i32 %33, 10
br i1 %34, label %35, label %43
35: ; preds = %30
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %35
br label %30
43: ; preds = %30
br label %48
44: ; preds = %24
%45 = call signext i8 (...) @getchar()
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
store i8 %45, i8* %47
br label %48
48: ; preds = %44, %43
br label %49
49: ; preds = %48
br label %12
50: ; preds = %12
br label %51
51: ; preds = %57, %50
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i32 -1
store i8* %53, i8** %3
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 32
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = load i8*, i8** %3
store i8 10, i8* %58
br label %51
59: ; preds = %51
ret void
}

LLVM IR (-O2):
define void @getline(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call signext i8 (...) @getchar()
store i8 %3, i8* %0
%4 = icmp eq i8 %3, 32
br i1 %4, label %2, label %5
5: ; preds = %2, %23
%6 = phi i8 [ %24, %23 ], [ %3, %2 ]
%7 = phi i64 [ %25, %23 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = icmp ult i64 %7, 99
br label %10
10: ; preds = %19, %5
%11 = phi i8 [ %6, %5 ], [ %20, %19 ]
switch i8 %11, label %18 [
i8 10, label %12
i8 0, label %16
]
12: ; preds = %10
%13 = getelementptr inbounds i8, i8* %8, i64 -1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %27, label %32
16: ; preds = %10
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %10
br i1 %9, label %23, label %19
19: ; preds = %18, %19
%20 = tail call signext i8 (...) @getchar()
store i8 %20, i8* %8
switch i8 %20, label %19 [
i8 10, label %10
i8 0, label %21
]
21: ; preds = %19
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %18
%24 = tail call signext i8 (...) @getchar()
%25 = add nuw nsw i64 %7, 1
%26 = getelementptr inbounds i8, i8* %0, i64 %25
store i8 %24, i8* %26
br label %5
27: ; preds = %12, %27
%28 = phi i8* [ %29, %27 ], [ %13, %12 ]
store i8 10, i8* %28
%29 = getelementptr inbounds i8, i8* %28, i64 -1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 32
br i1 %31, label %27, label %32
32: ; preds = %27, %12
ret void
}