#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 */
unsigned int strlen(char *);
unsigned strpbrk(char a[], char b[]) {
  unsigned i, j;
  for (i = 0; i < strlen(a); i++) {
    for (j = 0; j < strlen(b); j++) {
      if (a[i] == b[j])
        return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<strpbrk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jae    11b5 <strpbrk+0xa5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jae    11a2 <strpbrk+0x92>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    118f <strpbrk+0x7f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <strpbrk+0xac>
jmp    1194 <strpbrk+0x84>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114a <strpbrk+0x3a>
jmp    11a7 <strpbrk+0x97>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <strpbrk+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strpbrk>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
je     1192 <strpbrk+0x82>
xor    %r12d,%r12d
jmp    1153 <strpbrk+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%r12
jae    1192 <strpbrk+0x82>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1140 <strpbrk+0x30>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%r12,1),%eax
cmp    (%rbx,%rbp,1),%al
je     118f <strpbrk+0x7f>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbp
jb     1170 <strpbrk+0x60>
jmp    1140 <strpbrk+0x30>
mov    %r12d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @strpbrk(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %29, label %5
5: ; preds = %2, %22
%6 = phi i64 [ %23, %22 ], [ 0, %2 ]
%7 = tail call i32 @strlen(i8* %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 %6
br label %15
11: ; preds = %15
%12 = tail call i32 @strlen(i8* %1)
%13 = zext i32 %12 to i64
%14 = icmp ult i64 %21, %13
br i1 %14, label %15, label %22
15: ; preds = %9, %11
%16 = phi i64 [ 0, %9 ], [ %21, %11 ]
%17 = load i8, i8* %10
%18 = getelementptr inbounds i8, i8* %1, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %17, %19
%21 = add nuw nsw i64 %16, 1
br i1 %20, label %27, label %11
22: ; preds = %11, %5
%23 = add nuw nsw i64 %6, 1
%24 = tail call i32 @strlen(i8* %0)
%25 = zext i32 %24 to i64
%26 = icmp ult i64 %23, %25
br i1 %26, label %5, label %29
27: ; preds = %15
%28 = trunc i64 %6 to i32
br label %29
29: ; preds = %22, %27, %2
%30 = phi i32 [ -1, %2 ], [ %28, %27 ], [ -1, %22 ]
ret i32 %30
}