#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void output_person(FILE *fp, char *name) {
  int n = 0, nchars = 0;
  char *p = name;
  while (*p) {
    if (*p == '|') {
      n++;
      nchars = 0;
    } else {
      if (n == 1 && nchars < 2)
        fprintf(fp, ", ");
      if (n == 0 || (n > 0 && nchars < 2)) {
        fprintf(fp, "%c", *p);
      }
    }
    nchars++;
    p++;
  }
}


x86 assembly (clang, -O0):
<output_person>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e4 <output_person+0xd4>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
jne    1168 <output_person+0x58>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    11ca <output_person+0xba>
cmpl   $0x1,-0x14(%rbp)
jne    118e <output_person+0x7e>
cmpl   $0x2,-0x18(%rbp)
jge    118e <output_person+0x7e>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11ac <output_person+0x9c>
cmpl   $0x0,-0x14(%rbp)
jle    11c5 <output_person+0xb5>
cmpl   $0x2,-0x18(%rbp)
jge    11c5 <output_person+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%edx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ca <output_person+0xba>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1136 <output_person+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_person>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %r12d,%r12d
lea    0xec8(%rip),%r15
xor    %ebp,%ebp
jmp    114d <output_person+0x2d>
nopl   0x0(%rax)
add    $0x1,%r12d
xor    %ebp,%ebp
add    $0x1,%ebp
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x7c,%al
je     1140 <output_person+0x20>
test   %al,%al
je     119f <output_person+0x7f>
cmp    $0x1,%r12d
jne    1180 <output_person+0x60>
cmp    $0x1,%ebp
jg     1180 <output_person+0x60>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
jmp    1185 <output_person+0x65>
nopw   0x0(%rax,%rax,1)
test   %r12d,%r12d
je     1192 <output_person+0x72>
test   %r12d,%r12d
jle    1146 <output_person+0x26>
cmp    $0x1,%ebp
jg     1146 <output_person+0x26>
movzbl (%rbx),%eax
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1146 <output_person+0x26>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c", \00"
define void @output_person(i32* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %27, %2
%4 = phi i32 [ 0, %2 ], [ %28, %27 ]
%5 = phi i32 [ 0, %2 ], [ %30, %27 ]
%6 = phi i8* [ %1, %2 ], [ %31, %27 ]
%7 = load i8, i8* %6
switch i8 %7, label %10 [
i8 0, label %32
i8 124, label %8
]
8: ; preds = %3
%9 = add nsw i32 %4, 1
br label %27
10: ; preds = %3
%11 = icmp eq i32 %4, 1
%12 = icmp slt i32 %5, 2
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %18
16: ; preds = %10
%17 = icmp eq i32 %4, 0
br i1 %17, label %23, label %18
18: ; preds = %14, %16
%19 = icmp sgt i32 %4, 0
%20 = select i1 %19, i1 %12, i1 false
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i8, i8* %6
br label %23
23: ; preds = %21, %16
%24 = phi i8 [ %22, %21 ], [ %7, %16 ]
%25 = sext i8 %24 to i32
%26 = tail call i32 @fputc(i32 %25, i32* %0)
br label %27
27: ; preds = %18, %23, %8
%28 = phi i32 [ %9, %8 ], [ %4, %23 ], [ %4, %18 ]
%29 = phi i32 [ 0, %8 ], [ %5, %23 ], [ %5, %18 ]
%30 = add nsw i32 %29, 1
%31 = getelementptr inbounds i8, i8* %6, i64 1
br label %3
32: ; preds = %3
ret void
}