#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_str(char *, char *, char *);
int main(void) {
  test_str("Hello!", "el", "qq");
  printf("\n2 to 2\n");
  test_str("Hello!", "el", "qq");
  printf("\n2 to 1\n");
  test_str("Hello!", "el", "q");
  printf("\n1 to 2\n");
  test_str("Hello!", "e", "qq");
  printf("\nMore than 1\n");
  test_str("Hello!", "l", "q");
  printf("\nMore than 1 (long)\n");
  test_str("Hello! Hello!", "Hello", "Hi");
  printf("\nNone\n");
  test_str("Hello!", "f", "q");
  printf("\nReplace with Nothing\n");
  test_str("Hello!", "l", "");
  printf("\nFull Word\n");
  test_str("Hello!", "Hello!", "q");
  printf("\nFull Word Long\n");
  test_str("Hello!", "Hello!", "Another Word!");
  printf("\nOther Characters in String\n");
  test_str("This string is a Test!", "string", "array");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xf22(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xeca(%rip),%rdx
call   1030 <test_str@plt>
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
lea    0xea8(%rip),%rsi
lea    0xea4(%rip),%rdx
call   1030 <test_str@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0xe82(%rip),%rsi
lea    0xe7f(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    0xe7d(%rip),%rsi
lea    0xe58(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    0xe37(%rip),%rsi
lea    0xe33(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    0xe64(%rip),%rsi
lea    0xe63(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
lea    0xe4e(%rip),%rsi
lea    0xde7(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe18(%rip),%rdi
lea    0xdc5(%rip),%rsi
lea    0xe02(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf2(%rip),%rsi
lea    0xda2(%rip),%rdx
mov    %rsi,%rdi
call   1030 <test_str@plt>
lea    0xe18(%rip),%rdi
call   1040 <printf@plt>
lea    0xdd0(%rip),%rsi
lea    0xe16(%rip),%rdx
mov    %rsi,%rdi
call   1030 <test_str@plt>
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
lea    0xe26(%rip),%rdi
lea    0xe36(%rip),%rsi
lea    0xe36(%rip),%rdx
call   1030 <test_str@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xede(%rip),%rbx
lea    0xeca(%rip),%r12
lea    0xec6(%rip),%r15
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <test_str@plt>
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <test_str@plt>
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%r14
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <test_str@plt>
lea    0xed4(%rip),%rdi
call   1040 <puts@plt>
lea    0xef5(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1030 <test_str@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4a(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <test_str@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2e(%rip),%rdi
lea    0xe35(%rip),%rsi
lea    0xe34(%rip),%rdx
call   1030 <test_str@plt>
lea    0xe98(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1f(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <test_str@plt>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
lea    0xe10(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <test_str@plt>
lea    0xe78(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <test_str@plt>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
lea    0xdcb(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <test_str@plt>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
lea    0xdbb(%rip),%rdi
lea    0xdcb(%rip),%rsi
lea    0xdcb(%rip),%rdx
call   1030 <test_str@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Hello!\00"
@.str.1 = [3 x i8] c"el\00"
@.str.2 = [3 x i8] c"qq\00"
@.str.3 = [9 x i8] c"\0A2 to 2\0A\00"
@.str.4 = [9 x i8] c"\0A2 to 1\0A\00"
@.str.5 = [2 x i8] c"q\00"
@.str.6 = [9 x i8] c"\0A1 to 2\0A\00"
@.str.7 = [2 x i8] c"e\00"
@.str.8 = [14 x i8] c"\0AMore than 1\0A\00"
@.str.9 = [2 x i8] c"l\00"
@.str.10 = [21 x i8] c"\0AMore than 1 (long)\0A\00"
@.str.11 = [14 x i8] c"Hello! Hello!\00"
@.str.12 = [6 x i8] c"Hello\00"
@.str.13 = [3 x i8] c"Hi\00"
@.str.14 = [7 x i8] c"\0ANone\0A\00"
@.str.15 = [2 x i8] c"f\00"
@.str.16 = [23 x i8] c"\0AReplace with Nothing\0A\00"
@.str.17 = [1 x i8] zeroinitializer
@.str.18 = [12 x i8] c"\0AFull Word\0A\00"
@.str.19 = [17 x i8] c"\0AFull Word Long\0A\00"
@.str.20 = [14 x i8] c"Another Word!\00"
@.str.21 = [29 x i8] c"\0AOther Characters in String\0A\00"
@.str.22 = [23 x i8] c"This string is a Test!\00"
@.str.23 = [7 x i8] c"string\00"
@.str.24 = [6 x i8] c"array\00"
define i32 @main() {
%1 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%2 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%3 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%5 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%7 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%9 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%11 = call i32 @test_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%13 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%15 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.17, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0))
%17 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0))
%19 = call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.20, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0))
%21 = call i32 @test_str(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.24, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Hello!\00"
@.str.1 = [3 x i8] c"el\00"
@.str.2 = [3 x i8] c"qq\00"
@.str.5 = [2 x i8] c"q\00"
@.str.7 = [2 x i8] c"e\00"
@.str.9 = [2 x i8] c"l\00"
@.str.11 = [14 x i8] c"Hello! Hello!\00"
@.str.12 = [6 x i8] c"Hello\00"
@.str.13 = [3 x i8] c"Hi\00"
@.str.15 = [2 x i8] c"f\00"
@.str.17 = [1 x i8] zeroinitializer
@.str.20 = [14 x i8] c"Another Word!\00"
@.str.22 = [23 x i8] c"This string is a Test!\00"
@.str.23 = [7 x i8] c"string\00"
@.str.24 = [6 x i8] c"array\00"
@str = [8 x i8] c"\0A2 to 2\00"
@str.25 = [8 x i8] c"\0A2 to 1\00"
@str.26 = [8 x i8] c"\0A1 to 2\00"
@str.27 = [13 x i8] c"\0AMore than 1\00"
@str.28 = [20 x i8] c"\0AMore than 1 (long)\00"
@str.29 = [6 x i8] c"\0ANone\00"
@str.30 = [22 x i8] c"\0AReplace with Nothing\00"
@str.31 = [11 x i8] c"\0AFull Word\00"
@str.32 = [16 x i8] c"\0AFull Word Long\00"
@str.33 = [28 x i8] c"\0AOther Characters in String\00"
define i32 @main() {
%1 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.25, i64 0, i64 0))
%5 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.26, i64 0, i64 0))
%7 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.27, i64 0, i64 0))
%9 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.28, i64 0, i64 0))
%11 = tail call i32 @test_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.29, i64 0, i64 0))
%13 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.30, i64 0, i64 0))
%15 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.17, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.31, i64 0, i64 0))
%17 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.32, i64 0, i64 0))
%19 = tail call i32 @test_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.20, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.33, i64 0, i64 0))
%21 = tail call i32 @test_str(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.24, i64 0, i64 0))
ret i32 0
}