#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 */
struct pplex {
  int dummy;
};

/* Variables and functions */
scalar_t__ isalnum(char const);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
char *nextchar(struct pplex *, char const *);
char const *skipwhite(struct pplex *, char const *);
char const *getidentifier(struct pplex *cl, char const *input, char *buffer) {
  char const *startpos;
  size_t n;
  startpos = input;
  while ((isalnum(*input) || (*input) == '_'))
    input = nextchar(cl, input);
  n = (size_t)(input - startpos);
  memcpy(buffer, startpos, n);
  buffer[n] = '\0';
  return skipwhite(cl, input);
}


x86 assembly (clang, -O0):
<getidentifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
jne    118a <getidentifier+0x4a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    119a <getidentifier+0x5a>
jmp    11b0 <getidentifier+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <nextchar@plt>
mov    %rax,-0x10(%rbp)
jmp    115c <getidentifier+0x1c>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <skipwhite@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getidentifier>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rsi,%rbx
jmp    116e <getidentifier+0x2e>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <nextchar@plt>
mov    %rax,%rbx
movsbl (%rbx),%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1160 <getidentifier+0x20>
cmpb   $0x5f,(%rbx)
je     1160 <getidentifier+0x20>
mov    %rbx,%r13
sub    %r12,%r13
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <memcpy@plt>
movb   $0x0,(%r14,%r13,1)
mov    %r15,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <skipwhite@plt>

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

LLVM IR (-O2):
%struct.pplex = type { i32 }
define i8* @getidentifier(%struct.pplex* %0, i8* %1, i8* %2) {
br label %4
4: ; preds = %12, %3
%5 = phi i8* [ %1, %3 ], [ %13, %12 ]
%6 = load i8, i8* %5
%7 = tail call i64 @isalnum(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 95
br i1 %11, label %12, label %14
12: ; preds = %4, %9
%13 = tail call i8* @nextchar(%struct.pplex* %0, i8* %5)
br label %4
14: ; preds = %9
%15 = ptrtoint i8* %5 to i64
%16 = ptrtoint i8* %1 to i64
%17 = sub i64 %15, %16
%18 = tail call i32 @memcpy(i8* %2, i8* %1, i64 %17)
%19 = getelementptr inbounds i8, i8* %2, i64 %17
store i8 0, i8* %19
%20 = tail call i8* @skipwhite(%struct.pplex* %0, i8* %5)
ret i8* %20
}