#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__ isspace(int /*<<< orphan*/);
char *strdup(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strpbrk(char *, char *);
char *ident_read(char *buf) {
  char *m1, *m2, *ident;
  while (isspace(*buf++))
    ;
  m1 = strpbrk(buf, " \t\n\v\f\r");
  if (!m1)
    return NULL;
  while (isspace(*m1++))
    ;
  m2 = strpbrk(--m1, " \t\n\v\f\r;");
  if (!m2)
    return NULL;
  strncpy(buf, m1, m2 - m1 + 1);
  buf[m2 - m1] = '\0';
  ident = strdup(buf);
  buf[m2 - m1] = ' ';
  return ident;
}


x86 assembly (clang, -O0):
<ident_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1172 <ident_read+0x32>
jmp    114c <ident_read+0xc>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strpbrk@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119e <ident_read+0x5e>
movq   $0x0,-0x8(%rbp)
jmp    1256 <ident_read+0x116>
jmp    11a3 <ident_read+0x63>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11c9 <ident_read+0x89>
jmp    11a3 <ident_read+0x63>
mov    -0x18(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
mov    %rdi,-0x18(%rbp)
lea    0xe2b(%rip),%rsi
call   1050 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11fd <ident_read+0xbd>
movq   $0x0,-0x8(%rbp)
jmp    1256 <ident_read+0x116>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ident_read>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rbx
nopl   0x0(%rax)
movsbl (%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <ident_read+0x10>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strpbrk@plt>
test   %rax,%rax
je     11e7 <ident_read+0xa7>
mov    %rax,%r14
lea    -0x2(%rax),%r13d
mov    %rbx,%r12
sub    %rax,%r12
add    $0xffffffffffffffff,%r14
add    $0x1,%r12
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%r14),%edi
add    $0x1,%r14
call   1040 <isspace@plt>
add    $0x1,%r13
add    $0xffffffffffffffff,%r12
test   %rax,%rax
jne    1190 <ident_read+0x50>
lea    0xe55(%rip),%rsi
mov    %r14,%rdi
call   1050 <strpbrk@plt>
test   %rax,%rax
je     11e7 <ident_read+0xa7>
mov    %rax,%r15
mov    %r15d,%edx
sub    %r13d,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strncpy@plt>
movb   $0x0,(%r12,%r15,1)
mov    %rbx,%rdi
call   1060 <strdup@plt>
movb   $0x20,(%r12,%r15,1)
jmp    11e9 <ident_read+0xa9>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" \09\0A\0B\0C\0D\00"
@.str.1 = [8 x i8] c" \09\0A\0B\0C\0D;\00"
define i8* @ident_read(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
br label %7
7: ; preds = %14, %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = call i64 @isspace(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %7
br label %7
15: ; preds = %7
%16 = load i8*, i8** %3
%17 = call i8* @strpbrk(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %15
store i8* null, i8** %2
br label %65
21: ; preds = %15
br label %22
22: ; preds = %29, %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
%25 = load i8, i8* %23
%26 = sext i8 %25 to i32
%27 = call i64 @isspace(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %22
br label %22
30: ; preds = %22
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %4
%33 = call i8* @strpbrk(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %33, i8** %5
%34 = load i8*, i8** %5
%35 = icmp ne i8* %34, null
br i1 %35, label %37, label %36
36: ; preds = %30
store i8* null, i8** %2
br label %65
37: ; preds = %30
%38 = load i8*, i8** %3
%39 = load i8*, i8** %4
%40 = load i8*, i8** %5
%41 = load i8*, i8** %4
%42 = ptrtoint i8* %40 to i64
%43 = ptrtoint i8* %41 to i64
%44 = sub i64 %42, %43
%45 = add nsw i64 %44, 1
%46 = trunc i64 %45 to i32
%47 = call i32 @strncpy(i8* %38, i8* %39, i32 %46)
%48 = load i8*, i8** %3
%49 = load i8*, i8** %5
%50 = load i8*, i8** %4
%51 = ptrtoint i8* %49 to i64
%52 = ptrtoint i8* %50 to i64
%53 = sub i64 %51, %52
%54 = getelementptr inbounds i8, i8* %48, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %3
%56 = call i8* @strdup(i8* %55)
store i8* %56, i8** %6
%57 = load i8*, i8** %3
%58 = load i8*, i8** %5
%59 = load i8*, i8** %4
%60 = ptrtoint i8* %58 to i64
%61 = ptrtoint i8* %59 to i64
%62 = sub i64 %60, %61
%63 = getelementptr inbounds i8, i8* %57, i64 %62
store i8 32, i8* %63
%64 = load i8*, i8** %6
store i8* %64, i8** %2
br label %65
65: ; preds = %37, %36, %20
%66 = load i8*, i8** %2
ret i8* %66
}

LLVM IR (-O2):
@.str = [7 x i8] c" \09\0A\0B\0C\0D\00"
@.str.1 = [8 x i8] c" \09\0A\0B\0C\0D;\00"
define noalias i8* @ident_read(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %4, %2 ]
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = tail call i64 @isspace(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %2
9: ; preds = %2
%10 = tail call i8* @strpbrk(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %31, label %12
12: ; preds = %9, %12
%13 = phi i8* [ %14, %12 ], [ %10, %9 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = tail call i64 @isspace(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %12
19: ; preds = %12
%20 = tail call i8* @strpbrk(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = ptrtoint i8* %20 to i64
%24 = ptrtoint i8* %13 to i64
%25 = sub i64 %23, %24
%26 = trunc i64 %25 to i32
%27 = add i32 %26, 1
%28 = tail call i32 @strncpy(i8* %4, i8* %13, i32 %27)
%29 = getelementptr inbounds i8, i8* %4, i64 %25
store i8 0, i8* %29
%30 = tail call i8* @strdup(i8* %4)
store i8 32, i8* %29
br label %31
31: ; preds = %19, %9, %22
%32 = phi i8* [ %30, %22 ], [ null, %9 ], [ null, %19 ]
ret i8* %32
}