#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 number_occurrences_char(char, char *);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
void output_all(char *s) {
  char field_name[128], data[128];
  int number_pieces, i;
  number_pieces = number_occurrences_char('|', s) + 1;
  for (i = 0; i < number_pieces; i += 2) {
    piece(field_name, '|', s, i);
    piece(data, '|', s, i + 1);
    printf("%s|%s\n", field_name, data);
  }
}


x86 assembly (clang, -O0):
<output_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x7c,%edi
call   1040 <number_occurrences_char@plt>
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x114(%rbp),%eax
jge    11d9 <output_all+0xa9>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x118(%rbp),%ecx
mov    $0x7c,%esi
call   1050 <piece@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x118(%rbp),%ecx
add    $0x1,%ecx
mov    $0x7c,%esi
call   1050 <piece@plt>
lea    -0x90(%rbp),%rsi
lea    -0x110(%rbp),%rdx
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    -0x118(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x118(%rbp)
jmp    1160 <output_all+0x30>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_all>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
mov    $0x7c,%edi
mov    %rbx,%rsi
call   1040 <number_occurrences_char@plt>
test   %eax,%eax
js     11ab <output_all+0x7b>
mov    %eax,%r14d
xor    %ebp,%ebp
lea    0x80(%rsp),%r15
mov    %rsp,%r12
lea    0xe94(%rip),%r13
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x7c,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1050 <piece@plt>
lea    0x1(%rbp),%ecx
mov    %r12,%rdi
mov    $0x7c,%esi
mov    %rbx,%rdx
call   1050 <piece@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <printf@plt>
add    $0x2,%ebp
cmp    %r14d,%ebp
jle    1170 <output_all+0x40>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s|%s\0A\00"
define void @output_all(i8* %0) {
%2 = alloca i8*
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @number_occurrences_char(i8 signext 124, i8* %7)
%9 = add nsw i32 %8, 1
store i32 %9, i32* %5
store i32 0, i32* %6
br label %10
10: ; preds = %27, %1
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = load i32, i32* %6
%18 = call i32 @piece(i8* %15, i8 signext 124, i8* %16, i32 %17)
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%20 = load i8*, i8** %2
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
%23 = call i32 @piece(i8* %19, i8 signext 124, i8* %20, i32 %22)
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25)
br label %27
27: ; preds = %14
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 2
store i32 %29, i32* %6
br label %10
30: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s|%s\0A\00"
define void @output_all(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @number_occurrences_char(i8 signext 124, i8* %0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %1, %8
%9 = phi i32 [ %14, %8 ], [ 0, %1 ]
%10 = call i32 @piece(i8* %4, i8 signext 124, i8* %0, i32 %9)
%11 = or i32 %9, 1
%12 = call i32 @piece(i8* %5, i8 signext 124, i8* %0, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
%14 = add nuw nsw i32 %9, 2
%15 = icmp sgt i32 %14, %6
br i1 %15, label %16, label %8
16: ; preds = %8, %1
ret void
}