#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*/);
char *find(char *, char);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char *result;
  char haystack[401], needle;
  fgets(haystack, 401, stdin);
  needle = getchar();
  result = find(haystack, needle);
  if (result != NULL)
    printf("%d", (int)(result - haystack));
  else
    printf("-1");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1b0(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    $0x191,%esi
call   1040 <fgets@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1b1(%rbp)
lea    -0x1b0(%rbp),%rdi
movsbl -0x1b1(%rbp),%esi
call   1060 <find@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11be <main+0x7e>
mov    -0x10(%rbp),%rax
lea    -0x1b0(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cc <main+0x8c>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1a0,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x191,%esi
call   1040 <fgets@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%esi
mov    %rbx,%rdi
call   1060 <find@plt>
test   %rax,%rax
je     118f <main+0x4f>
mov    %rsp,%rcx
sub    %ecx,%eax
lea    0xe7c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    119d <main+0x5d>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca [401 x i8]
%2 = getelementptr inbounds [401 x i8], [401 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 401, i32 %3)
%5 = call signext i8 (...) @getchar()
%6 = call i8* @find(i8* %2, i8 signext %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %0
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint [401 x i8]* %1 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
ret i32 0
}