#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 */
char *ho_strrchr(char *, char);
char *ho_strrchr2(char *, char);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("%s\n", ho_strrchr("123456789", '1'));
  printf("%s\n", ho_strrchr("123456789", '2'));
  printf("%s\n", ho_strrchr("123456789", '3'));
  printf("%s\n", ho_strrchr("123456789", '9'));
  printf("%s\n", ho_strrchr("123456789", 'a'));
  printf("%s\n", ho_strrchr("123123", '1'));
  printf("===============\n");
  printf("%s\n", ho_strrchr2("123456789", '1'));
  printf("%s\n", ho_strrchr2("123456789", '2'));
  printf("%s\n", ho_strrchr2("123456789", '3'));
  printf("%s\n", ho_strrchr2("123456789", '9'));
  printf("%s\n", ho_strrchr2("123456789", 'a'));
  printf("%s\n", ho_strrchr2("123123", '1'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x31,%esi
call   1030 <ho_strrchr@plt>
mov    %rax,%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x32,%esi
call   1030 <ho_strrchr@plt>
mov    %rax,%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x33,%esi
call   1030 <ho_strrchr@plt>
mov    %rax,%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x39,%esi
call   1030 <ho_strrchr@plt>
mov    %rax,%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
mov    $0x61,%esi
call   1030 <ho_strrchr@plt>
mov    %rax,%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    $0x31,%esi
call   1030 <ho_strrchr@plt>
mov    %rax,%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde4(%rip),%rdi
mov    $0x31,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc2(%rip),%rdi
mov    $0x32,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rsi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda0(%rip),%rdi
mov    $0x33,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7e(%rip),%rdi
mov    $0x39,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rsi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd5c(%rip),%rdi
mov    $0x61,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rsi
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd44(%rip),%rdi
mov    $0x31,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rsi
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rbx
mov    %rbx,%rdi
mov    $0x31,%esi
call   1040 <ho_strrchr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1040 <ho_strrchr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x33,%esi
call   1040 <ho_strrchr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x39,%esi
call   1040 <ho_strrchr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
call   1040 <ho_strrchr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
lea    0xe5f(%rip),%r14
mov    %r14,%rdi
mov    $0x31,%esi
call   1040 <ho_strrchr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x31,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x33,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x39,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x31,%esi
call   1050 <ho_strrchr2@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [10 x i8] c"123456789\00"
@.str.2 = [7 x i8] c"123123\00"
@.str.3 = [17 x i8] c"===============\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 49)
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 50)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 51)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 57)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i8* @ho_strrchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 signext 49)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%15 = call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 49)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 50)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 51)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 57)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i8* @ho_strrchr2(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 signext 49)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"123456789\00"
@.str.2 = [7 x i8] c"123123\00"
@str = [16 x i8] c"===============\00"
define i32 @main() {
%1 = tail call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 49)
%2 = tail call i32 @puts(i8* dereferenceable(1) %1)
%3 = tail call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 50)
%4 = tail call i32 @puts(i8* dereferenceable(1) %3)
%5 = tail call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 51)
%6 = tail call i32 @puts(i8* dereferenceable(1) %5)
%7 = tail call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 57)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = tail call i8* @ho_strrchr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = tail call i8* @ho_strrchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 signext 49)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%14 = tail call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 49)
%15 = tail call i32 @puts(i8* dereferenceable(1) %14)
%16 = tail call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 50)
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
%18 = tail call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 51)
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
%20 = tail call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 57)
%21 = tail call i32 @puts(i8* dereferenceable(1) %20)
%22 = tail call i8* @ho_strrchr2(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%23 = tail call i32 @puts(i8* dereferenceable(1) %22)
%24 = tail call i8* @ho_strrchr2(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 signext 49)
%25 = tail call i32 @puts(i8* dereferenceable(1) %24)
ret i32 0
}