#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 */
char *find(char *, char);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char haystack[400], needle;
  char *i = 0;
  scanf("%[^\n]s", haystack);
  getchar();
  scanf("%c", &needle);
  if (find(haystack, needle) == NULL) {
    printf("-1\n");
  } else {
    i = find(haystack, needle);
    printf("%d\n", (int)(i - haystack));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x1b0(%rbp)
lea    -0x1a0(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xe89(%rip),%rdi
lea    -0x1a1(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
movsbl -0x1a1(%rbp),%esi
call   1050 <find@plt>
cmp    $0x0,%rax
jne    11ba <main+0x7a>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <main+0xb5>
lea    -0x1a0(%rbp),%rdi
movsbl -0x1a1(%rbp),%esi
call   1050 <find@plt>
mov    %rax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rax
lea    -0x1a0(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1a0,%rsp
lea    0xea1(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xe8d(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
movsbl 0xf(%rsp),%esi
mov    %rbx,%rdi
call   1060 <find@plt>
test   %rax,%rax
je     11bc <main+0x6c>
movsbl 0xf(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <find@plt>
sub    %ebx,%eax
lea    0xe59(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c8 <main+0x78>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"-1\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [400 x i8]
%3 = alloca i8
%4 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %4
%5 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i32 (...) @getchar()
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%9 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%10 = load i8, i8* %3
%11 = call i8* @find(i8* %9, i8 signext %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %26
15: ; preds = %0
%16 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%17 = load i8, i8* %3
%18 = call i8* @find(i8* %16, i8 signext %17)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [400 x i8], [400 x i8]* %2, i64 0, i64 0
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %15, %13
ret i32 0
}

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