#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);
char getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  char c, line[400];
  int i = 0;
  int res;
  char *found;
  while ((c = getchar()) != '\n') {
    line[i++] = c;
  }
  line[i] = '\0';
  found = find(line, getchar());
  if (!found) {
    res = -1;
  }
  for (i = 0; line[i] != '\0'; ++i) {
    if (&line[i] == found) {
      res = i;
    }
  }
  printf("\n%d\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1184 <main+0x54>
mov    -0x5(%rbp),%cl
mov    -0x1a4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1a4(%rbp)
cltq
mov    %cl,-0x1a0(%rbp,%rax,1)
jmp    114c <main+0x1c>
movslq -0x1a4(%rbp),%rax
movb   $0x0,-0x1a0(%rbp,%rax,1)
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x1b8(%rbp),%rdi
movsbl %al,%esi
call   1050 <find@plt>
mov    %rax,-0x1b0(%rbp)
cmpq   $0x0,-0x1b0(%rbp)
jne    11d6 <main+0xa6>
movl   $0xffffffff,-0x1a8(%rbp)
ff ff ff
movl   $0x0,-0x1a4(%rbp)
movslq -0x1a4(%rbp),%rax
movsbl -0x1a0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     123b <main+0x10b>
movslq -0x1a4(%rbp),%rcx
lea    -0x1a0(%rbp),%rax
add    %rcx,%rax
cmp    -0x1b0(%rbp),%rax
jne    1222 <main+0xf2>
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
jmp    1227 <main+0xf7>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11e0 <main+0xb0>
mov    -0x1a8(%rbp),%esi
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x190,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1164 <main+0x34>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1150 <main+0x20>
mov    %ebx,%ebx
movb   $0x0,(%rsp,%rbx,1)
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl %al,%esi
mov    %rsp,%rdi
call   1050 <find@plt>
cmpb   $0x0,(%rsp)
je     11a7 <main+0x77>
mov    $0xffffffff,%esi
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
lea    (%rsp,%rcx,1),%rdx
cmp    %rax,%rdx
cmove  %ecx,%esi
cmpb   $0x0,0x1(%rsp,%rcx,1)
lea    0x1(%rcx),%rcx
jne    1190 <main+0x60>
jmp    11ac <main+0x7c>
mov    $0xffffffff,%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\0A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [400 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %4
br label %7
7: ; preds = %11, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i8, i8* %2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %15
store i8 %12, i8* %16
br label %7
17: ; preds = %7
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 0
%22 = call signext i8 (...) @getchar()
%23 = call i8* @find(i8* %21, i8 signext %22)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %17
store i32 -1, i32* %5
br label %27
27: ; preds = %26, %17
store i32 0, i32* %4
br label %28
28: ; preds = %44, %27
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %47
35: ; preds = %28
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [400 x i8], [400 x i8]* %3, i64 0, i64 %37
%39 = load i8*, i8** %6
%40 = icmp eq i8* %38, %39
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = load i32, i32* %4
store i32 %42, i32* %5
br label %43
43: ; preds = %41, %35
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %28
47: ; preds = %28
%48 = load i32, i32* %5
%49 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"\0A%d\0A\00"
define i32 @main() {
%1 = alloca [400 x i8]
%2 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 0
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %14, label %5
5: ; preds = %0, %5
%6 = phi i64 [ %8, %5 ], [ 0, %0 ]
%7 = phi i8 [ %10, %5 ], [ %3, %0 ]
%8 = add nuw i64 %6, 1
%9 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %6
store i8 %7, i8* %9
%10 = tail call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = and i64 %8, 4294967295
br label %14
14: ; preds = %12, %0
%15 = phi i64 [ 0, %0 ], [ %13, %12 ]
%16 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %15
store i8 0, i8* %16
%17 = tail call signext i8 (...) @getchar()
%18 = call i8* @find(i8* %2, i8 signext %17)
%19 = load i8, i8* %2
%20 = icmp eq i8 %19, 0
br i1 %20, label %32, label %21
21: ; preds = %14, %21
%22 = phi i64 [ %28, %21 ], [ 0, %14 ]
%23 = phi i8* [ %29, %21 ], [ %2, %14 ]
%24 = phi i32 [ %27, %21 ], [ -1, %14 ]
%25 = icmp eq i8* %23, %18
%26 = trunc i64 %22 to i32
%27 = select i1 %25, i32 %26, i32 %24
%28 = add nuw nsw i64 %22, 1
%29 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %21
32: ; preds = %21, %14
%33 = phi i32 [ -1, %14 ], [ %27, %21 ]
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %33)
ret i32 0
}