#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__ isdigit(char);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *fullname(char *gecos) {
  static char fname[512];
  register char *cend;
  (void)strcpy(fname, gecos);
  if (cend = strchr(fname, ','))
    *cend = '\0';
  if (cend = strchr(fname, '('))
    *cend = '\0';
  if (isdigit(*(cend = fname))) {
    if ((cend = strchr(fname, '-')) != 0)
      cend++;
    else
      cend = fname;
  }
  return (cend);
}


x86 assembly (clang, -O0):
<fullname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f09(%rip),%rdi
call   1040 <strcpy@plt>
lea    0x2efd(%rip),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1172 <fullname+0x42>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ed7(%rip),%rdi
mov    $0x28,%esi
call   1050 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1198 <fullname+0x68>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2eb1(%rip),%rax
mov    %rax,-0x10(%rbp)
movsbl 0x2ea6(%rip),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11f9 <fullname+0xc9>
lea    0x2e90(%rip),%rdi
mov    $0x2d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11e9 <fullname+0xb9>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f4 <fullname+0xc4>
lea    0x2e60(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11f9 <fullname+0xc9>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fullname>:
push   %rbx
mov    %rdi,%rsi
lea    0x2f15(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1158 <fullname+0x28>
movb   $0x0,(%rax)
lea    0x2ef1(%rip),%rbx
mov    %rbx,%rdi
mov    $0x28,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1174 <fullname+0x44>
movb   $0x0,(%rax)
movsbl 0x2ed5(%rip),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11a5 <fullname+0x75>
lea    0x2ec4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11a5 <fullname+0x75>
add    $0x1,%rax
mov    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@fullname.fname = internal global [512 x i8] zeroinitializer
define i8* @fullname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strcpy(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8* %4)
%6 = call i8* @strchr(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8 signext 44)
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i8*, i8** %3
store i8 0, i8* %9
br label %10
10: ; preds = %8, %1
%11 = call i8* @strchr(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8 signext 40)
store i8* %11, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = load i8*, i8** %3
store i8 0, i8* %14
br label %15
15: ; preds = %13, %10
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8** %3
%16 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0)
%17 = call i64 @isdigit(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = call i8* @strchr(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8 signext 45)
store i8* %20, i8** %3
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
br label %26
25: ; preds = %19
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8** %3
br label %26
26: ; preds = %25, %22
br label %27
27: ; preds = %26, %15
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@fullname.fname = internal global [512 x i8] zeroinitializer
define i8* @fullname(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8* %0)
%3 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8 signext 44)
%4 = icmp eq i8* %3, null
br i1 %4, label %6, label %5
5: ; preds = %1
store i8 0, i8* %3
br label %6
6: ; preds = %5, %1
%7 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8 signext 40)
%8 = icmp eq i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %6
store i8 0, i8* %7
br label %10
10: ; preds = %9, %6
%11 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0)
%12 = tail call i64 @isdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), i8 signext 45)
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %15, i64 1
br label %19
19: ; preds = %14, %17, %10
%20 = phi i8* [ %18, %17 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), %10 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @fullname.fname, i64 0, i64 0), %14 ]
ret i8* %20
}