#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 */
scalar_t__ count_characters(char, char *);
int /*<<< orphan*/ piece(char *, char, char *, scalar_t__);
int /*<<< orphan*/ piece_delete(char *, char, scalar_t__);
int /*<<< orphan*/ piece_insert(char *, char, char *, int /*<<< orphan*/);
char *piece_shift_right(char *source_destination, char delimiter) {
  char data[2048];
  piece(data, delimiter, source_destination,
        count_characters(delimiter, source_destination));
  piece_insert(source_destination, delimiter, data, 0);
  piece_delete(source_destination, delimiter,
               count_characters(delimiter, source_destination) + 1);
  return source_destination;
}


x86 assembly (clang, -O0):
<piece_shift_right>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x838(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x821(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1060 <count_characters@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rdx
mov    %rax,%rcx
mov    -0x821(%rbp),%al
movsbl %al,%esi
call   1050 <piece@plt>
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
lea    -0x810(%rbp),%rdx
xor    %ecx,%ecx
movsbl %al,%esi
call   1040 <piece_insert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x820(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x811(%rbp)
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1060 <count_characters@plt>
mov    -0x820(%rbp),%rdi
mov    %rax,%rdx
mov    -0x811(%rbp),%al
add    $0x1,%rdx
movsbl %al,%esi
call   1030 <piece_delete@plt>
mov    -0x8(%rbp),%rax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piece_shift_right>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
mov    %rbx,%rsi
call   1060 <count_characters@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1050 <piece@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <piece_insert@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <count_characters@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <piece_delete@plt>
mov    %rbx,%rax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @piece_shift_right(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca [2048 x i8]
store i8* %0, i8** %3
store i8 %1, i8* %4
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%7 = load i8, i8* %4
%8 = load i8*, i8** %3
%9 = load i8, i8* %4
%10 = load i8*, i8** %3
%11 = call i64 @count_characters(i8 signext %9, i8* %10)
%12 = call i32 @piece(i8* %6, i8 signext %7, i8* %8, i64 %11)
%13 = load i8*, i8** %3
%14 = load i8, i8* %4
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%16 = call i32 @piece_insert(i8* %13, i8 signext %14, i8* %15, i32 0)
%17 = load i8*, i8** %3
%18 = load i8, i8* %4
%19 = load i8, i8* %4
%20 = load i8*, i8** %3
%21 = call i64 @count_characters(i8 signext %19, i8* %20)
%22 = add nsw i64 %21, 1
%23 = call i32 @piece_delete(i8* %17, i8 signext %18, i64 %22)
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
define i8* @piece_shift_right(i8* returned %0, i8 signext %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @count_characters(i8 signext %1, i8* %0)
%6 = call i32 @piece(i8* %4, i8 signext %1, i8* %0, i64 %5)
%7 = call i32 @piece_insert(i8* %0, i8 signext %1, i8* %4, i32 0)
%8 = call i64 @count_characters(i8 signext %1, i8* %0)
%9 = add nsw i64 %8, 1
%10 = call i32 @piece_delete(i8* %0, i8 signext %1, i64 %9)
ret i8* %0
}