#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, char);
scalar_t__ scanf(char *, char *);
int main(int argc, char **argv) {
  char c;
  char last = 0;
  int counter = 0;
  while (scanf("%c", &c) != EOF) {
    if (c == 74) {
      c = 73;
    }
    if (last == c && last != 0) {
      counter++;
      printf("%c", 'X');
    }
    last = c;
    printf("%c", c);
    counter++;
  }
  if (counter % 2 != 0) {
    printf("%c", 'X');
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x12(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeb8(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e90(%rip),%rcx
cmp    (%rcx),%rax
je     11cd <main+0xad>
movsbl -0x11(%rbp),%eax
cmp    $0x4a,%eax
jne    1172 <main+0x52>
movb   $0x49,-0x11(%rbp)
movsbl -0x12(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    11a9 <main+0x89>
movsbl -0x12(%rbp),%eax
cmp    $0x0,%eax
je     11a9 <main+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    0xe61(%rip),%rdi
mov    $0x58,%esi
call   1030 <printf@plt>
mov    -0x11(%rbp),%al
mov    %al,-0x12(%rbp)
lea    0xe4a(%rip),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1141 <main+0x21>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f2 <main+0xd2>
lea    0xe18(%rip),%rdi
mov    $0x58,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2ea4(%rip),%r15
cmp    (%r15),%rax
je     11c7 <main+0xa7>
xor    %ebp,%ebp
lea    0xeae(%rip),%r12
lea    0xf(%rsp),%r14
xor    %ecx,%ecx
jmp    1180 <main+0x60>
nopl   0x0(%rax,%rax,1)
movsbl %bl,%esi
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    %ebx,%ecx
cmp    (%r15),%rax
je     11b0 <main+0x90>
movzbl 0xf(%rsp),%ebx
cmp    $0x4a,%bl
jne    1191 <main+0x71>
movb   $0x49,0xf(%rsp)
mov    $0x49,%bl
test   %cl,%cl
je     1160 <main+0x40>
cmp    %bl,%cl
jne    1160 <main+0x40>
add    $0x1,%ebp
mov    %r12,%rdi
mov    $0x58,%esi
call   1030 <printf@plt>
movzbl 0xf(%rsp),%ebx
jmp    1160 <main+0x40>
test   $0x1,%bpl
je     11c7 <main+0xa7>
lea    0xe43(%rip),%rdi
mov    $0x58,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %35, label %7
7: ; preds = %2, %22
%8 = phi i32 [ %26, %22 ], [ 0, %2 ]
%9 = phi i8 [ %23, %22 ], [ 0, %2 ]
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 74
br i1 %11, label %12, label %13
12: ; preds = %7
store i8 73, i8* %3
br label %13
13: ; preds = %12, %7
%14 = phi i8 [ 73, %12 ], [ %10, %7 ]
%15 = icmp eq i8 %9, %14
%16 = icmp ne i8 %9, 0
%17 = and i1 %16, %15
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = add nsw i32 %8, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 88)
%21 = load i8, i8* %3
br label %22
22: ; preds = %18, %13
%23 = phi i8 [ %21, %18 ], [ %14, %13 ]
%24 = phi i32 [ %19, %18 ], [ %8, %13 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%26 = add nsw i32 %24, 1
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %7
30: ; preds = %22
%31 = and i32 %26, 1
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 88)
br label %35
35: ; preds = %2, %33, %30
ret i32 0
}