#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 getchar();
int /*<<< orphan*/ lower(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  int c, i;
  char s[1000];
  while ((c = getchar()) != '\n') {
    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)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     1173 <main+0x43>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
cltq
mov    %cl,-0x400(%rbp,%rax,1)
jmp    1142 <main+0x12>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rdi
call   1050 <lower@plt>
lea    -0x400(%rbp),%rsi
lea    0xe67(%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    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1179 <main+0x49>
mov    %rsp,%rbx
movabs $0x100000000,%r15
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
add    %r15,%r14
mov    %al,(%rbx)
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
cmp    $0xa,%eax
jne    1160 <main+0x30>
sar    $0x20,%r14
movb   $0x0,(%rsp,%r14,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <lower@plt>
lea    0xe70(%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):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
store i32 0, i32* %1
br label %5
5: ; preds = %8, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %2
%10 = trunc i32 %9 to i8
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %13
store i8 %10, i8* %14
br label %5
15: ; preds = %5
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%20 = call i32 @lower(i8* %19)
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.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 i32 (...) @getchar()
%4 = icmp eq i32 %3, 10
br i1 %4, label %16, label %5
5: ; preds = %0, %5
%6 = phi i64 [ %9, %5 ], [ 0, %0 ]
%7 = phi i32 [ %11, %5 ], [ %3, %0 ]
%8 = trunc i32 %7 to i8
%9 = add i64 %6, 1
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %6
store i8 %8, i8* %10
%11 = tail call i32 (...) @getchar()
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = shl i64 %9, 32
%15 = ashr exact i64 %14, 32
br label %16
16: ; preds = %13, %0
%17 = phi i64 [ 0, %0 ], [ %15, %13 ]
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 @lower(i8* %2)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}