#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
size_t strcspn(char *, char *);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  char buf1[80], buf2[80];
  size_t loc;
  printf("Enter the string to be searched: ");
  gets(buf1);
  printf("Enter the string containing target characters: ");
  gets(buf2);
  loc = strcspn(buf1, buf2);
  if (loc == strlen(buf1))
    printf("No match was found.");
  else
    printf("The first match was found at position %d.\n", loc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1060 <gets@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xb0(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1050 <strcspn@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
cmp    %rcx,%rax
jne    11de <main+0x9e>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f3 <main+0xb3>
mov    -0xb8(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x50(%rsp),%r14
mov    %r14,%rdi
call   1060 <gets@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcspn@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jne    11a9 <main+0x69>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ba <main+0x7a>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter the string to be searched: \00"
@.str.1 = [48 x i8] c"Enter the string containing target characters: \00"
@.str.2 = [20 x i8] c"No match was found.\00"
@.str.3 = [43 x i8] c"The first match was found at position %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%14 = call i32 @gets(i8* %13)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%17 = call i64 @strcspn(i8* %15, i8* %16)
store i64 %17, i64* %8
%18 = load i64, i64* %8
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = icmp eq i64 %18, %20
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %27
24: ; preds = %2
%25 = load i64, i64* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i64 %25)
br label %27
27: ; preds = %24, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter the string to be searched: \00"
@.str.1 = [48 x i8] c"Enter the string containing target characters: \00"
@.str.2 = [20 x i8] c"No match was found.\00"
@.str.3 = [43 x i8] c"The first match was found at position %d.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @gets(i8* %6)
%11 = call i64 @strcspn(i8* %5, i8* %6)
%12 = call i64 @strlen(i8* %5)
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i64 %11)
br label %18
18: ; preds = %16, %14
ret i32 0
}