#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 */
int /*<<< orphan*/ printf(char *);
char const *strpbrk(char const *, char *);
int test_strpbrk(void) {
  const char *str = "hello, world!";
  printf("\tstrpbrk");
  if (strpbrk(str, "l") != &str[2])
    return 1;
  else
    printf(".");
  if (strpbrk(str, "w!") != &str[7])
    return 1;
  else
    printf(".");
  if (strpbrk(str, "!w") != &str[7])
    return 1;
  else
    printf(".");
  printf(" passed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_strpbrk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1040 <strpbrk@plt>
mov    -0x10(%rbp),%rcx
add    $0x2,%rcx
cmp    %rcx,%rax
je     116c <test_strpbrk+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    11fd <test_strpbrk+0xdd>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <strpbrk@plt>
mov    -0x10(%rbp),%rcx
add    $0x7,%rcx
cmp    %rcx,%rax
je     11a5 <test_strpbrk+0x85>
movl   $0x1,-0x4(%rbp)
jmp    11fd <test_strpbrk+0xdd>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1040 <strpbrk@plt>
mov    -0x10(%rbp),%rcx
add    $0x7,%rcx
cmp    %rcx,%rax
je     11de <test_strpbrk+0xbe>
movl   $0x1,-0x4(%rbp)
jmp    11fd <test_strpbrk+0xdd>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strpbrk>:
push   %rax
lea    0xec8(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"hello, world!\00"
@.str.1 = [9 x i8] c"\09strpbrk\00"
@.str.2 = [2 x i8] c"l\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"w!\00"
@.str.5 = [3 x i8] c"!w\00"
@.str.6 = [10 x i8] c" passed.\0A\00"
define i32 @test_strpbrk() {
%1 = alloca i32
%2 = alloca i8*
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%4 = load i8*, i8** %2
%5 = call i8* @strpbrk(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 2
%8 = icmp ne i8* %5, %7
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %32
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10
%13 = load i8*, i8** %2
%14 = call i8* @strpbrk(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 7
%17 = icmp ne i8* %14, %16
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 1, i32* %1
br label %32
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19
%22 = load i8*, i8** %2
%23 = call i8* @strpbrk(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 7
%26 = icmp ne i8* %23, %25
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 1, i32* %1
br label %32
28: ; preds = %21
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %32
32: ; preds = %30, %27, %18, %9
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"\09strpbrk\00"
@str = [9 x i8] c" passed.\00"
define i32 @test_strpbrk() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @putchar(i32 46)
%3 = tail call i32 @putchar(i32 46)
%4 = tail call i32 @putchar(i32 46)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}