#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  unsigned int rm_so;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ REG_EXTENDED;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ regexec(int /*<<< orphan*/ *, char *, size_t, TYPE_1__ *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
scalar_t__ scanf(char *, char *, unsigned int *);
int main(void) {
  unsigned int offset, len;
  char source[90], *regexString = "([a-z]+)\\1$";
  size_t maxMatches = 1, maxGroups = 2;
  regex_t regexCompiled;
  regmatch_t groupArray[maxGroups];
  regcomp(&regexCompiled, regexString, REG_EXTENDED);
  while (scanf("%s%n\n", source, &len) != EOF) {
    source[len] = 0;
    if (!regexec(&regexCompiled, source, maxGroups, groupArray, 0)) {
      offset = groupArray[0].rm_so;
      source[offset + (len - offset) / 2] = 0;
    }
    printf("%s\n", source);
  }
  regfree(&regexCompiled);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x78(%rbp)
movq   $0x1,-0x80(%rbp)
movq   $0x2,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x98(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xa0(%rbp)
mov    -0x78(%rbp),%rsi
mov    0x2e19(%rip),%rax
mov    (%rax),%edx
lea    -0x8c(%rbp),%rdi
call   1050 <regcomp@plt>
lea    -0x70(%rbp),%rsi
lea    0xe34(%rip),%rdi
lea    -0xc(%rbp),%rdx
call   1070 <scanf@plt>
mov    0x2e00(%rip),%rcx
cmp    (%rcx),%rax
je     1259 <main+0x109>
mov    -0xa8(%rbp),%rcx
mov    -0xc(%rbp),%eax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
mov    -0x88(%rbp),%rdx
lea    -0x8c(%rbp),%rdi
xor    %r8d,%r8d
call   1060 <regexec@plt>
cmp    $0x0,%eax
jne    1244 <main+0xf4>
mov    -0xa8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
shr    $0x1,%ecx
add    %ecx,%eax
mov    %eax,%eax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xdc3(%rip),%rdi
call   1040 <printf@plt>
jmp    11cd <main+0x7d>
lea    -0x8c(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsp,0x18(%rsp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
lea    0xe8a(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1050 <regcomp@plt>
lea    0xe85(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1070 <scanf@plt>
mov    0x2e4b(%rip),%r14
cmp    (%r14),%rax
jne    11c5 <main+0x75>
lea    0xc(%rsp),%rdi
call   1030 <regfree@plt>
mov    0x18(%rsp),%rsp
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rbx
lea    0x10(%rsp),%r15
lea    0xe3c(%rip),%r12
lea    0xe2f(%rip),%r13
lea    0x8(%rsp),%rbp
jmp    120e <main+0xbe>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <scanf@plt>
cmp    (%r14),%rax
je     11a2 <main+0x52>
mov    0x8(%rsp),%eax
movb   $0x0,0x20(%rsp,%rax,1)
mov    $0x2,%edx
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15,%rcx
xor    %r8d,%r8d
call   1060 <regexec@plt>
test   %eax,%eax
jne    11f0 <main+0xa0>
mov    0x10(%rsp),%eax
mov    0x8(%rsp),%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
movb   $0x0,0x20(%rsp,%rcx,1)
jmp    11f0 <main+0xa0>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@.str = [12 x i8] c"([a-z]+)\\1$\00"
@REG_EXTENDED = global i32 0
@.str.1 = [6 x i8] c"%s%n\0A\00"
@EOF = global i64 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [90 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %5
store i64 1, i64* %6
store i64 2, i64* %7
%11 = load i64, i64* %7
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %9
%13 = alloca %struct.TYPE_3__, i64 %11
store i64 %11, i64* %10
%14 = load i8*, i8** %5
%15 = load i32, i32* @REG_EXTENDED
%16 = call i32 @regcomp(i32* %8, i8* %14, i32 %15)
br label %17
17: ; preds = %42, %0
%18 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 0
%19 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32* %3)
%20 = load i64, i64* @EOF
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %45
22: ; preds = %17
%23 = load i32, i32* %3
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 0
%27 = load i64, i64* %7
%28 = call i32 @regexec(i32* %8, i8* %26, i64 %27, %struct.TYPE_3__* %13, i32 0)
%29 = icmp ne i32 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %22
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i64 0
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %31, i32 0, i32 0
%33 = load i32, i32* %32
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = sub i32 %35, %36
%38 = udiv i32 %37, 2
%39 = add i32 %34, %38
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 %40
store i8 0, i8* %41
br label %42
42: ; preds = %30, %22
%43 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 0
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %17
45: ; preds = %17
%46 = call i32 @regfree(i32* %8)
store i32 0, i32* %1
%47 = load i8*, i8** %9
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@.str = [12 x i8] c"([a-z]+)\\1$\00"
@REG_EXTENDED = global i32 0
@.str.1 = [6 x i8] c"%s%n\0A\00"
@EOF = global i64 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [90 x i8]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i8* @llvm.stacksave()
%8 = alloca [2 x %struct.TYPE_3__]
%9 = getelementptr inbounds [2 x %struct.TYPE_3__], [2 x %struct.TYPE_3__]* %8, i64 0, i64 0
%10 = load i32, i32* @REG_EXTENDED
%11 = call i32 @regcomp(i32* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32* %1)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %36, label %15
15: ; preds = %0
%16 = getelementptr inbounds [2 x %struct.TYPE_3__], [2 x %struct.TYPE_3__]* %8, i64 0, i64 0, i32 0
br label %17
17: ; preds = %15, %31
%18 = load i32, i32* %1
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 @regexec(i32* %3, i8* %5, i64 2, %struct.TYPE_3__* %9, i32 0)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %17
%24 = load i32, i32* %16
%25 = load i32, i32* %1
%26 = sub i32 %25, %24
%27 = lshr i32 %26, 1
%28 = add i32 %27, %24
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %23, %17
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%33 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32* %1)
%34 = load i64, i64* @EOF
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %17
36: ; preds = %31, %0
%37 = call i32 @regfree(i32* %3)
ret i32 0
}