#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 */
int /*<<< orphan*/ isalnum(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ memmove(char *, char *, int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t const);
char *strtok(char *, char *);
char *robj(char *buf, const size_t mxl) {
  char *tbuf;
  tbuf = strtok(buf, ":");
  tbuf = strtok(NULL, "\n");
  if (!tbuf) {
    strncpy(buf, "UNKNOWN", mxl);
  } else {
    int p = strlen(tbuf);
    if (isspace(tbuf[0]))
      memmove(tbuf, tbuf + 1, p--);
    while (!isalnum(tbuf[p]))
      tbuf[p--] = '\0';
    strncpy(buf, tbuf, mxl);
  }
  return buf;
}


x86 assembly (clang, -O0):
<robj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe73(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11bc <robj+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe52(%rip),%rsi
call   1030 <strncpy@plt>
jmp    1251 <robj+0xf1>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     11fa <robj+0x9a>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    -0x1c(%rbp),%edx
mov    %edx,%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
call   1070 <memmove@plt>
jmp    11ff <robj+0x9f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1225 <robj+0xc5>
jmp    1240 <robj+0xe0>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11ff <robj+0x9f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<robj>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe8b(%rip),%rsi
call   1080 <strtok@plt>
lea    0xe81(%rip),%rsi
xor    %edi,%edi
call   1080 <strtok@plt>
test   %rax,%rax
je     11fc <robj+0x9c>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
movsbl 0x0(%rbp),%edi
call   1060 <isspace@plt>
test   %rax,%rax
je     11c0 <robj+0x60>
lea    0x1(%rbp),%rsi
mov    %ebx,%r12d
add    $0xffffffff,%r12d
mov    %rbp,%rdi
mov    %ebx,%edx
call   1070 <memmove@plt>
mov    %r12d,%ebx
movslq %ebx,%r12
movsbl 0x0(%rbp,%r12,1),%edi
call   1050 <isalnum@plt>
test   %eax,%eax
jne    11f4 <robj+0x94>
mov    %rbp,%rbx
add    %r12,%rbx
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1050 <isalnum@plt>
test   %eax,%eax
je     11e0 <robj+0x80>
mov    %r15,%rdi
mov    %rbp,%rsi
jmp    1206 <robj+0xa6>
lea    0xe01(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1030 <strncpy@plt>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"UNKNOWN\00"
define i8* @robj(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
%9 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = load i64, i64* %4
%15 = call i32 @strncpy(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %14)
br label %52
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %6
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = call i64 @isspace(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %16
%25 = load i8*, i8** %5
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
%30 = call i32 @memmove(i8* %25, i8* %27, i32 %28)
br label %31
31: ; preds = %24, %16
br label %32
32: ; preds = %41, %31
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @isalnum(i8 signext %37)
%39 = icmp ne i32 %38, 0
%40 = xor i1 %39, true
br i1 %40, label %41, label %47
41: ; preds = %32
%42 = load i8*, i8** %5
%43 = load i32, i32* %6
%44 = add nsw i32 %43, -1
store i32 %44, i32* %6
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %42, i64 %45
store i8 0, i8* %46
br label %32
47: ; preds = %32
%48 = load i8*, i8** %3
%49 = load i8*, i8** %5
%50 = load i64, i64* %4
%51 = call i32 @strncpy(i8* %48, i8* %49, i64 %50)
br label %52
52: ; preds = %47, %12
%53 = load i8*, i8** %3
ret i8* %53
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"UNKNOWN\00"
define i8* @robj(i8* returned %0, i64 %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @strncpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %1)
br label %34
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %4)
%10 = load i8, i8* %4
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %4, i64 1
%15 = add nsw i32 %9, -1
%16 = tail call i32 @memmove(i8* %4, i8* %14, i32 %9)
br label %17
17: ; preds = %13, %8
%18 = phi i32 [ %15, %13 ], [ %9, %8 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %4, i64 %19
%21 = load i8, i8* %20
%22 = tail call i32 @isalnum(i8 signext %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %17, %24
%25 = phi i64 [ %27, %24 ], [ %19, %17 ]
%26 = phi i8* [ %28, %24 ], [ %20, %17 ]
%27 = add i64 %25, -1
store i8 0, i8* %26
%28 = getelementptr inbounds i8, i8* %4, i64 %27
%29 = load i8, i8* %28
%30 = tail call i32 @isalnum(i8 signext %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %24, label %32
32: ; preds = %24, %17
%33 = tail call i32 @strncpy(i8* %0, i8* %4, i64 %1)
br label %34
34: ; preds = %32, %6
ret i8* %0
}