#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(int);
char *find_name_end(char *ptr) {
  while (*ptr && (isalnum((int)*ptr) || *ptr == '_')) {
    ptr++;
  }
  return ptr;
}


x86 assembly (clang, -O0):
<find_name_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
je     1165 <find_name_end+0x55>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xa(%rbp)
jne    115f <find_name_end+0x4f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1175 <find_name_end+0x65>
jmp    1186 <find_name_end+0x76>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <find_name_end+0xc>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_name_end>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%al
jmp    1128 <find_name_end+0x18>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     113e <find_name_end+0x2e>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1120 <find_name_end+0x10>
cmpb   $0x5f,(%rbx)
je     1120 <find_name_end+0x10>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @find_name_end(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %23, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i64 @isalnum(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %8
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 95
br label %19
19: ; preds = %14, %8
%20 = phi i1 [ true, %8 ], [ %18, %14 ]
br label %21
21: ; preds = %19, %3
%22 = phi i1 [ false, %3 ], [ %20, %19 ]
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %2
br label %3
26: ; preds = %21
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
define i8* @find_name_end(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %15, %13 ], [ %2, %1 ]
%6 = phi i8* [ %14, %13 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
%8 = tail call i64 @isalnum(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, 95
br i1 %12, label %13, label %17
13: ; preds = %4, %10
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %10, %13, %1
%18 = phi i8* [ %0, %1 ], [ %14, %13 ], [ %6, %10 ]
ret i8* %18
}