#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t;
  char buffer[100001];
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    char *follower = &buffer[0];
    char *leader = &buffer[1];
    int deletions = 0;
    scanf("%s", buffer);
    while (*leader != 0) {
      if (*leader++ == *follower++) {
        deletions++;
      }
    }
    printf("%d\n", deletions);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x186b4(%rbp)
mov    -0x186b4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1221 <main+0x101>
lea    -0x186b0(%rbp),%rax
mov    %rax,-0x186c0(%rbp)
lea    -0x186b0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x186c8(%rbp)
movl   $0x0,-0x186cc(%rbp)
lea    -0x186b0(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x186c8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fb <main+0xdb>
mov    -0x186c8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x186c8(%rbp)
movsbl (%rax),%eax
mov    -0x186c0(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x186c0(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11f6 <main+0xd6>
mov    -0x186cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186cc(%rbp)
jmp    119c <main+0x7c>
mov    -0x186cc(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x186b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186b4(%rbp)
jmp    114e <main+0x2e>
xor    %eax,%eax
add    $0x186d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186b8,%rsp
lea    0xec8(%rip),%rdi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11b7 <main+0x97>
lea    0x12(%rsp),%r13
lea    0xeaa(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xea1(%rip),%r12
jmp    1183 <main+0x63>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jge    11b7 <main+0x97>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x11(%rsp),%al
test   %al,%al
je     1170 <main+0x50>
xor    %ebp,%ebp
mov    %r13,%rcx
nop
xor    %edx,%edx
cmp    -0x2(%rcx),%al
sete   %dl
add    %edx,%ebp
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    11a0 <main+0x80>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x186b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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