#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 *);
int strcspn(char const *, char *);
int test_strcspn(void) {
  const char *str = "aabbcc";
  printf("\tstrcspn");
  if (strcspn(str, "bc") != 2)
    return 1;
  else
    printf(".");
  if (strcspn(str, "c") != 4)
    return 1;
  else
    printf(".");
  if (strcspn(str, "d") != 6)
    return 1;
  else
    printf(".");
  printf(" passed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_strcspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1040 <strcspn@plt>
cmp    $0x2,%eax
je     1164 <test_strcspn+0x44>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <test_strcspn+0xc5>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strcspn@plt>
cmp    $0x4,%eax
je     1195 <test_strcspn+0x75>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <test_strcspn+0xc5>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1040 <strcspn@plt>
cmp    $0x6,%eax
je     11c6 <test_strcspn+0xa6>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <test_strcspn+0xc5>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
lea    0xe3e(%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_strcspn>:
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 = [7 x i8] c"aabbcc\00"
@.str.1 = [9 x i8] c"\09strcspn\00"
@.str.2 = [3 x i8] c"bc\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"c\00"
@.str.5 = [2 x i8] c"d\00"
@.str.6 = [10 x i8] c" passed.\0A\00"
define i32 @test_strcspn() {
%1 = alloca i32
%2 = alloca i8*
store i8* getelementptr inbounds ([7 x i8], [7 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 i32 @strcspn(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp ne i32 %5, 2
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 1, i32* %1
br label %26
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %8
%11 = load i8*, i8** %2
%12 = call i32 @strcspn(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp ne i32 %12, 4
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %1
br label %26
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15
%18 = load i8*, i8** %2
%19 = call i32 @strcspn(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp ne i32 %19, 6
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 1, i32* %1
br label %26
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22
%25 = 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 %26
26: ; preds = %24, %21, %14, %7
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"\09strcspn\00"
@str = [9 x i8] c" passed.\00"
define i32 @test_strcspn() {
%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
}