#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);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, char *);
void test(char *data) {
  char tok[20];
  int i = 0;
  if (isalpha(*data) || *data == '_') {
    while (isalnum(*data) || *data == '_') {
      tok[i] = *data;
      i++;
      data++;
    }
  } else
    data++;
  printf("Token: %s \n", tok);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
jne    1169 <test+0x39>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    11d9 <test+0xa9>
jmp    116e <test+0x3e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x25(%rbp)
jne    119c <test+0x6c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11ac <test+0x7c>
jmp    11d4 <test+0xa4>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    116e <test+0x3e>
jmp    11e5 <test+0xb5>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movsbl (%rdi),%edi
call   1050 <isalpha@plt>
test   %rax,%rax
jne    114d <test+0x1d>
cmpb   $0x5f,(%r14)
jne    1182 <test+0x52>
xor    %ebx,%ebx
jmp    1167 <test+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %cl,(%rsp,%rbx,1)
add    $0x1,%rbx
movsbl (%r14,%rbx,1),%edi
call   1040 <isalnum@plt>
movzbl (%r14,%rbx,1),%ecx
test   %rax,%rax
jne    1160 <test+0x30>
cmp    $0x5f,%cl
mov    $0x5f,%cl
je     1160 <test+0x30>
lea    0xe77(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Token: %s \0A\00"
define void @test(i8* %0) {
%2 = alloca i8*
%3 = alloca [20 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = call i64 @isalpha(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 95
br i1 %13, label %14, label %38
14: ; preds = %9, %1
br label %15
15: ; preds = %27, %14
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = call i64 @isalnum(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 95
br label %25
25: ; preds = %20, %15
%26 = phi i1 [ true, %15 ], [ %24, %20 ]
br i1 %26, label %27, label %37
27: ; preds = %25
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %31
store i8 %29, i8* %32
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
br label %15
37: ; preds = %25
br label %41
38: ; preds = %9
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %2
br label %41
41: ; preds = %38, %37
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %42)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Token: %s \0A\00"
define void @test(i8* nocapture %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = tail call i64 @isalpha(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 95
br i1 %9, label %10, label %25
10: ; preds = %7, %1
br label %11
11: ; preds = %10, %20
%12 = phi i64 [ %23, %20 ], [ 0, %10 ]
%13 = phi i8* [ %24, %20 ], [ %0, %10 ]
%14 = load i8, i8* %13
%15 = tail call i64 @isalnum(i8 signext %14)
%16 = icmp eq i64 %15, 0
%17 = load i8, i8* %13
br i1 %16, label %18, label %20
18: ; preds = %11
%19 = icmp eq i8 %17, 95
br i1 %19, label %20, label %25
20: ; preds = %11, %18
%21 = phi i8 [ 95, %18 ], [ %17, %11 ]
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %12
store i8 %21, i8* %22
%23 = add nuw i64 %12, 1
%24 = getelementptr inbounds i8, i8* %13, i64 1
br label %11
25: ; preds = %18, %7
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}