#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 find(char *, char);
char *slice(char *str, char ch) {
  int i = -1;
  if (*str && str) {
    i = find(str, ch);
    if (i > 0)
      *(str + i) = '\0';
  }
  return (str + i + 1);
}


x86 assembly (clang, -O0):
<slice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116f <slice+0x5f>
cmpq   $0x0,-0x8(%rbp)
je     116f <slice+0x5f>
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <find@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    116a <slice+0x5a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    116f <slice+0x5f>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slice>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1131 <slice+0x21>
movsbl %sil,%esi
mov    %rbx,%rdi
call   1030 <find@plt>
test   %eax,%eax
jle    1136 <slice+0x26>
mov    %eax,%ecx
movb   $0x0,(%rbx,%rcx,1)
jmp    1136 <slice+0x26>
mov    $0xffffffff,%eax
cltq
add    %rbx,%rax
add    $0x1,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @slice(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 -1, i32* %5
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = load i8, i8* %4
%16 = call i32 @find(i8* %14, i8 signext %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %19, %13
br label %25
25: ; preds = %24, %10, %2
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = getelementptr inbounds i8, i8* %29, i64 1
ret i8* %30
}

LLVM IR (-O2):
define i8* @slice(i8* %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i32 @find(i8* %0, i8 signext %1)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = zext i32 %6 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
br label %11
11: ; preds = %5, %8, %2
%12 = phi i32 [ %6, %8 ], [ %6, %5 ], [ -1, %2 ]
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 1
ret i8* %15
}