#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 *stb_strchr2(char *, char, char);
char *strchr(char *, char);
scalar_t__ tolower(char);
scalar_t__ toupper(char);
char *stb_strichr(char *s, char t) {
  if (tolower(t) == toupper(t))
    return strchr(s, t);
  return stb_strchr2(s, (char)tolower(t), (char)toupper(t));
}


x86 assembly (clang, -O0):
<stb_strichr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1060 <tolower@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    118e <stb_strichr+0x4e>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1040 <strchr@plt>
mov    %rax,-0x8(%rbp)
jmp    11c1 <stb_strichr+0x81>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movsbl -0x11(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,-0x21(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <toupper@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%cl
movsbl %cl,%esi
movsbl %al,%edx
call   1050 <stb_strchr2@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_strichr>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
call   1060 <tolower@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1030 <toupper@plt>
cmp    %rax,%rbx
jne    116f <stb_strichr+0x2f>
movsbl %bpl,%esi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <strchr@plt>
movsbl %bpl,%ebx
mov    %ebx,%edi
call   1060 <tolower@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1030 <toupper@plt>
movsbl %bpl,%esi
movsbl %al,%edx
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <stb_strchr2@plt>

LLVM IR (-O0):
define i8* @stb_strichr(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = call i64 @tolower(i8 signext %6)
%8 = load i8, i8* %5
%9 = call i64 @toupper(i8 signext %8)
%10 = icmp eq i64 %7, %9
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8, i8* %5
%14 = call i8* @strchr(i8* %12, i8 signext %13)
store i8* %14, i8** %3
br label %24
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i8, i8* %5
%18 = call i64 @tolower(i8 signext %17)
%19 = trunc i64 %18 to i8
%20 = load i8, i8* %5
%21 = call i64 @toupper(i8 signext %20)
%22 = trunc i64 %21 to i8
%23 = call i8* @stb_strchr2(i8* %16, i8 signext %19, i8 signext %22)
store i8* %23, i8** %3
br label %24
24: ; preds = %15, %11
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
define i8* @stb_strichr(i8* %0, i8 signext %1) {
%3 = tail call i64 @tolower(i8 signext %1)
%4 = tail call i64 @toupper(i8 signext %1)
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext %1)
br label %14
8: ; preds = %2
%9 = tail call i64 @tolower(i8 signext %1)
%10 = trunc i64 %9 to i8
%11 = tail call i64 @toupper(i8 signext %1)
%12 = trunc i64 %11 to i8
%13 = tail call i8* @stb_strchr2(i8* %0, i8 signext %10, i8 signext %12)
br label %14
14: ; preds = %8, %6
%15 = phi i8* [ %7, %6 ], [ %13, %8 ]
ret i8* %15
}