#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 find(char *, char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char haystack[400], needle;
  int counter, helper = -1, lenght;
  scanf("%[^\n]s", haystack);
  scanf(" %c", &needle);
  lenght = strlen(haystack);
  for (counter = 0; counter < lenght; counter++) {
    if (find(&haystack[counter], needle) == 1) {
      helper = counter;
      break;
    }
  }
  printf("%d", helper);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x1ac(%rbp)
ff ff ff
lea    -0x1a0(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1060 <scanf@plt>
lea    0xe91(%rip),%rdi
lea    -0x1a1(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1b0(%rbp)
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1b0(%rbp),%eax
jge    1200 <main+0xc0>
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rdi
add    %rax,%rdi
movsbl -0x1a1(%rbp),%esi
call   1050 <find@plt>
cmp    $0x1,%eax
jne    11e7 <main+0xa7>
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
jmp    1200 <main+0xc0>
jmp    11ec <main+0xac>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    119e <main+0x5e>
mov    -0x1ac(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xeae(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xea1(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
jle    11b5 <main+0x75>
mov    %eax,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
movsbl 0xf(%rsp),%esi
call   1050 <find@plt>
cmp    $0x1,%eax
je     11b2 <main+0x72>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <main+0x50>
jmp    11b5 <main+0x75>
mov    %ebx,%r14d
lea    0xe4f(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [3 x i8] c"%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 -1, i32* %5
%7 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
store i32 0, i32* %4
br label %12
12: ; preds = %26, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %3
%21 = call i32 @find(i8* %19, i8 signext %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = load i32, i32* %4
store i32 %24, i32* %5
br label %29
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %12
29: ; preds = %23, %12
%30 = load i32, i32* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [3 x i8] c"%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 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 @strlen(i8* %3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %16
%11 = phi i64 [ 0, %8 ], [ %17, %16 ]
%12 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %2
%14 = call i32 @find(i8* %12, i8 signext %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %21, label %10
19: ; preds = %10
%20 = trunc i64 %11 to i32
br label %21
21: ; preds = %16, %19, %0
%22 = phi i32 [ -1, %0 ], [ %20, %19 ], [ -1, %16 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}