#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*/ printf(char *, char *);
void prlongname(char *buf) {
  int savech;
  char *p, *savep;
  for (p = buf; *p && *p != ':'; ++p)
    ;
  savech = *(savep = p);
  for (*p = '\0'; p >= buf && *p != '|'; --p)
    ;
  (void)printf("%s\n", p + 1);
  *savep = savech;
}


x86 assembly (clang, -O0):
<prlongname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1149 <prlongname+0x39>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1159 <prlongname+0x49>
jmp    116f <prlongname+0x5f>
jmp    115e <prlongname+0x4e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <prlongname+0x14>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x22(%rbp)
jb     11a7 <prlongname+0x97>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    11b7 <prlongname+0xa7>
jmp    11cd <prlongname+0xbd>
jmp    11bc <prlongname+0xac>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1184 <prlongname+0x74>
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prlongname>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
movzbl (%r14),%ebx
test   %bl,%bl
je     1133 <prlongname+0x23>
cmp    $0x3a,%bl
je     1133 <prlongname+0x23>
add    $0x1,%r14
jmp    1120 <prlongname+0x10>
movb   $0x0,(%r14)
mov    %r14,%rsi
cmp    %rdi,%r14
jb     1161 <prlongname+0x51>
lea    -0x1(%r14),%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rsi
cmp    %rdi,%rax
jb     1161 <prlongname+0x51>
lea    -0x1(%rsi),%rax
cmpb   $0x7c,(%rsi)
jne    1150 <prlongname+0x40>
add    $0x1,%rsi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    %bl,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @prlongname(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %20, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 58
br label %17
17: ; preds = %12, %7
%18 = phi i1 [ false, %7 ], [ %16, %12 ]
br i1 %18, label %19, label %23
19: ; preds = %17
br label %20
20: ; preds = %19
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
br label %7
23: ; preds = %17
%24 = load i8*, i8** %4
store i8* %24, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
store i32 %26, i32* %3
%27 = load i8*, i8** %4
store i8 0, i8* %27
br label %28
28: ; preds = %40, %23
%29 = load i8*, i8** %4
%30 = load i8*, i8** %2
%31 = icmp uge i8* %29, %30
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 124
br label %37
37: ; preds = %32, %28
%38 = phi i1 [ false, %28 ], [ %36, %32 ]
br i1 %38, label %39, label %43
39: ; preds = %37
br label %40
40: ; preds = %39
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i32 -1
store i8* %42, i8** %4
br label %28
43: ; preds = %37
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %45)
%47 = load i32, i32* %3
%48 = trunc i32 %47 to i8
%49 = load i8*, i8** %5
store i8 %48, i8* %49
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @prlongname(i8* %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %7
i8 58, label %7
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2, %2
store i8 0, i8* %3
%8 = icmp ult i8* %3, %0
br i1 %8, label %16, label %9
9: ; preds = %7, %13
%10 = phi i8* [ %11, %13 ], [ %3, %7 ]
%11 = getelementptr inbounds i8, i8* %10, i64 -1
%12 = icmp ult i8* %11, %0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 124
br i1 %15, label %16, label %9
16: ; preds = %13, %9, %7
%17 = phi i8* [ %3, %7 ], [ %11, %9 ], [ %11, %13 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
store i8 %4, i8* %3
ret void
}