#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__ isalpha(char);
scalar_t__ isspace(char);
char *strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strend(char *);
char *strrchr(char *, char);
int /*<<< orphan*/ strstrip(char *);
int /*<<< orphan*/ strupper(int /*<<< orphan*/);
char *get_username(char *userid) {
  char s[256];
  char *p = userid;
  while (isalpha(*p) || isspace(*p) || *p == '.' || *p == '-')
    p++;
  if (p > userid)
    *p = '\0';
  strupper(strstrip(userid));
  if (*userid == '<') {
    strcpy(userid, userid + 1);
  }
  p = strend(userid);
  if (!strcmp(p - 2, " I"))
    *(p - 2) = '\0';
  if (!strcmp(p - 3, " II"))
    *(p - 3) = '\0';
  if (!strcmp(p - 4, " III"))
    *(p - 4) = '\0';
  if (!strcmp(p - 4, " JR."))
    *(p - 4) = '\0';
  if (!strcmp(p - 5, " M.D."))
    *(p - 5) = '\0';
  if ((p = strrchr(userid, ' ')) != NULL) {
    strcpy(s, p + 1);
    *p = '\0';
    strcpy(userid, strcat(s, userid));
  }
  return userid;
}


x86 assembly (clang, -O0):
<get_username>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isalpha@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x119(%rbp)
jne    1223 <get_username+0x93>
mov    -0x118(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x119(%rbp)
jne    1223 <get_username+0x93>
mov    -0x118(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x119(%rbp)
je     1223 <get_username+0x93>
mov    -0x118(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    1236 <get_username+0xa6>
jmp    124d <get_username+0xbd>
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    11aa <get_username+0x1a>
mov    -0x118(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1268 <get_username+0xd8>
mov    -0x118(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1070 <strstrip@plt>
mov    %eax,%edi
call   1080 <strupper@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    1299 <get_username+0x109>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <strend@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xd45(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12d4 <get_username+0x144>
mov    -0x118(%rbp),%rax
movb   $0x0,-0x2(%rax)
mov    -0x118(%rbp),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xd1d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12ff <get_username+0x16f>
mov    -0x118(%rbp),%rax
movb   $0x0,-0x3(%rax)
mov    -0x118(%rbp),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xcf6(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    132a <get_username+0x19a>
mov    -0x118(%rbp),%rax
movb   $0x0,-0x4(%rax)
mov    -0x118(%rbp),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xcd0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1355 <get_username+0x1c5>
mov    -0x118(%rbp),%rax
movb   $0x0,-0x4(%rax)
mov    -0x118(%rbp),%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xcaa(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1380 <get_username+0x1f0>
mov    -0x118(%rbp),%rax
movb   $0x0,-0x5(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
je     13ea <get_username+0x25a>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x118(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x128(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_username>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
mov    %rdi,%rbx
jmp    11b4 <get_username+0x24>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
movsbl (%rbx),%edi
call   1090 <isalpha@plt>
test   %rax,%rax
jne    11b0 <get_username+0x20>
movsbl (%rbx),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    11b0 <get_username+0x20>
movzbl (%rbx),%eax
add    $0xd3,%al
cmp    $0x1,%al
jbe    11b0 <get_username+0x20>
cmp    %r14,%rbx
jbe    11df <get_username+0x4f>
movb   $0x0,(%rbx)
mov    %r14,%rdi
call   1070 <strstrip@plt>
mov    %eax,%edi
call   1080 <strupper@plt>
cmpb   $0x3c,(%r14)
jne    1200 <get_username+0x70>
lea    0x1(%r14),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   10a0 <strend@plt>
mov    %rax,%rbx
lea    -0x2(%rax),%r15
lea    0xdea(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1226 <get_username+0x96>
movb   $0x0,(%r15)
lea    -0x3(%rbx),%r15
lea    0xdd2(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1241 <get_username+0xb1>
movb   $0x0,(%r15)
lea    -0x4(%rbx),%r15
lea    0xdbb(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    125c <get_username+0xcc>
movb   $0x0,(%r15)
lea    0xda9(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1273 <get_username+0xe3>
movb   $0x0,(%r15)
add    $0xfffffffffffffffb,%rbx
lea    0xd93(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    128d <get_username+0xfd>
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    $0x20,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     12cd <get_username+0x13d>
mov    %rax,%rbx
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
movb   $0x0,(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c" I\00"
@.str.1 = [4 x i8] c" II\00"
@.str.2 = [5 x i8] c" III\00"
@.str.3 = [5 x i8] c" JR.\00"
@.str.4 = [6 x i8] c" M.D.\00"
define i8* @get_username(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %4
br label %6
6: ; preds = %28, %1
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = call i64 @isalpha(i8 signext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = call i64 @isspace(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 46
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 45
br label %26
26: ; preds = %21, %16, %11, %6
%27 = phi i1 [ true, %16 ], [ true, %11 ], [ true, %6 ], [ %25, %21 ]
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
br label %6
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = load i8*, i8** %2
%34 = icmp ugt i8* %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i8*, i8** %4
store i8 0, i8* %36
br label %37
37: ; preds = %35, %31
%38 = load i8*, i8** %2
%39 = call i32 @strstrip(i8* %38)
%40 = call i32 @strupper(i32 %39)
%41 = load i8*, i8** %2
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 60
br i1 %44, label %45, label %50
45: ; preds = %37
%46 = load i8*, i8** %2
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = call i32 @strcpy(i8* %46, i8* %48)
br label %50
50: ; preds = %45, %37
%51 = load i8*, i8** %2
%52 = call i8* @strend(i8* %51)
store i8* %52, i8** %4
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 -2
%55 = call i32 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %60, label %57
57: ; preds = %50
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 -2
store i8 0, i8* %59
br label %60
60: ; preds = %57, %50
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 -3
%63 = call i32 @strcmp(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp ne i32 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i64 -3
store i8 0, i8* %67
br label %68
68: ; preds = %65, %60
%69 = load i8*, i8** %4
%70 = getelementptr inbounds i8, i8* %69, i64 -4
%71 = call i32 @strcmp(i8* %70, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%72 = icmp ne i32 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %68
%74 = load i8*, i8** %4
%75 = getelementptr inbounds i8, i8* %74, i64 -4
store i8 0, i8* %75
br label %76
76: ; preds = %73, %68
%77 = load i8*, i8** %4
%78 = getelementptr inbounds i8, i8* %77, i64 -4
%79 = call i32 @strcmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
br i1 %80, label %84, label %81
81: ; preds = %76
%82 = load i8*, i8** %4
%83 = getelementptr inbounds i8, i8* %82, i64 -4
store i8 0, i8* %83
br label %84
84: ; preds = %81, %76
%85 = load i8*, i8** %4
%86 = getelementptr inbounds i8, i8* %85, i64 -5
%87 = call i32 @strcmp(i8* %86, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%88 = icmp ne i32 %87, 0
br i1 %88, label %92, label %89
89: ; preds = %84
%90 = load i8*, i8** %4
%91 = getelementptr inbounds i8, i8* %90, i64 -5
store i8 0, i8* %91
br label %92
92: ; preds = %89, %84
%93 = load i8*, i8** %2
%94 = call i8* @strrchr(i8* %93, i8 signext 32)
store i8* %94, i8** %4
%95 = icmp ne i8* %94, null
br i1 %95, label %96, label %107
96: ; preds = %92
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%98 = load i8*, i8** %4
%99 = getelementptr inbounds i8, i8* %98, i64 1
%100 = call i32 @strcpy(i8* %97, i8* %99)
%101 = load i8*, i8** %4
store i8 0, i8* %101
%102 = load i8*, i8** %2
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%104 = load i8*, i8** %2
%105 = call i8* @strcat(i8* %103, i8* %104)
%106 = call i32 @strcpy(i8* %102, i8* %105)
br label %107
107: ; preds = %96, %92
%108 = load i8*, i8** %2
ret i8* %108
}

LLVM IR (-O2):
@.str = [3 x i8] c" I\00"
@.str.1 = [4 x i8] c" II\00"
@.str.2 = [5 x i8] c" III\00"
@.str.3 = [5 x i8] c" JR.\00"
@.str.4 = [6 x i8] c" M.D.\00"
define i8* @get_username(i8* returned %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %17, %1
%5 = phi i8* [ %0, %1 ], [ %18, %17 ]
%6 = load i8, i8* %5
%7 = tail call i64 @isalpha(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = load i8, i8* %5
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8, i8* %5
%15 = add i8 %14, -45
%16 = icmp ult i8 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %13, %4, %9
%18 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
19: ; preds = %13
%20 = icmp ugt i8* %5, %0
br i1 %20, label %21, label %22
21: ; preds = %19
store i8 0, i8* %5
br label %22
22: ; preds = %21, %19
%23 = tail call i32 @strstrip(i8* %0)
%24 = tail call i32 @strupper(i32 %23)
%25 = load i8, i8* %0
%26 = icmp eq i8 %25, 60
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = getelementptr inbounds i8, i8* %0, i64 1
%29 = tail call i32 @strcpy(i8* %0, i8* %28)
br label %30
30: ; preds = %27, %22
%31 = tail call i8* @strend(i8* %0)
%32 = getelementptr inbounds i8, i8* %31, i64 -2
%33 = tail call i32 @strcmp(i8* %32, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i8 0, i8* %32
br label %36
36: ; preds = %35, %30
%37 = getelementptr inbounds i8, i8* %31, i64 -3
%38 = tail call i32 @strcmp(i8* %37, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i8 0, i8* %37
br label %41
41: ; preds = %40, %36
%42 = getelementptr inbounds i8, i8* %31, i64 -4
%43 = tail call i32 @strcmp(i8* %42, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
store i8 0, i8* %42
br label %46
46: ; preds = %45, %41
%47 = tail call i32 @strcmp(i8* %42, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
store i8 0, i8* %42
br label %50
50: ; preds = %49, %46
%51 = getelementptr inbounds i8, i8* %31, i64 -5
%52 = tail call i32 @strcmp(i8* %51, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i8 0, i8* %51
br label %55
55: ; preds = %54, %50
%56 = tail call i8* @strrchr(i8* %0, i8 signext 32)
%57 = icmp eq i8* %56, null
br i1 %57, label %63, label %58
58: ; preds = %55
%59 = getelementptr inbounds i8, i8* %56, i64 1
%60 = call i32 @strcpy(i8* %3, i8* %59)
store i8 0, i8* %56
%61 = call i8* @strcat(i8* %3, i8* %0)
%62 = call i32 @strcpy(i8* %0, i8* %3)
br label %63
63: ; preds = %58, %55
ret i8* %0
}