#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int word(char *);
int main() {
  int string(char);
  int i;
  char str[20];
  printf("input the string:\n");
  gets(str);
  printf("the longest word is :");
  for (i == word(str); string(str[i]); i++)
    printf("%c", str[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <gets@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <word@plt>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1040 <string@plt>
cmp    $0x0,%eax
je     11b9 <main+0x79>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117d <main+0x3d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <word@plt>
movsbl (%rsp),%edi
call   1060 <string@plt>
test   %eax,%eax
je     11c9 <main+0x69>
lea    0x1(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl -0x1(%rbx),%edi
call   1030 <putchar@plt>
movsbl (%rbx),%edi
call   1060 <string@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    11b0 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"input the string:\0A\00"
@.str.1 = [22 x i8] c"the longest word is :\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = call i32 @word(i8* %9)
%11 = icmp eq i32 %8, %10
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %27, %0
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @string(i8 signext %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %13
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %13
30: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"the longest word is :\00"
@str = [18 x i8] c"input the string:\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @word(i8* %2)
%7 = load i8, i8* %2
%8 = call i32 @string(i8 signext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %0, %10
%11 = phi i64 [ %16, %10 ], [ 0, %0 ]
%12 = phi i8* [ %17, %10 ], [ %2, %0 ]
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 @putchar(i32 %14)
%16 = add i64 %11, 1
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @string(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %10, %0
ret i32 0
}