#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;
char getchar();
int /*<<< orphan*/ lower(char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char s[1000], c;
  int i;
  for (i = 0; (c = getchar()) != EOF && c != ' ' && c != '\n' && i < 1000 - 1;
       i++)
    s[i] = c;
  s[i] = '\0';
  lower(s);
  printf("%s\n", s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x3f1(%rbp)
movsbl %al,%ecx
mov    0x2e85(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x3f9(%rbp)
je     11b9 <main+0x89>
movsbl -0x3f1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x3f9(%rbp)
je     11b9 <main+0x89>
movsbl -0x3f1(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x3f9(%rbp)
je     11b9 <main+0x89>
cmpl   $0x3e7,-0x3f8(%rbp)
setl   %al
mov    %al,-0x3f9(%rbp)
mov    -0x3f9(%rbp),%al
test   $0x1,%al
jne    11cc <main+0x9c>
jmp    11f4 <main+0xc4>
mov    -0x3f1(%rbp),%cl
movslq -0x3f8(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    114c <main+0x1c>
movslq -0x3f8(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
lea    -0x3f0(%rbp),%rdi
call   1050 <lower@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e9b(%rip),%r14
cmp    (%r14),%al
je     1187 <main+0x57>
xor    %r15d,%r15d
cmp    $0xa,%al
je     1187 <main+0x57>
cmp    $0x20,%al
je     1187 <main+0x57>
xor    %ebx,%ebx
nop
mov    %al,(%rsp,%rbx,1)
lea    0x1(%rbx),%r15
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1187 <main+0x57>
cmp    $0x20,%al
je     1187 <main+0x57>
cmp    (%r14),%al
je     1187 <main+0x57>
cmp    $0x3e6,%rbx
mov    %r15,%rbx
jb     1160 <main+0x30>
movb   $0x0,(%rsp,%r15,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <lower@plt>
lea    0xe62(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = freeze i8 %4
%6 = icmp eq i8 %3, %5
br i1 %6, label %22, label %7
7: ; preds = %0
switch i8 %3, label %8 [
i8 32, label %22
i8 10, label %22
]
8: ; preds = %7, %8
%9 = phi i64 [ %12, %8 ], [ 0, %7 ]
%10 = phi i8 [ %13, %8 ], [ %3, %7 ]
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %9
store i8 %10, i8* %11
%12 = add nuw nsw i64 %9, 1
%13 = tail call signext i8 (...) @getchar()
%14 = load i8, i8* @EOF
%15 = icmp ne i8 %13, %14
%16 = icmp ne i8 %13, 32
%17 = and i1 %16, %15
%18 = icmp ne i8 %13, 10
%19 = and i1 %18, %17
%20 = icmp ult i64 %9, 998
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %8, label %22
22: ; preds = %8, %7, %7, %0
%23 = phi i64 [ 0, %7 ], [ 0, %0 ], [ 0, %7 ], [ %12, %8 ]
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i32 @lower(i8* %2)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}