#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__ strncasecmp(char const *, char *, int);
char *strcasechr(const char *s, char c) {
  for (; *s && c; s++) {
    if (strncasecmp(s, &c, 1) == 0) {
      return (char *)s;
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<strcasechr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
je     1144 <strcasechr+0x34>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1154 <strcasechr+0x44>
jmp    1193 <strcasechr+0x83>
mov    -0x10(%rbp),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    117d <strcasechr+0x6d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <strcasechr+0x8b>
jmp    1182 <strcasechr+0x72>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1122 <strcasechr+0x12>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasechr>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %sil,0xf(%rsp)
xor    %r14d,%r14d
test   %sil,%sil
je     1164 <strcasechr+0x54>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1164 <strcasechr+0x54>
lea    0xf(%rsp),%r15
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncasecmp@plt>
test   %rax,%rax
je     1161 <strcasechr+0x51>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <strcasechr+0x30>
jmp    1164 <strcasechr+0x54>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @strcasechr(i8* %0, i8 signext %1) {
%3 = alloca i8
store i8 %1, i8* %3
%4 = icmp ne i8 %1, 0
%5 = load i8, i8* %0
%6 = icmp ne i8 %5, 0
%7 = and i1 %4, %6
br i1 %7, label %8, label %16
8: ; preds = %2, %12
%9 = phi i8* [ %13, %12 ], [ %0, %2 ]
%10 = call i64 @strncasecmp(i8* %9, i8* %3, i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %8
16: ; preds = %8, %12, %2
%17 = phi i8* [ null, %2 ], [ null, %12 ], [ %9, %8 ]
ret i8* %17
}