#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*/ isalpha(char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
scalar_t__ xmalloc(int);
char *return_keyword(char *word) {
  size_t size = strlen(word);
  int i;
  printf("\n");
  for (i = 0; i < size; i++) {
    if (!isdigit(word[i]) && !isalpha(word[i]) && word[i] != '_') {
      break;
    }
  }
  char *keyword = (char *)xmalloc(sizeof(char) * i + 1);
  strcpy(keyword, word);
  keyword[i] = '\0';
  return keyword;
}


x86 assembly (clang, -O0):
<return_keyword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe80(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11fb <return_keyword+0x9b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11e8 <return_keyword+0x88>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1080 <isalpha@plt>
cmp    $0x0,%eax
jne    11e8 <return_keyword+0x88>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11e8 <return_keyword+0x88>
jmp    11fb <return_keyword+0x9b>
jmp    11ed <return_keyword+0x8d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <return_keyword+0x2c>
movslq -0x14(%rbp),%rax
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<return_keyword>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1060 <strlen@plt>
mov    %rax,%r15
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
test   %r15,%r15
jne    1199 <return_keyword+0x39>
jmp    11c1 <return_keyword+0x61>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     11be <return_keyword+0x5e>
movsbl (%r14,%rbx,1),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1190 <return_keyword+0x30>
movsbl (%r14,%rbx,1),%edi
call   1080 <isalpha@plt>
test   %eax,%eax
jne    1190 <return_keyword+0x30>
cmpb   $0x5f,(%r14,%rbx,1)
je     1190 <return_keyword+0x30>
jmp    11c1 <return_keyword+0x61>
mov    %r15,%rbx
mov    %ebx,%r15d
add    $0x1,%ebx
mov    %ebx,%edi
call   1070 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
movb   $0x0,(%rbx,%r15,1)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i8* @return_keyword(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %40, %1
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = load i64, i64* %3
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %43
14: ; preds = %9
%15 = load i8*, i8** %2
%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 @isdigit(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %39, label %22
22: ; preds = %14
%23 = load i8*, i8** %2
%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 = call i32 @isalpha(i8 signext %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %22
%31 = load i8*, i8** %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 95
br i1 %37, label %38, label %39
38: ; preds = %30
br label %43
39: ; preds = %30, %22, %14
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %9
43: ; preds = %38, %9
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = mul i64 1, %45
%47 = add i64 %46, 1
%48 = trunc i64 %47 to i32
%49 = call i64 @xmalloc(i32 %48)
%50 = inttoptr i64 %49 to i8*
store i8* %50, i8** %5
%51 = load i8*, i8** %5
%52 = load i8*, i8** %2
%53 = call i32 @strcpy(i8* %51, i8* %52)
%54 = load i8*, i8** %5
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 0, i8* %57
%58 = load i8*, i8** %5
ret i8* %58
}

LLVM IR (-O2):
define i8* @return_keyword(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = tail call i32 @putchar(i32 10)
%4 = icmp eq i64 %2, 0
br i1 %4, label %24, label %5
5: ; preds = %1, %18
%6 = phi i64 [ %19, %18 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i32 @isdigit(i8 signext %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = load i8, i8* %7
%13 = tail call i32 @isalpha(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8, i8* %7
%17 = icmp eq i8 %16, 95
br i1 %17, label %18, label %21
18: ; preds = %5, %11, %15
%19 = add nuw i64 %6, 1
%20 = icmp eq i64 %19, %2
br i1 %20, label %21, label %5
21: ; preds = %15, %18
%22 = phi i64 [ %2, %18 ], [ %6, %15 ]
%23 = trunc i64 %22 to i32
br label %24
24: ; preds = %21, %1
%25 = phi i32 [ 0, %1 ], [ %23, %21 ]
%26 = zext i32 %25 to i64
%27 = add nuw i32 %25, 1
%28 = tail call i64 @xmalloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
%30 = tail call i32 @strcpy(i8* %29, i8* %0)
%31 = getelementptr inbounds i8, i8* %29, i64 %26
store i8 0, i8* %31
ret i8* %29
}