#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 *strchr(char *, char);
int main(void) {
  int i;
  int len;
  char *p;
  char *q;
  char a[100] = {};
  char str[100] = "cang|95588|12345|";
  p = str;
  while (*p != 0) {
    q = strchr(p, '|');
    len = q - p;
    for (i = 0; i < len; i++)
      printf("%c", p[i]);
    printf("\n");
    p = q + 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x100(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1212 <main+0xd2>
mov    -0x18(%rbp),%rdi
mov    $0x7c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f3 <main+0xb3>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bf <main+0x7f>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1188 <main+0x48>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsp,%rbx
movaps 0xf1a(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xefe(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x63,%r15b
jmp    11aa <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rbx
add    $0x1,%rbx
mov    0x1(%r14),%r15b
test   %r15b,%r15b
je     11f4 <main+0xd4>
mov    %rbx,%rdi
mov    $0x7c,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
sub    %rbx,%rax
test   %eax,%eax
jle    1190 <main+0x70>
mov    %eax,%r12d
movsbl %r15b,%edi
call   1030 <putchar@plt>
cmp    $0x1,%r12
je     1190 <main+0x70>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11e0 <main+0xc0>
jmp    1190 <main+0x70>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str = [100 x i8] c"cang|95588|12345|\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
store i32 0, i32* %1
%8 = bitcast [100 x i8]* %6 to i8*
%9 = bitcast [100 x i8]* %7 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
store i8* %10, i8** %4
br label %11
11: ; preds = %40, %0
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %44
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = call i8* @strchr(i8* %17, i8 signext 124)
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = load i8*, i8** %4
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %3
store i32 0, i32* %2
br label %25
25: ; preds = %37, %16
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %2
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %25
40: ; preds = %25
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i64 1
store i8* %43, i8** %4
br label %11
44: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [100 x i8] c"cang|95588|12345|\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %25
%4 = phi i8 [ %28, %25 ], [ 99, %0 ]
%5 = phi i8* [ %27, %25 ], [ %2, %0 ]
%6 = call i8* @strchr(i8* %5, i8 signext 124)
%7 = ptrtoint i8* %6 to i64
%8 = ptrtoint i8* %5 to i64
%9 = sub i64 %7, %8
%10 = trunc i64 %9 to i32
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %3
%13 = and i64 %9, 4294967295
%14 = sext i8 %4 to i32
%15 = call i32 @putchar(i32 %14)
%16 = icmp eq i64 %13, 1
br i1 %16, label %25, label %17
17: ; preds = %12, %17
%18 = phi i64 [ %23, %17 ], [ 1, %12 ]
%19 = getelementptr inbounds i8, i8* %5, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 @putchar(i32 %21)
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, %13
br i1 %24, label %25, label %17
25: ; preds = %17, %12, %3
%26 = call i32 @putchar(i32 10)
%27 = getelementptr inbounds i8, i8* %6, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %3
30: ; preds = %25
ret i32 0
}