#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 is_alphanumeric(char);
char *malloc(scalar_t__);
scalar_t__ my_word_size(char *);
char *my_get_word(char *str) {
  int i;
  char *output;
  i = 0;
  output = malloc(my_word_size(str) + 1);
  if (output == 0)
    return 0;
  while (is_alphanumeric(str[i]) == 1) {
    output[i] = str[i];
    i++;
  }
  output[i] = 0;
  return output;
}


x86 assembly (clang, -O0):
<my_get_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <my_word_size@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1174 <my_get_word+0x44>
movq   $0x0,-0x8(%rbp)
jmp    11cb <my_get_word+0x9b>
jmp    1179 <my_get_word+0x49>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <is_alphanumeric@plt>
cmp    $0x1,%eax
jne    11b7 <my_get_word+0x87>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <my_get_word+0x49>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_get_word>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1050 <my_word_size@plt>
lea    0x1(%rax),%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     1188 <my_get_word+0x58>
movsbl (%r15),%edi
call   1030 <is_alphanumeric@plt>
cmp    $0x1,%eax
jne    1181 <my_get_word+0x51>
xor    %ebx,%ebx
xchg   %ax,%ax
movzbl (%r15,%rbx,1),%eax
mov    %al,(%r14,%rbx,1)
movsbl 0x1(%r15,%rbx,1),%edi
add    $0x1,%rbx
call   1030 <is_alphanumeric@plt>
cmp    $0x1,%eax
je     1160 <my_get_word+0x30>
mov    %ebx,%eax
jmp    1183 <my_get_word+0x53>
xor    %eax,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define noalias i8* @my_get_word(i8* %0) {
%2 = tail call i64 @my_word_size(i8* %0)
%3 = add nsw i64 %2, 1
%4 = tail call i8* @malloc(i64 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %25, label %6
6: ; preds = %1
%7 = load i8, i8* %0
%8 = tail call i32 @is_alphanumeric(i8 signext %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %22
10: ; preds = %6, %10
%11 = phi i64 [ %15, %10 ], [ 0, %6 ]
%12 = phi i8* [ %16, %10 ], [ %0, %6 ]
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %4, i64 %11
store i8 %13, i8* %14
%15 = add nuw nsw i64 %11, 1
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32 @is_alphanumeric(i8 signext %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %10, label %20
20: ; preds = %10
%21 = and i64 %15, 4294967295
br label %22
22: ; preds = %20, %6
%23 = phi i64 [ 0, %6 ], [ %21, %20 ]
%24 = getelementptr inbounds i8, i8* %4, i64 %23
store i8 0, i8* %24
br label %25
25: ; preds = %1, %22
ret i8* %4
}