#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 */
size_t strlen(char const *);
scalar_t__ strncmp(char *, char const *, size_t);
char *findfirstabnul(char *input, const char *a, const char *b) {
  size_t alen = strlen(a);
  size_t blen = strlen(b);
  char *p = input;
  while (*p) {
    if (strncmp(p, a, alen) == 0)
      return p;
    if (strncmp(p, b, blen) == 0)
      return p;
    ++p;
  }
  return p;
}


x86 assembly (clang, -O0):
<findfirstabnul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c4 <findfirstabnul+0xa4>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    118b <findfirstabnul+0x6b>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <findfirstabnul+0xac>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b3 <findfirstabnul+0x93>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <findfirstabnul+0xac>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1156 <findfirstabnul+0x36>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findfirstabnul>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1040 <strlen@plt>
cmpb   $0x0,(%rbx)
je     1185 <findfirstabnul+0x65>
mov    %rax,%r13
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1185 <findfirstabnul+0x65>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1185 <findfirstabnul+0x65>
lea    0x1(%rbx),%rax
cmpb   $0x0,0x1(%rbx)
mov    %rax,%rbx
jne    1150 <findfirstabnul+0x30>
jmp    1188 <findfirstabnul+0x68>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @findfirstabnul(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %6
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %8
%13 = load i8*, i8** %7
%14 = call i64 @strlen(i8* %13)
store i64 %14, i64* %9
%15 = load i8*, i8** %5
store i8* %15, i8** %10
br label %16
16: ; preds = %36, %3
%17 = load i8*, i8** %10
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %16
%21 = load i8*, i8** %10
%22 = load i8*, i8** %6
%23 = load i64, i64* %8
%24 = call i64 @strncmp(i8* %21, i8* %22, i64 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = load i8*, i8** %10
store i8* %27, i8** %4
br label %41
28: ; preds = %20
%29 = load i8*, i8** %10
%30 = load i8*, i8** %7
%31 = load i64, i64* %9
%32 = call i64 @strncmp(i8* %29, i8* %30, i64 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = load i8*, i8** %10
store i8* %35, i8** %4
br label %41
36: ; preds = %28
%37 = load i8*, i8** %10
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %10
br label %16
39: ; preds = %16
%40 = load i8*, i8** %10
store i8* %40, i8** %4
br label %41
41: ; preds = %39, %34, %26
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
define i8* @findfirstabnul(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %3, %15
%9 = phi i8* [ %16, %15 ], [ %0, %3 ]
%10 = tail call i64 @strncmp(i8* %9, i8* %1, i64 %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %8
%13 = tail call i64 @strncmp(i8* %9, i8* %2, i64 %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %9, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %8
19: ; preds = %8, %12, %15, %3
%20 = phi i8* [ %0, %3 ], [ %16, %15 ], [ %9, %12 ], [ %9, %8 ]
ret i8* %20
}