#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 */
struct btp_location {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ btp_location_eat_char(struct btp_location *, char const);
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char const *, size_t);
const char *findfirstabnul(const char *input, const char *a, const char *b,
                           struct btp_location *location) {
  size_t alen = strlen(a);
  size_t blen = strlen(b);
  const char *p = input;
  while (*p) {
    if (strncmp(p, a, alen) == 0)
      return p;
    if (strncmp(p, b, blen) == 0)
      return p;
    btp_location_eat_char(location, *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    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e8 <findfirstabnul+0xb8>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119f <findfirstabnul+0x6f>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f0 <findfirstabnul+0xc0>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c7 <findfirstabnul+0x97>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f0 <findfirstabnul+0xc0>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rax
movsbl (%rax),%esi
call   1040 <btp_location_eat_char@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    116a <findfirstabnul+0x3a>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findfirstabnul>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1050 <strlen@plt>
cmpb   $0x0,(%rbx)
je     11b0 <findfirstabnul+0x80>
mov    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <findfirstabnul+0x80>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <findfirstabnul+0x80>
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1040 <btp_location_eat_char@plt>
lea    0x1(%rbx),%rax
cmpb   $0x0,0x1(%rbx)
mov    %rax,%rbx
jne    1170 <findfirstabnul+0x40>
jmp    11b3 <findfirstabnul+0x83>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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