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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x10(%rbp)
lea    -0x1a0(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1060 <scanf@plt>
lea    0xe94(%rip),%rdi
lea    -0x1a1(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e3 <main+0xa3>
movslq -0x8(%rbp),%rax
lea    -0x1a0(%rbp),%rdi
add    %rax,%rdi
movsbl -0x1a1(%rbp),%esi
call   1050 <find@plt>
cmp    $0x0,%rax
je     11d0 <main+0x90>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11e3 <main+0xa3>
jmp    11d5 <main+0x95>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x55>
mov    -0x10(%rbp),%esi
lea    0xe1e(%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>
test   %rax,%rax
jne    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 i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [400 x i8]
%6 = alloca i8
store i32 0, i32* %1
store i32 -1, i32* %4
%7 = getelementptr inbounds [400 x i8], [400 x i8]* %5, 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* %6)
%10 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %3
store i32 0, i32* %2
br label %12
12: ; preds = %26, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [400 x i8], [400 x i8]* %5, i64 0, i64 %18
%20 = load i8, i8* %6
%21 = call i64 @find(i8* %19, i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = load i32, i32* %2
store i32 %24, i32* %4
br label %29
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %12
29: ; preds = %23, %12
%30 = load i32, i32* %4
%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 i64 @find(i8* %12, i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
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
}