#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*/ printf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int stringOfSubstring(char const *, char *);
unsigned long strlen(char const *);
char *strtok(char *, char *);
void mostWordInString(const char *str) {
  unsigned long len = strlen(str);
  char s[len + 1];
  char *array[len + 1];
  int i = 0, cnt, max = 0, flag = 0;
  strcpy(s, str);
  array[i] = strtok(s, " ");
  while ((array[++i] = strtok(NULL, " ")) != NULL)
    ;
  for (i = 0; array[i] != NULL; i++) {
    cnt = stringOfSubstring(str, array[i]);
    if (cnt > max) {
      max = cnt;
      flag = i;
    }
  }
  printf("%s%d", array[flag], max);
}


x86 assembly (clang, -O0):
<mostWordInString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
add    $0x10,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
lea    0x17(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdfc(%rip),%rsi
call   1060 <strtok@plt>
mov    -0x40(%rbp),%rcx
mov    -0x2c(%rbp),%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %edx,%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
je     122c <mostWordInString+0xdc>
jmp    11f9 <mostWordInString+0xa9>
movl   $0x0,-0x2c(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1289 <mostWordInString+0x139>
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rdi
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <stringOfSubstring@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    1276 <mostWordInString+0x126>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    127b <mostWordInString+0x12b>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1233 <mostWordInString+0xe3>
mov    -0x40(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x34(%rbp),%edx
lea    0xd63(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mostWordInString>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %rsp,%r15
lea    0x10(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
mov    %rsp,%r12
mov    %r12,-0x30(%rbp)
lea    0x17(,%rax,8),%rbx
and    $0xfffffffffffffff0,%rbx
sub    %rbx,%r12
mov    %r12,%rsp
neg    %rbx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe5b(%rip),%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <strtok@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,(%rcx,%rbx,1)
lea    0x8(%r12),%rbx
nopl   (%rax)
xor    %edi,%edi
mov    %r13,%rsi
call   1060 <strtok@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
test   %rax,%rax
jne    11c0 <mostWordInString+0x70>
mov    (%r12),%rsi
test   %rsi,%rsi
je     121a <mostWordInString+0xca>
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <stringOfSubstring@plt>
cmp    %r15d,%eax
cmovg  %eax,%r15d
cmovg  %ebx,%r13d
mov    0x8(%r12,%rbx,8),%rsi
add    $0x1,%rbx
test   %rsi,%rsi
jne    11f0 <mostWordInString+0xa0>
movslq %r13d,%rax
mov    (%r12,%rax,8),%rsi
jmp    121f <mostWordInString+0xcf>
xor    %esi,%esi
xor    %r15d,%r15d
lea    0xddc(%rip),%rdi
mov    %r15d,%edx
call   1050 <printf@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"%s%d\00"
define void @mostWordInString(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %2
%11 = load i8*, i8** %2
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = add i64 %13, 1
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %4
%16 = alloca i8, i64 %14
store i64 %14, i64* %5
%17 = load i64, i64* %3
%18 = add i64 %17, 1
%19 = alloca i8*, i64 %18
store i64 %18, i64* %6
store i32 0, i32* %7
store i32 0, i32* %9
store i32 0, i32* %10
%20 = load i8*, i8** %2
%21 = call i32 @strcpy(i8* %16, i8* %20)
%22 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %19, i64 %24
store i8* %22, i8** %25
br label %26
26: ; preds = %33, %1
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %19, i64 %30
store i8* %27, i8** %31
%32 = icmp ne i8* %27, null
br i1 %32, label %33, label %34
33: ; preds = %26
br label %26
34: ; preds = %26
store i32 0, i32* %7
br label %35
35: ; preds = %55, %34
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %19, i64 %37
%39 = load i8*, i8** %38
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %58
41: ; preds = %35
%42 = load i8*, i8** %2
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %19, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @stringOfSubstring(i8* %42, i8* %46)
store i32 %47, i32* %8
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = icmp sgt i32 %48, %49
br i1 %50, label %51, label %54
51: ; preds = %41
%52 = load i32, i32* %8
store i32 %52, i32* %9
%53 = load i32, i32* %7
store i32 %53, i32* %10
br label %54
54: ; preds = %51, %41
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %35
58: ; preds = %35
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %19, i64 %60
%62 = load i8*, i8** %61
%63 = load i32, i32* %9
%64 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %62, i32 %63)
%65 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"%s%d\00"
define void @mostWordInString(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add i64 %2, 1
%4 = alloca i8, i64 %3
%5 = alloca i8*, i64 %3
%6 = call i32 @strcpy(i8* %4, i8* %0)
%7 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %5
br label %8
8: ; preds = %8, %1
%9 = phi i64 [ %11, %8 ], [ 0, %1 ]
%10 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = add nuw nsw i64 %9, 1
%12 = getelementptr inbounds i8*, i8** %5, i64 %11
store i8* %10, i8** %12
%13 = icmp eq i8* %10, null
br i1 %13, label %14, label %8
14: ; preds = %8
%15 = load i8*, i8** %5
%16 = icmp eq i8* %15, null
br i1 %16, label %35, label %17
17: ; preds = %14, %17
%18 = phi i64 [ %27, %17 ], [ 0, %14 ]
%19 = phi i8* [ %29, %17 ], [ %15, %14 ]
%20 = phi i32 [ %26, %17 ], [ 0, %14 ]
%21 = phi i32 [ %24, %17 ], [ 0, %14 ]
%22 = call i32 @stringOfSubstring(i8* %0, i8* %19)
%23 = icmp sgt i32 %22, %21
%24 = select i1 %23, i32 %22, i32 %21
%25 = trunc i64 %18 to i32
%26 = select i1 %23, i32 %25, i32 %20
%27 = add nuw i64 %18, 1
%28 = getelementptr inbounds i8*, i8** %5, i64 %27
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %17
31: ; preds = %17
%32 = sext i32 %26 to i64
%33 = getelementptr inbounds i8*, i8** %5, i64 %32
%34 = load i8*, i8** %33
br label %35
35: ; preds = %14, %31
%36 = phi i8* [ %34, %31 ], [ null, %14 ]
%37 = phi i32 [ %24, %31 ], [ 0, %14 ]
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %36, i32 %37)
ret void
}