#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getLongestWord(char *, char *, int *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
char tolower(char);
int main(void) {
  char line[10000 + 2], longestWord[10000 + 2], i;
  int stop;
  strcpy(longestWord, "");
  while (1) {
    fgets(line, 10000 + 2, stdin);
    getLongestWord(line, longestWord, &stop);
    if (stop)
      break;
  }
  for (i = 0; longestWord[i] != '\0'; i++)
    longestWord[i] = tolower(longestWord[i]);
  printf("%s\n", longestWord);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x4e40(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x2720(%rbp),%rdi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
mov    $0x2712,%esi
call   1060 <fgets@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x4e40(%rbp),%rsi
lea    -0x4e48(%rbp),%rdx
call   1040 <getLongestWord@plt>
cmpl   $0x0,-0x4e48(%rbp)
je     11bb <main+0x6b>
jmp    11c0 <main+0x70>
jmp    1175 <main+0x25>
movb   $0x0,-0x4e41(%rbp)
movsbq -0x4e41(%rbp),%rax
ff
movsbl -0x4e40(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1219 <main+0xc9>
movsbq -0x4e41(%rbp),%rax
ff
movsbl -0x4e40(%rbp,%rax,1),%edi
ff
call   1070 <tolower@plt>
mov    %al,%cl
movsbq -0x4e41(%rbp),%rax
ff
mov    %cl,-0x4e40(%rbp,%rax,1)
mov    -0x4e41(%rbp),%al
add    $0x1,%al
mov    %al,-0x4e41(%rbp)
jmp    11c7 <main+0x77>
lea    -0x4e40(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4e48,%rsp
lea    0xe9e(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    0x2e6f(%rip),%rbx
lea    0x2730(%rsp),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edx
mov    %r14,%rdi
mov    $0x2712,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <getLongestWord@plt>
cmpl   $0x0,0xc(%rsp)
je     1190 <main+0x40>
mov    0x10(%rsp),%al
test   %al,%al
je     11e4 <main+0x94>
mov    $0x1,%bl
xchg   %ax,%ax
movsbl %al,%edi
call   1070 <tolower@plt>
mov    %al,(%r12)
movsbq %bl,%rbx
lea    (%rsp,%rbx,1),%r12
add    $0x10,%r12
movzbl 0x10(%rsp,%rbx,1),%eax
add    $0x1,%bl
test   %al,%al
jne    11c0 <main+0x70>
lea    0xe15(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x4e48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [10002 x i8]
%2 = alloca [10002 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [10002 x i8], [10002 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [10002 x i8], [10002 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %8, %0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %4, i32 10002, i32 %9)
%11 = call i32 @getLongestWord(i8* %4, i8* %5, i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %8
%15 = load i8, i8* %5
%16 = icmp eq i8 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %14, %17
%18 = phi i8 [ %25, %17 ], [ %15, %14 ]
%19 = phi i8* [ %24, %17 ], [ %5, %14 ]
%20 = phi i8 [ %22, %17 ], [ 0, %14 ]
%21 = call signext i8 @tolower(i8 signext %18)
store i8 %21, i8* %19
%22 = add i8 %20, 1
%23 = sext i8 %22 to i64
%24 = getelementptr inbounds [10002 x i8], [10002 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %17
27: ; preds = %17, %14
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret i32 0
}