#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 *, char *, ...);
int str_all_digits(char *);
int str_equal(char const *, char const *);
int str_replace_all(char *, char, char);
int str_replace_last(char *, char, char);
scalar_t__ strcmp(char *, char *);
int main(void) {
  const char same1[] = "Hi";
  const char same2[] = "H";
  char s[] = "hello world";
  char x[] = "xxxxxxx";
  char y[] = "xxxxxxx";
  char z[] = "0123456789";
  char q[] = "hello123world";
  char j[] = "123hello123";
  printf("\n%s\n", "  Replace all test case");
  printf("%s...%s\n",
         (str_replace_all(s, 'h', 'j') == 1) ? "  TEST PASSED"
                                             : "X TEST FAILED",
         "str_replace_all(s, 'h', 'j') == 1");
  ;
  printf("%s...%s\n",
         (strcmp(s, "jello world") == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "strcmp(s, \"jello world\") == 0");
  ;
  printf("%s...%s\n",
         (str_replace_all(s, 'j', 'i') == 1) ? "  TEST PASSED"
                                             : "X TEST FAILED",
         "str_replace_all(s, 'j', 'i') == 1");
  ;
  printf("\n%s\n", "  Replace last test case");
  printf("%s...%s\n",
         (str_replace_last(s, 'd', 'l') == 1) ? "  TEST PASSED"
                                              : "X TEST FAILED",
         "str_replace_last(s, 'd', 'l') == 1");
  ;
  printf("%s...%s\n",
         (strcmp(s, "iello worll") == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "strcmp(s, \"iello worll\") == 0");
  ;
  printf("%s...%s\n",
         (str_replace_last(s, 'V', 'o') == 0) ? "  TEST PASSED"
                                              : "X TEST FAILED",
         "str_replace_last(s, 'V', 'o') == 0");
  ;
  printf("\n%s\n", "  All digits test case");
  printf("%s...%s\n",
         (str_all_digits(z) == 1) ? "  TEST PASSED" : "X TEST FAILED",
         "str_all_digits(z) == 1");
  ;
  printf("%s...%s\n",
         (str_all_digits(s) == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "str_all_digits(s) == 0");
  ;
  printf("%s...%s\n",
         (str_all_digits(j) == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "str_all_digits(j) == 0");
  ;
  printf("\n%s\n", "  Equal test case");
  printf("%s...%s\n",
         (str_equal(s, j) == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "str_equal(s, j) == 0");
  ;
  printf("%s...%s\n",
         (str_equal(q, y) == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "str_equal(q, y) == 0");
  ;
  printf("%s...%s\n",
         (str_equal(x, y) == 1) ? "  TEST PASSED" : "X TEST FAILED",
         "str_equal(x, y) == 1");
  ;
  printf("\n%s\n", "  Equal test case (q2)");
  printf("%s...%s\n",
         (str_equal(same2, same1) == 0) ? "  TEST PASSED" : "X TEST FAILED",
         "str_equal(same2, same1) == 0");
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xe91(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xe89(%rip),%al
mov    %al,-0x1(%rbp)
mov    0xe80(%rip),%ax
mov    %ax,-0x5(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xe6f(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xe64(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    0xe61(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xe5e(%rip),%ax
mov    %ax,-0x24(%rbp)
mov    0xe56(%rip),%al
mov    %al,-0x22(%rbp)
mov    0xe4d(%rip),%rax
mov    %rax,-0x3a(%rbp)
mov    0xe4b(%rip),%eax
mov    %eax,-0x32(%rbp)
mov    0xe45(%rip),%ax
mov    %ax,-0x2e(%rbp)
mov    0xe3c(%rip),%rax
mov    %rax,-0x46(%rbp)
mov    0xe3a(%rip),%eax
mov    %eax,-0x3e(%rbp)
lea    0xe34(%rip),%rdi
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
mov    $0x68,%esi
mov    $0x6a,%edx
call   1050 <str_replace_all@plt>
mov    %eax,%ecx
lea    0xe3e(%rip),%rsi
lea    0xe29(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xe12(%rip),%rdi
lea    0xe30(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
lea    0xe01(%rip),%rsi
lea    0xdec(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xdd4(%rip),%rdi
lea    0xe20(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
mov    $0x6a,%esi
mov    $0x69,%edx
call   1050 <str_replace_all@plt>
mov    %eax,%ecx
lea    0xdc1(%rip),%rsi
lea    0xdac(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xd95(%rip),%rdi
lea    0xdff(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd63(%rip),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
mov    $0x64,%esi
mov    $0x6c,%edx
call   1060 <str_replace_last@plt>
mov    %eax,%ecx
lea    0xd6d(%rip),%rsi
lea    0xd58(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xd41(%rip),%rdi
lea    0xde6(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
lea    0xd30(%rip),%rsi
lea    0xd1b(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xd03(%rip),%rdi
lea    0xdd7(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
mov    $0x56,%esi
mov    $0x6f,%edx
call   1060 <str_replace_last@plt>
mov    %eax,%ecx
lea    0xcf0(%rip),%rsi
lea    0xcdb(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xcc4(%rip),%rdi
lea    0xdb6(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc92(%rip),%rdi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2c(%rbp),%rdi
call   1070 <str_all_digits@plt>
mov    %eax,%ecx
lea    0xca6(%rip),%rsi
lea    0xc91(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xc7a(%rip),%rdi
lea    0xda6(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
call   1070 <str_all_digits@plt>
mov    %eax,%ecx
lea    0xc71(%rip),%rsi
lea    0xc5c(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xc45(%rip),%rdi
lea    0xd88(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x46(%rbp),%rdi
call   1070 <str_all_digits@plt>
mov    %eax,%ecx
lea    0xc3c(%rip),%rsi
lea    0xc27(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xc10(%rip),%rdi
lea    0xd6a(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xbde(%rip),%rdi
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rdi
lea    -0x46(%rbp),%rsi
call   1080 <str_equal@plt>
mov    %eax,%ecx
lea    0xbee(%rip),%rsi
lea    0xbd9(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xbc2(%rip),%rdi
lea    0xd45(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x3a(%rbp),%rdi
lea    -0x21(%rbp),%rsi
call   1080 <str_equal@plt>
mov    %eax,%ecx
lea    0xbb5(%rip),%rsi
lea    0xba0(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xb89(%rip),%rdi
lea    0xd21(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x19(%rbp),%rdi
lea    -0x21(%rbp),%rsi
call   1080 <str_equal@plt>
mov    %eax,%ecx
lea    0xb7c(%rip),%rsi
lea    0xb67(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xb50(%rip),%rdi
lea    0xcfd(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xb1e(%rip),%rdi
lea    0xcfd(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5(%rbp),%rdi
lea    -0x3(%rbp),%rsi
call   1080 <str_equal@plt>
mov    %eax,%ecx
lea    0xb2e(%rip),%rsi
lea    0xb19(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xb02(%rip),%rdi
lea    0xcdb(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movb   $0x0,0x6(%rsp)
movw   $0x6948,0x4(%rsp)
movw   $0x48,0x2(%rsp)
movabs $0x6f77206f6c6c6568,%rax
20 77 6f
mov    %rax,0x38(%rsp)
movl   $0x646c72,0x40(%rsp)
movabs $0x78787878787878,%rax
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,0x8(%rsp)
movl   $0x393837,0xf(%rsp)
movabs $0x646c726f773332,%rax
mov    %rax,0x4e(%rsp)
movabs $0x3332316f6c6c6568,%rax
31 32 33
mov    %rax,0x48(%rsp)
movabs $0x6f6c6c6568333231,%rax
6c 6c 6f
mov    %rax,0x18(%rsp)
movl   $0x333231,0x20(%rsp)
lea    0xe35(%rip),%r14
lea    0xe33(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x38(%rsp),%r12
mov    %r12,%rdi
mov    $0x68,%esi
mov    $0x6a,%edx
call   1050 <str_replace_all@plt>
cmp    $0x1,%eax
lea    0xe29(%rip),%rbp
lea    0xe30(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe0b(%rip),%r15
lea    0xe29(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe3a(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe2d(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    $0x6a,%esi
mov    $0x69,%edx
call   1050 <str_replace_all@plt>
cmp    $0x1,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe1e(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe2f(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    $0x64,%esi
mov    $0x6c,%edx
call   1060 <str_replace_last@plt>
cmp    $0x1,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe1b(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe2d(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe20(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    $0x56,%esi
mov    $0x6f,%edx
call   1060 <str_replace_last@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe12(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe24(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
call   1070 <str_all_digits@plt>
cmp    $0x1,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe16(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
call   1070 <str_all_digits@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe0b(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x18(%rsp),%r13
mov    %r13,%rdi
call   1070 <str_all_digits@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xdfb(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe01(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <str_equal@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xdee(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x48(%rsp),%rdi
lea    0x28(%rsp),%r12
mov    %r12,%rsi
call   1080 <str_equal@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xdd7(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x30(%rsp),%rdi
mov    %r12,%rsi
call   1080 <str_equal@plt>
cmp    $0x1,%eax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xdc4(%rip),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdc8(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x2(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1080 <str_equal@plt>
test   %eax,%eax
cmove  %rbp,%rbx
lea    0xdb9(%rip),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.same1 = [3 x i8] c"Hi\00"
@__const.main.same2 = [2 x i8] c"H\00"
@__const.main.s = [12 x i8] c"hello world\00"
@__const.main.x = [8 x i8] c"xxxxxxx\00"
@__const.main.y = [8 x i8] c"xxxxxxx\00"
@__const.main.z = [11 x i8] c"0123456789\00"
@__const.main.q = [14 x i8] c"hello123world\00"
@__const.main.j = [12 x i8] c"123hello123\00"
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [24 x i8] c" Replace all test case\00"
@.str.2 = [9 x i8] c"%s...%s\0A\00"
@.str.3 = [14 x i8] c" TEST PASSED\00"
@.str.4 = [14 x i8] c"X TEST FAILED\00"
@.str.5 = [34 x i8] c"str_replace_all(s, 'h', 'j') == 1\00"
@.str.6 = [12 x i8] c"jello world\00"
@.str.7 = [30 x i8] c"strcmp(s, \22jello world\22) == 0\00"
@.str.8 = [34 x i8] c"str_replace_all(s, 'j', 'i') == 1\00"
@.str.9 = [25 x i8] c" Replace last test case\00"
@.str.10 = [35 x i8] c"str_replace_last(s, 'd', 'l') == 1\00"
@.str.11 = [12 x i8] c"iello worll\00"
@.str.12 = [30 x i8] c"strcmp(s, \22iello worll\22) == 0\00"
@.str.13 = [35 x i8] c"str_replace_last(s, 'V', 'o') == 0\00"
@.str.14 = [23 x i8] c" All digits test case\00"
@.str.15 = [23 x i8] c"str_all_digits(z) == 1\00"
@.str.16 = [23 x i8] c"str_all_digits(s) == 0\00"
@.str.17 = [23 x i8] c"str_all_digits(j) == 0\00"
@.str.18 = [18 x i8] c" Equal test case\00"
@.str.19 = [21 x i8] c"str_equal(s, j) == 0\00"
@.str.20 = [21 x i8] c"str_equal(q, y) == 0\00"
@.str.21 = [21 x i8] c"str_equal(x, y) == 1\00"
@.str.22 = [23 x i8] c" Equal test case (q2)\00"
@.str.23 = [29 x i8] c"str_equal(same2, same1) == 0\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = alloca [2 x i8]
%3 = alloca [12 x i8]
%4 = alloca [8 x i8]
%5 = alloca [8 x i8]
%6 = alloca [11 x i8]
%7 = alloca [14 x i8]
%8 = alloca [12 x i8]
%9 = bitcast [3 x i8]* %1 to i8*
%10 = bitcast [2 x i8]* %2 to i8*
%11 = bitcast [12 x i8]* %3 to i8*
%12 = bitcast [8 x i8]* %4 to i8*
%13 = bitcast [8 x i8]* %5 to i8*
%14 = bitcast [11 x i8]* %6 to i8*
%15 = bitcast [14 x i8]* %7 to i8*
%16 = bitcast [12 x i8]* %8 to i8*
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%19 = call i32 @str_replace_all(i8* %18, i8 signext 104, i8 signext 106)
%20 = icmp eq i32 %19, 1
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%24 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%30 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%31 = call i32 @str_replace_all(i8* %30, i8 signext 106, i8 signext 105)
%32 = icmp eq i32 %31, 1
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%38 = call i32 @str_replace_last(i8* %37, i8 signext 100, i8 signext 108)
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%43 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%48 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %47, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%49 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%50 = call i32 @str_replace_last(i8* %49, i8 signext 86, i8 signext 111)
%51 = icmp eq i32 %50, 0
%52 = zext i1 %51 to i64
%53 = select i1 %51, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%54 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %53, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
%55 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
%56 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%57 = call i32 @str_all_digits(i8* %56)
%58 = icmp eq i32 %57, 1
%59 = zext i1 %58 to i64
%60 = select i1 %58, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%61 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%62 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%63 = call i32 @str_all_digits(i8* %62)
%64 = icmp eq i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%67 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %66, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%68 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%69 = call i32 @str_all_digits(i8* %68)
%70 = icmp eq i32 %69, 0
%71 = zext i1 %70 to i64
%72 = select i1 %70, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%73 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %72, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%74 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0))
%75 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%76 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%77 = call i32 @str_equal(i8* %75, i8* %76)
%78 = icmp eq i32 %77, 0
%79 = zext i1 %78 to i64
%80 = select i1 %78, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%81 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %80, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%82 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 0
%83 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%84 = call i32 @str_equal(i8* %82, i8* %83)
%85 = icmp eq i32 %84, 0
%86 = zext i1 %85 to i64
%87 = select i1 %85, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%88 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %87, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%89 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%90 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%91 = call i32 @str_equal(i8* %89, i8* %90)
%92 = icmp eq i32 %91, 1
%93 = zext i1 %92 to i64
%94 = select i1 %92, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%95 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %94, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0))
%96 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.22, i64 0, i64 0))
%97 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%98 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%99 = call i32 @str_equal(i8* %97, i8* %98)
%100 = icmp eq i32 %99, 0
%101 = zext i1 %100 to i64
%102 = select i1 %100, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%103 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %102, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.23, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.same1 = [3 x i8] c"Hi\00"
@__const.main.s = [12 x i8] c"hello world\00"
@__const.main.z = [11 x i8] c"0123456789\00"
@__const.main.q = [14 x i8] c"hello123world\00"
@__const.main.j = [12 x i8] c"123hello123\00"
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [24 x i8] c" Replace all test case\00"
@.str.2 = [9 x i8] c"%s...%s\0A\00"
@.str.3 = [14 x i8] c" TEST PASSED\00"
@.str.4 = [14 x i8] c"X TEST FAILED\00"
@.str.5 = [34 x i8] c"str_replace_all(s, 'h', 'j') == 1\00"
@.str.6 = [12 x i8] c"jello world\00"
@.str.7 = [30 x i8] c"strcmp(s, \22jello world\22) == 0\00"
@.str.8 = [34 x i8] c"str_replace_all(s, 'j', 'i') == 1\00"
@.str.9 = [25 x i8] c" Replace last test case\00"
@.str.10 = [35 x i8] c"str_replace_last(s, 'd', 'l') == 1\00"
@.str.11 = [12 x i8] c"iello worll\00"
@.str.12 = [30 x i8] c"strcmp(s, \22iello worll\22) == 0\00"
@.str.13 = [35 x i8] c"str_replace_last(s, 'V', 'o') == 0\00"
@.str.14 = [23 x i8] c" All digits test case\00"
@.str.15 = [23 x i8] c"str_all_digits(z) == 1\00"
@.str.16 = [23 x i8] c"str_all_digits(s) == 0\00"
@.str.17 = [23 x i8] c"str_all_digits(j) == 0\00"
@.str.18 = [18 x i8] c" Equal test case\00"
@.str.19 = [21 x i8] c"str_equal(s, j) == 0\00"
@.str.20 = [21 x i8] c"str_equal(q, y) == 0\00"
@.str.21 = [21 x i8] c"str_equal(x, y) == 1\00"
@.str.22 = [23 x i8] c" Equal test case (q2)\00"
@.str.23 = [29 x i8] c"str_equal(same2, same1) == 0\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = alloca i16
%3 = alloca [12 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = alloca [11 x i8]
%7 = alloca [14 x i8]
%8 = alloca [12 x i8]
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%10 = bitcast i16* %2 to i8*
store i16 72, i16* %2
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%12 = bitcast i64* %4 to i8*
store i64 33909456017848440, i64* %4
%13 = bitcast i64* %5 to i8*
store i64 33909456017848440, i64* %5
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @str_replace_all(i8* %11, i8 signext 104, i8 signext 106)
%19 = icmp eq i32 %18, 1
%20 = select i1 %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%22 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 @str_replace_all(i8* %11, i8 signext 106, i8 signext 105)
%27 = icmp eq i32 %26, 1
%28 = select i1 %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%31 = call i32 @str_replace_last(i8* %11, i8 signext 100, i8 signext 108)
%32 = icmp eq i32 %31, 1
%33 = select i1 %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %33, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%35 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %37, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%39 = call i32 @str_replace_last(i8* %11, i8 signext 86, i8 signext 111)
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
%43 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
%44 = call i32 @str_all_digits(i8* %14)
%45 = icmp eq i32 %44, 1
%46 = select i1 %45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%47 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%48 = call i32 @str_all_digits(i8* %11)
%49 = icmp eq i32 %48, 0
%50 = select i1 %49, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%51 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%52 = call i32 @str_all_digits(i8* %16)
%53 = icmp eq i32 %52, 0
%54 = select i1 %53, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%55 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %54, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0))
%57 = call i32 @str_equal(i8* %11, i8* %16)
%58 = icmp eq i32 %57, 0
%59 = select i1 %58, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%60 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %59, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%61 = call i32 @str_equal(i8* %15, i8* %13)
%62 = icmp eq i32 %61, 0
%63 = select i1 %62, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %63, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%65 = call i32 @str_equal(i8* %12, i8* %13)
%66 = icmp eq i32 %65, 1
%67 = select i1 %66, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%68 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %67, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0))
%69 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.22, i64 0, i64 0))
%70 = call i32 @str_equal(i8* %10, i8* %9)
%71 = icmp eq i32 %70, 0
%72 = select i1 %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%73 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %72, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.23, i64 0, i64 0))
ret i32 0
}