#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 */
char EOF;
int /*<<< orphan*/ free(char *);
char getchar();
int is_valid(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int);
char *realloc(char *, int);
int main() {
  int size = 0;
  char *egn = malloc(sizeof(char)), c;
  do {
    c = getchar();
    egn[size++] = c;
    egn = realloc(egn, size + 1);
  } while (c != ' ' && c != '\n' && c != EOF);
  egn[size - 1] = '\0';
  printf("%d", is_valid(egn));
  free(egn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1070 <realloc@plt>
mov    %rax,-0x10(%rbp)
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x12(%rbp)
je     11f3 <main+0x93>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x12(%rbp)
je     11f3 <main+0x93>
movsbl -0x11(%rbp),%eax
mov    0x2e00(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1184 <main+0x24>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1080 <is_valid@plt>
mov    %eax,%esi
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0x2e6c(%rip),%r15
xor    %eax,%eax
xchg   %ax,%ax
mov    %rax,%r12
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
mov    %al,(%r14,%r12,1)
lea    0x2(%r12),%esi
mov    %r14,%rdi
call   1070 <realloc@plt>
mov    %rax,%r14
cmp    $0xa,%bl
je     11b4 <main+0x54>
cmp    $0x20,%bl
je     11b4 <main+0x54>
lea    0x1(%r12),%rax
cmp    (%r15),%bl
jne    1180 <main+0x20>
mov    %r12d,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
call   1080 <is_valid@plt>
lea    0xe35(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i8* @malloc(i32 1)
store i8* %5, i8** %3
br label %6
6: ; preds = %32, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %4
%8 = load i8, i8* %4
%9 = load i8*, i8** %3
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
store i8 %8, i8* %13
%14 = load i8*, i8** %3
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
%17 = call i8* @realloc(i8* %14, i32 %16)
store i8* %17, i8** %3
br label %18
18: ; preds = %6
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 32
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br label %32
32: ; preds = %26, %22, %18
%33 = phi i1 [ false, %22 ], [ false, %18 ], [ %31, %26 ]
br i1 %33, label %6, label %34
34: ; preds = %32
%35 = load i8*, i8** %3
%36 = load i32, i32* %2
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
store i8 0, i8* %39
%40 = load i8*, i8** %3
%41 = call i32 @is_valid(i8* %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = load i8*, i8** %3
%44 = call i32 @free(i8* %43)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
br label %2
2: ; preds = %10, %0
%3 = phi i64 [ %11, %10 ], [ 0, %0 ]
%4 = phi i8* [ %9, %10 ], [ %1, %0 ]
%5 = tail call signext i8 (...) @getchar()
%6 = getelementptr inbounds i8, i8* %4, i64 %3
store i8 %5, i8* %6
%7 = trunc i64 %3 to i32
%8 = add i32 %7, 2
%9 = tail call i8* @realloc(i8* %4, i32 %8)
switch i8 %5, label %10 [
i8 32, label %14
i8 10, label %14
]
10: ; preds = %2
%11 = add nuw i64 %3, 1
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %5, %12
br i1 %13, label %14, label %2
14: ; preds = %2, %2, %10
%15 = and i64 %3, 4294967295
%16 = getelementptr inbounds i8, i8* %9, i64 %15
store i8 0, i8* %16
%17 = tail call i32 @is_valid(i8* %9)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = tail call i32 @free(i8* %9)
ret i32 0
}