#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 */
scalar_t__ isalpha(char);
int strlen(char *);
char *strstr(char *, char *);
char *strtexchr(char *string, char *texchr) {
  char delim, *ptexchr = (char *)NULL;
  char *pstring = string;
  int texchrlen = (texchr == NULL ? 0 : strlen(texchr));
  if (string != (char *)NULL && texchrlen > 0) {
    while ((ptexchr = strstr(pstring, texchr)) != (char *)NULL)
      if ((delim = ptexchr[texchrlen]) == '\000')
        break;
      else if (isalpha(delim) || 0)
        pstring = ptexchr + texchrlen;
      else
        break;
  }
  return (ptexchr);
}


x86 assembly (clang, -O0):
<strtexchr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1165 <strtexchr+0x35>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    1171 <strtexchr+0x41>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1206 <strtexchr+0xd6>
cmpl   $0x0,-0x2c(%rbp)
jle    1206 <strtexchr+0xd6>
jmp    1191 <strtexchr+0x61>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1201 <strtexchr+0xd1>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
jne    11cb <strtexchr+0x9b>
jmp    1201 <strtexchr+0xd1>
movsbl -0x11(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     11f2 <strtexchr+0xc2>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    11f7 <strtexchr+0xc7>
jmp    1201 <strtexchr+0xd1>
jmp    11fc <strtexchr+0xcc>
jmp    1191 <strtexchr+0x61>
jmp    1206 <strtexchr+0xd6>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtexchr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1191 <strtexchr+0x61>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
xor    %r15d,%r15d
test   %rbx,%rbx
je     1194 <strtexchr+0x64>
test   %eax,%eax
jle    1194 <strtexchr+0x64>
mov    %eax,%r12d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1191 <strtexchr+0x61>
mov    %rax,%r15
movzbl (%rax,%r12,1),%eax
test   %al,%al
je     1194 <strtexchr+0x64>
mov    %r15,%rbx
add    %r12,%rbx
movsbl %al,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    1160 <strtexchr+0x30>
jmp    1194 <strtexchr+0x64>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strtexchr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* null, i8** %6
%9 = load i8*, i8** %3
store i8* %9, i8** %7
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
br label %16
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
br label %16
16: ; preds = %13, %12
%17 = phi i32 [ 0, %12 ], [ %15, %13 ]
store i32 %17, i32* %8
%18 = load i8*, i8** %3
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %51
20: ; preds = %16
%21 = load i32, i32* %8
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %51
23: ; preds = %20
br label %24
24: ; preds = %49, %23
%25 = load i8*, i8** %7
%26 = load i8*, i8** %4
%27 = call i8* @strstr(i8* %25, i8* %26)
store i8* %27, i8** %6
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %50
29: ; preds = %24
%30 = load i8*, i8** %6
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
store i8 %34, i8* %5
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %29
br label %50
38: ; preds = %29
%39 = load i8, i8* %5
%40 = call i64 @isalpha(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = load i8*, i8** %6
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8* %46, i8** %7
br label %48
47: ; preds = %38
br label %50
48: ; preds = %42
br label %49
49: ; preds = %48
br label %24
50: ; preds = %47, %37, %24
br label %51
51: ; preds = %50, %20, %16
%52 = load i8*, i8** %6
ret i8* %52
}

LLVM IR (-O2):
define i8* @strtexchr(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp ne i8* %0, null
%7 = icmp sgt i32 %5, 0
%8 = select i1 %6, i1 %7, i1 false
br i1 %8, label %9, label %22
9: ; preds = %4
%10 = zext i32 %5 to i64
br label %11
11: ; preds = %9, %19
%12 = phi i8* [ %16, %19 ], [ %0, %9 ]
%13 = tail call i8* @strstr(i8* dereferenceable(1) %12, i8* dereferenceable(1) %1)
%14 = icmp eq i8* %13, null
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %13, i64 %10
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = tail call i64 @isalpha(i8 signext %17)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %11, %15, %19, %2, %4
%23 = phi i8* [ null, %4 ], [ null, %2 ], [ null, %11 ], [ %13, %19 ], [ %13, %15 ]
ret i8* %23
}