#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__ isalnum(char);
char *readword(char *to, char *from) {
  for (; *from != '\0' && isalnum(*from);)
    *to++ = *from++;
  *to = '\0';
  for (; *from != '\0' && !isalnum(*from);)
    from++;
  return from;
}


x86 assembly (clang, -O0):
<readword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     114b <readword+0x3b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    115b <readword+0x4b>
jmp    1182 <readword+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1120 <readword+0x10>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
je     11b6 <readword+0xa6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11c6 <readword+0xb6>
jmp    11d7 <readword+0xc7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1189 <readword+0x79>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readword>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rsi),%al
test   %al,%al
je     115a <readword+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     115a <readword+0x4a>
lea    0x1(%r15),%rbx
movzbl (%r15),%eax
mov    %al,(%r14)
add    $0x1,%r14
movzbl 0x1(%r15),%eax
mov    %rbx,%r15
test   %al,%al
jne    1130 <readword+0x20>
jmp    115d <readword+0x4d>
mov    %r15,%rbx
movb   $0x0,(%r14)
mov    (%rbx),%al
test   %al,%al
je     1189 <readword+0x79>
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1189 <readword+0x79>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <readword+0x60>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @readword(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %17, %2
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = call i64 @isalnum(i8 signext %12)
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
%20 = load i8, i8* %18
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 %20, i8* %21
br label %5
23: ; preds = %15
%24 = load i8*, i8** %3
store i8 0, i8* %24
br label %25
25: ; preds = %38, %23
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = call i64 @isalnum(i8 signext %32)
%34 = icmp ne i64 %33, 0
%35 = xor i1 %34, true
br label %36
36: ; preds = %30, %25
%37 = phi i1 [ false, %25 ], [ %35, %30 ]
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
br label %25
41: ; preds = %36
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
define i8* @readword(i8* nocapture writeonly %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %11
%6 = phi i8 [ %15, %11 ], [ %3, %2 ]
%7 = phi i8* [ %12, %11 ], [ %1, %2 ]
%8 = phi i8* [ %14, %11 ], [ %0, %2 ]
%9 = tail call i64 @isalnum(i8 signext %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %7
%14 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %13, i8* %8
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %11, %2
%18 = phi i8* [ %0, %2 ], [ %14, %11 ], [ %8, %5 ]
%19 = phi i8* [ %1, %2 ], [ %12, %11 ], [ %7, %5 ]
store i8 0, i8* %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %17, %27
%23 = phi i8 [ %29, %27 ], [ %20, %17 ]
%24 = phi i8* [ %28, %27 ], [ %19, %17 ]
%25 = tail call i64 @isalnum(i8 signext %23)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = getelementptr inbounds i8, i8* %24, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %22
31: ; preds = %22, %27, %17
%32 = phi i8* [ %19, %17 ], [ %28, %27 ], [ %24, %22 ]
ret i8* %32
}