#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*/ getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char letra, letra2;
  char str1[51];
  int i = 0;
  int pos = 0;
  int comprimento = 0;
  int qtd = 0;
  while (1) {
    scanf("%c", &letra);
    getchar();
    if (letra == '0') {
      break;
    }
    gets(str1);
    comprimento = strlen(str1);
    for (i = 0; i < comprimento; i++) {
      letra2 = str1[i];
      if (letra == letra2) {
        pos = i + 1;
        qtd += 1;
        printf("%d ", pos);
      }
    }
    printf("%d\n", qtd);
    qtd = 0;
    pos = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
lea    0xe7e(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jne    11a4 <main+0x54>
jmp    123d <main+0xed>
lea    -0x40(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    121b <main+0xcb>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0x6(%rbp)
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jne    1208 <main+0xb8>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x48(%rbp),%esi
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
jmp    120d <main+0xbd>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c0 <main+0x70>
mov    -0x50(%rbp),%esi
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x48(%rbp)
jmp    117b <main+0x2b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe9b(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmpb   $0x30,0xf(%rsp)
jne    118e <main+0x3e>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r14
lea    0xe69(%rip),%rbx
lea    0xf(%rsp),%r13
jmp    11db <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe50(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmpb   $0x30,0xf(%rsp)
je     117d <main+0x2d>
mov    %r14,%rdi
call   1060 <gets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x0,%ebp
test   %eax,%eax
jle    11b0 <main+0x60>
mov    %eax,%r15d
xor    %esi,%esi
xor    %ebp,%ebp
jmp    1208 <main+0xb8>
nopl   (%rax)
mov    %r12,%rsi
cmp    %r12,%r15
je     11b0 <main+0x60>
movzbl 0xf(%rsp),%eax
lea    0x1(%rsi),%r12
cmp    0x10(%rsp,%rsi,1),%al
jne    1200 <main+0xb0>
add    $0x1,%ebp
add    $0x1,%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
jmp    1200 <main+0xb0>

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

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