#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*/ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
int main() {
  char *haystack;
  size_t len = 0;
  getline(&haystack, &len, stdin);
  char needle;
  scanf("%c", &needle);
  char *result = find(haystack, needle);
  printf("%d", (int)strlen(result) - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <getline@plt>
lea    0xe7c(%rip),%rdi
lea    -0x19(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1050 <find@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
sub    $0x1,%esi
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <getline@plt>
lea    0xe84(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x10(%rsp),%rdi
movsbl 0x7(%rsp),%esi
call   1050 <find@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    -0x1(%rax),%esi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8
%5 = alloca i8*
store i32 0, i32* %1
store i64 0, i64* %3
%6 = load i32, i32* @stdin
%7 = call i32 @getline(i8** %2, i64* %3, i32 %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = load i8*, i8** %2
%10 = load i8, i8* %4
%11 = call i8* @find(i8* %9, i8 signext %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
%15 = sub nsw i32 %14, 1
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8
%4 = bitcast i8** %1 to i8*
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%6 = load i32, i32* @stdin
%7 = call i32 @getline(i8** %1, i64* %2, i32 %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%9 = load i8*, i8** %1
%10 = load i8, i8* %3
%11 = call i8* @find(i8* %9, i8 signext %10)
%12 = call i64 @strlen(i8* dereferenceable(1) %11)
%13 = trunc i64 %12 to i32
%14 = add nsw i32 %13, -1
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
}