#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 *);
int /*<<< orphan*/ test_repblock(char *, char, char);
int main(void) {
  printf("\nWorking:\n");
  test_repblock("asdf asdf  asdf   asdf    asdf", ' ', 'y');
  printf("\nFind not in Source\n");
  test_repblock("asdf asdf", 'y', ' ');
  printf("\nSource = End\n");
  test_repblock("asdf          asdf", ' ', ' ');
  printf("\nEmpty Source\n");
  test_repblock(NULL, ' ', ' ');
  printf("\nReplace\n");
  test_repblock("asdf     asdf", ' ', 'y');
  printf("\nTrailing 4\n");
  test_repblock("asdf     asdf    ", ' ', 'y');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x20,%esi
mov    $0x79,%edx
call   1040 <test_repblock@plt>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
mov    $0x79,%esi
mov    $0x20,%edx
call   1040 <test_repblock@plt>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x20,%edx
mov    %edx,%esi
call   1040 <test_repblock@plt>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x20,%edx
mov    %edx,%esi
call   1040 <test_repblock@plt>
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    $0x20,%esi
mov    $0x79,%edx
call   1040 <test_repblock@plt>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    $0x20,%esi
mov    $0x79,%edx
call   1040 <test_repblock@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
mov    $0x20,%esi
mov    $0x79,%edx
call   1040 <test_repblock@plt>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
mov    $0x79,%esi
mov    $0x20,%edx
call   1040 <test_repblock@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
mov    $0x20,%esi
mov    $0x20,%edx
call   1040 <test_repblock@plt>
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
mov    $0x20,%esi
mov    $0x20,%edx
call   1040 <test_repblock@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%rdi
mov    $0x20,%esi
mov    $0x79,%edx
call   1040 <test_repblock@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe71(%rip),%rdi
mov    $0x20,%esi
mov    $0x79,%edx
call   1040 <test_repblock@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0AWorking:\0A\00"
@.str.1 = [31 x i8] c"asdf asdf asdf asdf asdf\00"
@.str.2 = [21 x i8] c"\0AFind not in Source\0A\00"
@.str.3 = [10 x i8] c"asdf asdf\00"
@.str.4 = [15 x i8] c"\0ASource = End\0A\00"
@.str.5 = [19 x i8] c"asdf asdf\00"
@.str.6 = [15 x i8] c"\0AEmpty Source\0A\00"
@.str.7 = [10 x i8] c"\0AReplace\0A\00"
@.str.8 = [14 x i8] c"asdf asdf\00"
@.str.9 = [13 x i8] c"\0ATrailing 4\0A\00"
@.str.10 = [18 x i8] c"asdf asdf \00"
define i32 @main() {
%1 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @test_repblock(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8 signext 32, i8 signext 121)
%3 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @test_repblock(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8 signext 121, i8 signext 32)
%5 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 @test_repblock(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8 signext 32, i8 signext 32)
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%8 = call i32 @test_repblock(i8* null, i8 signext 32, i8 signext 32)
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%10 = call i32 @test_repblock(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8 signext 32, i8 signext 121)
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%12 = call i32 @test_repblock(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8 signext 32, i8 signext 121)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"asdf asdf asdf asdf asdf\00"
@.str.3 = [10 x i8] c"asdf asdf\00"
@.str.5 = [19 x i8] c"asdf asdf\00"
@.str.8 = [14 x i8] c"asdf asdf\00"
@.str.10 = [18 x i8] c"asdf asdf \00"
@str = [10 x i8] c"\0AWorking:\00"
@str.11 = [20 x i8] c"\0AFind not in Source\00"
@str.12 = [14 x i8] c"\0ASource = End\00"
@str.13 = [14 x i8] c"\0AEmpty Source\00"
@str.14 = [9 x i8] c"\0AReplace\00"
@str.15 = [12 x i8] c"\0ATrailing 4\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @test_repblock(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8 signext 32, i8 signext 121)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%4 = tail call i32 @test_repblock(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8 signext 121, i8 signext 32)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @test_repblock(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8 signext 32, i8 signext 32)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @test_repblock(i8* null, i8 signext 32, i8 signext 32)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @test_repblock(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8 signext 32, i8 signext 121)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.15, i64 0, i64 0))
%12 = tail call i32 @test_repblock(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8 signext 32, i8 signext 121)
ret i32 0
}