#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);
char *strrchr(char *, char);
main() {
  char strp[] = "Never ever say no";
  char *chp, c = 'e';
  int i, j;
  chp = strrchr(strp, c);
  i = chp - strp;
  for (j = 0; j <= i; j++)
    printf("%c", strp[j]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%ax
mov    %ax,-0x10(%rbp)
movb   $0x65,-0x29(%rbp)
lea    -0x20(%rbp),%rdi
movsbl -0x29(%rbp),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
lea    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jg     11a9 <main+0x89>
movslq -0x34(%rbp),%rax
lea    0xe81(%rip),%rdi
movsbl -0x20(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117a <main+0x5a>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xed0(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x6f,0x10(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x65,%esi
call   1040 <strrchr@plt>
mov    %rax,%r15
sub    %r14d,%eax
test   $0x80000000,%eax
jne    11a5 <main+0x85>
mov    %rsp,%rax
sub    %eax,%r15d
add    $0x1,%r15d
lea    0xea9(%rip),%rdi
mov    $0x4e,%esi
call   1030 <printf@plt>
cmp    $0x1,%r15d
je     11a5 <main+0x85>
mov    $0x1,%ebx
lea    0xe8d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <main+0x70>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.strp = [18 x i8] c"Never ever say no\00"
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [18 x i8]* %2 to i8*
store i8 101, i8* %4
%8 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%9 = load i8, i8* %4
%10 = call i8* @strrchr(i8* %8, i8 signext %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%13 = ptrtoint i8* %11 to i64
%14 = ptrtoint i8* %12 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
store i32 %16, i32* %5
store i32 0, i32* %6
br label %17
17: ; preds = %27, %0
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %17
30: ; preds = %17
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@__const.main.strp = [18 x i8] c"Never ever say no\00"
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%3 = call i8* @strrchr(i8* %2, i8 signext 101)
%4 = ptrtoint i8* %3 to i64
%5 = ptrtoint [18 x i8]* %1 to i64
%6 = sub i64 %4, %5
%7 = and i64 %6, 2147483648
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %0
%10 = add i64 %4, 1
%11 = sub i64 %10, %5
%12 = and i64 %11, 4294967295
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 78)
%14 = icmp eq i64 %12, 1
br i1 %14, label %22, label %15
15: ; preds = %9, %15
%16 = phi i64 [ %20, %15 ], [ 1, %9 ]
%17 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %12
br i1 %21, label %22, label %15
22: ; preds = %15, %9, %0
ret i32 0
}