#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 *find(char *, char);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int *result, i = 0, length;
  char str[400];
  char c;
  while (c != '\n') {
    if (c != '\n') {
      c = getchar();
      str[i] = c;
      i++;
    }
  }
  scanf("%c", &c);
  result = find(str, c);
  length = strlen(str);
  if (result == NULL) {
    printf("-1");
  } else {
    int p;
    for (p = 0; p < length; p++) {
      if (result == &str[p]) {
        printf("%d", p);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movsbl -0x1b1(%rbp),%eax
cmp    $0xa,%eax
je     11b5 <main+0x65>
movsbl -0x1b1(%rbp),%eax
cmp    $0xa,%eax
je     11b0 <main+0x60>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1b1(%rbp)
mov    -0x1b1(%rbp),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1b0(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <main+0x19>
lea    0xe44(%rip),%rdi
lea    -0x1b1(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x1b0(%rbp),%rdi
movsbl -0x1b1(%rbp),%esi
call   1060 <find@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1b0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    120c <main+0xbc>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1275 <main+0x125>
movl   $0x0,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1270 <main+0x120>
mov    -0x10(%rbp),%rax
movslq -0x1b8(%rbp),%rdx
lea    -0x1b0(%rbp),%rcx
add    %rdx,%rcx
cmp    %rcx,%rax
jne    1257 <main+0x107>
mov    -0x1b8(%rbp),%esi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <main+0x10c>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    1216 <main+0xc6>
jmp    1275 <main+0x125>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    $0xa,%al
jne    1170 <main+0x20>
movb   $0xa,0xf(%rsp)
lea    0xe73(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
movsbl 0xf(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <find@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %r15,%r15
je     11f4 <main+0xa4>
test   %eax,%eax
jle    1202 <main+0xb2>
mov    %eax,%r12d
lea    0xe3f(%rip),%r14
xor    %ebx,%ebx
jmp    11d9 <main+0x89>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1202 <main+0xb2>
lea    (%rsp,%rbx,1),%rax
add    $0x10,%rax
cmp    %r15,%rax
jne    11d0 <main+0x80>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d0 <main+0x80>
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"-1\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
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %8, %4 ]
%6 = tail call signext i8 (...) @getchar()
%7 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %5
store i8 %6, i8* %7
%8 = add nuw i64 %5, 1
%9 = icmp eq i8 %6, 10
br i1 %9, label %10, label %4
10: ; preds = %4
store i8 10, i8* %2
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
%13 = call i32* @find(i8* %3, i8 signext %12)
%14 = call i32 @strlen(i8* %3)
%15 = icmp eq i32* %13, null
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = icmp sgt i32 %14, 0
br i1 %17, label %18, label %33
18: ; preds = %16
%19 = zext i32 %14 to i64
br label %22
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %33
22: ; preds = %18, %30
%23 = phi i64 [ 0, %18 ], [ %31, %30 ]
%24 = getelementptr inbounds [400 x i8], [400 x i8]* %1, i64 0, i64 %23
%25 = bitcast i8* %24 to i32*
%26 = icmp eq i32* %13, %25
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = trunc i64 %23 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %22, %27
%31 = add nuw nsw i64 %23, 1
%32 = icmp eq i64 %31, %19
br i1 %32, label %33, label %22
33: ; preds = %30, %16, %20
ret i32 0
}