#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_last_2(char *s) {
  char field_name[128], data[128];
  int number_pieces, i;
  number_pieces = number_occurrences_char('|', s) + 1;
  for (i = number_pieces - 2; 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_last_2>:
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)
mov    -0x114(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x114(%rbp),%eax
jge    11de <output_last_2+0xae>
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    0xe3b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x118(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x118(%rbp)
jmp    1165 <output_last_2+0x35>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_last_2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r15
mov    $0x7c,%edi
mov    %r15,%rsi
call   1040 <number_occurrences_char@plt>
mov    %eax,%r14d
lea    -0x1(%r14),%ebx
lea    0x80(%rsp),%r12
mov    %rsp,%r13
lea    0xe96(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x7c,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1050 <piece@plt>
lea    0x1(%rbx),%ecx
mov    %r13,%rdi
mov    $0x7c,%esi
mov    %r15,%rdx
call   1050 <piece@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <printf@plt>
add    $0x2,%ebx
cmp    %r14d,%ebx
jle    1170 <output_last_2+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_last_2(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
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 2
store i32 %11, i32* %6
br label %12
12: ; preds = %29, %1
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %32
16: ; preds = %12
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = load i32, i32* %6
%20 = call i32 @piece(i8* %17, i8 signext 124, i8* %18, i32 %19)
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%22 = load i8*, i8** %2
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
%25 = call i32 @piece(i8* %21, i8 signext 124, i8* %22, i32 %24)
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
br label %29
29: ; preds = %16
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 2
store i32 %31, i32* %6
br label %12
32: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s|%s\0A\00"
define void @output_last_2(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 = add nsw i32 %6, -1
br label %8
8: ; preds = %1, %8
%9 = phi i32 [ %7, %1 ], [ %14, %8 ]
%10 = call i32 @piece(i8* %4, i8 signext 124, i8* %0, i32 %9)
%11 = add nsw 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 nsw i32 %9, 2
%15 = icmp sgt i32 %14, %6
br i1 %15, label %16, label %8
16: ; preds = %8
ret void
}