#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() {
  char haystack[400], needle;
  int counter = 0, result = -1, length;
  scanf("%[^\n]s", haystack);
  scanf("\n%c", &needle);
  length = strlen(haystack);
  do {
    if (find(&haystack[counter], needle)) {
      result = counter;
      break;
    }
    counter++;
  } while (counter < length);
  printf("%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   $0xffffffff,-0x1ac(%rbp)
ff ff ff
lea    -0x1a0(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1060 <scanf@plt>
lea    0xe87(%rip),%rdi
lea    -0x1a1(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1b0(%rbp)
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rdi
add    %rax,%rdi
movsbl -0x1a1(%rbp),%esi
call   1050 <find@plt>
cmp    $0x0,%rax
je     11d6 <main+0x96>
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
jmp    11f7 <main+0xb7>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1b0(%rbp),%eax
jl     119e <main+0x5e>
mov    -0x1ac(%rbp),%esi
lea    0xe07(%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
lea    0xeaf(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xea2(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
mov    $0x1,%r14d
cmovge %eax,%r14d
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    11b5 <main+0x75>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1190 <main+0x50>
mov    $0xffffffff,%ebx
lea    0xe4f(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

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

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