#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*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ find(char *, char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char haystack[400], needle;
  int i = 0, result = 0, j;
  fgets(haystack, 400, stdin);
  scanf("%c", &needle);
  i = strlen(haystack);
  for (j = 0; j <= i; j++) {
    if (find(&haystack[j], needle)) {
      result = j;
      break;
    }
  }
  printf("\n %d", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a8(%rbp)
movl   $0x0,-0x1ac(%rbp)
lea    -0x1a0(%rbp),%rdi
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
mov    $0x190,%esi
call   1050 <fgets@plt>
lea    0xe69(%rip),%rdi
lea    -0x1a1(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1a8(%rbp)
movl   $0x0,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jg     1222 <main+0xd2>
movslq -0x1b0(%rbp),%rax
lea    -0x1a0(%rbp),%rdi
add    %rax,%rdi
movsbl -0x1a1(%rbp),%esi
call   1060 <find@plt>
cmp    $0x0,%rax
je     1209 <main+0xb9>
mov    -0x1b0(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
jmp    1222 <main+0xd2>
jmp    120e <main+0xbe>
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
jmp    11bf <main+0x6f>
mov    -0x1ac(%rbp),%esi
lea    0xdd4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x190,%esi
call   1050 <fgets@plt>
lea    0xe84(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     11c0 <main+0x70>
mov    %eax,%r14d
add    $0x1,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
movsbl 0xf(%rsp),%esi
call   1060 <find@plt>
test   %rax,%rax
jne    11c2 <main+0x72>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11a0 <main+0x50>
xor    %ebx,%ebx
lea    0xe3a(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"\0A %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [400 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%7 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 400, i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %4
store i32 0, i32* %6
br label %13
13: ; preds = %27, %0
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %3
%22 = call i64 @find(i8* %20, i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = load i32, i32* %6
store i32 %25, i32* %5
br label %30
26: ; preds = %17
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %13
30: ; preds = %24, %13
%31 = load i32, i32* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"\0A %d\00"
define i32 @main() {
%1 = alloca [400 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 400, i32 %4)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i32 @strlen(i8* %3)
%8 = icmp slt i32 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %0
%10 = add nuw i32 %7, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %9, %18
%13 = phi i64 [ 0, %9 ], [ %19, %18 ]
%14 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %2
%16 = call i64 @find(i8* %14, i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %23, label %12
21: ; preds = %12
%22 = trunc i64 %13 to i32
br label %23
23: ; preds = %18, %21, %0
%24 = phi i32 [ 0, %0 ], [ %22, %21 ], [ 0, %18 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}