#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 */
scalar_t__ isspace(char);
char *memmem(char *, int, char *, int);
char *wordfromindex(char *from, char *to, char *index) {
  static char *cp;
  cp = from;
  cp = memmem(from, to - from, index, 5);
  cp += 5;
  while (isspace(*cp))
    cp++;
  return cp;
}


x86 assembly (clang, -O0):
<wordfromindex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,0x2ef9(%rip)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
mov    $0x5,%ecx
call   1040 <memmem@plt>
mov    %rax,0x2ed3(%rip)
mov    0x2ecc(%rip),%rax
add    $0x5,%rax
mov    %rax,0x2ec1(%rip)
mov    0x2eba(%rip),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     11a7 <wordfromindex+0x87>
mov    0x2ea1(%rip),%rax
add    $0x1,%rax
mov    %rax,0x2e96(%rip)
jmp    1177 <wordfromindex+0x57>
mov    0x2e8a(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordfromindex>:
push   %rax
mov    %rdi,0x2f10(%rip)
sub    %edi,%esi
mov    $0x5,%ecx
call   1040 <memmem@plt>
lea    0x5(%rax),%rcx
mov    %rcx,0x2ef9(%rip)
movsbl 0x5(%rax),%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <isspace@plt>
test   %rax,%rax
je     1172 <wordfromindex+0x52>
mov    0x2ed7(%rip),%rax
lea    0x1(%rax),%rcx
mov    %rcx,0x2ecc(%rip)
movsbl 0x1(%rax),%edi
jmp    1150 <wordfromindex+0x30>
mov    0x2ebf(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@wordfromindex.cp = internal global i8* null
define i8* @wordfromindex(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
store i8* %7, i8** @wordfromindex.cp
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = ptrtoint i8* %9 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %11, %12
%14 = trunc i64 %13 to i32
%15 = load i8*, i8** %6
%16 = call i8* @memmem(i8* %8, i32 %14, i8* %15, i32 5)
store i8* %16, i8** @wordfromindex.cp
%17 = load i8*, i8** @wordfromindex.cp
%18 = getelementptr inbounds i8, i8* %17, i64 5
store i8* %18, i8** @wordfromindex.cp
br label %19
19: ; preds = %24, %3
%20 = load i8*, i8** @wordfromindex.cp
%21 = load i8, i8* %20
%22 = call i64 @isspace(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i8*, i8** @wordfromindex.cp
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** @wordfromindex.cp
br label %19
27: ; preds = %19
%28 = load i8*, i8** @wordfromindex.cp
ret i8* %28
}

LLVM IR (-O2):
@wordfromindex.cp = internal unnamed_addr global i8* null
define i8* @wordfromindex(i8* %0, i8* %1, i8* %2) {
store i8* %0, i8** @wordfromindex.cp
%4 = ptrtoint i8* %1 to i64
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 %4, %5
%7 = trunc i64 %6 to i32
%8 = tail call i8* @memmem(i8* %0, i32 %7, i8* %2, i32 5)
%9 = getelementptr inbounds i8, i8* %8, i64 5
store i8* %9, i8** @wordfromindex.cp
%10 = load i8, i8* %9
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %3, %13
%14 = load i8*, i8** @wordfromindex.cp
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** @wordfromindex.cp
%16 = load i8, i8* %15
%17 = tail call i64 @isspace(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %13
19: ; preds = %13, %3
%20 = load i8*, i8** @wordfromindex.cp
ret i8* %20
}