#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 */
typedef int /*<<< orphan*/ mpf_t;

/* Variables and functions */
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ gmp_sprintf(char *, char *, int /*<<< orphan*/);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ mpf_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_init2(int /*<<< orphan*/, long);
int /*<<< orphan*/ mpf_init_set_d(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_ui_div(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
int strlen(char *);
int main(int argc, const char *argv[]) {
  mpf_t n;
  mpf_t d;
  int i;
  char s[10000];
  int offset, len;
  int slen;
  int count;
  int max = 0;
  mpf_init2(d, 19510L);
  mpf_init_set_d(n, 1);
  for (i = 0; i < 1000; i++) {
    mpf_add_ui(n, n, 1);
    mpf_ui_div(d, 1, n);
    gmp_sprintf(s, "%.Ff", d);
    slen = strlen(s);
    if (slen < 50) {
      continue;
    }
    for (offset = slen - 1; offset > slen / 3; offset--) {
      for (len = 1; len < (slen - 4) / 2 && len + offset < slen; len++) {
        count = 1;
        while (memcmp(s + offset, s + offset - (count * len), len) == 0) {
          count++;
        }
        if (count > 4) {
          if (len > max) {
            max = len;
            gmp_printf("%Ff ", n);
            printf(":%d %s\n", len, s);
          }
          goto NEXT;
        }
      }
    }
  NEXT:;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2750,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2744(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x4c36,%esi
call   10b0 <mpf_init2@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1070 <mpf_init_set_d@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    13e4 <main+0x254>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1090 <mpf_add_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    $0x1,%esi
call   1030 <mpf_ui_div@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xdee(%rip),%rsi
call   1060 <gmp_sprintf@plt>
lea    -0x2730(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x273c(%rbp)
cmpl   $0x32,-0x273c(%rbp)
jge    123b <main+0xab>
jmp    13d6 <main+0x246>
mov    -0x273c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2734(%rbp)
mov    -0x2734(%rbp),%eax
mov    %eax,-0x2748(%rbp)
mov    -0x273c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2748(%rbp),%eax
cmp    %ecx,%eax
jle    13cc <main+0x23c>
movl   $0x1,-0x2738(%rbp)
mov    -0x2738(%rbp),%ecx
mov    -0x273c(%rbp),%eax
sub    $0x4,%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x2749(%rbp)
jge    12c2 <main+0x132>
mov    -0x2738(%rbp),%eax
add    -0x2734(%rbp),%eax
cmp    -0x273c(%rbp),%eax
setl   %al
mov    %al,-0x2749(%rbp)
mov    -0x2749(%rbp),%al
test   $0x1,%al
jne    12d5 <main+0x145>
jmp    13b3 <main+0x223>
movl   $0x1,-0x2740(%rbp)
lea    -0x2730(%rbp),%rdi
movslq -0x2734(%rbp),%rax
add    %rax,%rdi
lea    -0x2730(%rbp),%rsi
movslq -0x2734(%rbp),%rax
add    %rax,%rsi
mov    -0x2740(%rbp),%eax
imul   -0x2738(%rbp),%eax
movslq %eax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rsi
mov    -0x2738(%rbp),%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
jne    1342 <main+0x1b2>
mov    -0x2740(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2740(%rbp)
jmp    12df <main+0x14f>
cmpl   $0x4,-0x2740(%rbp)
jle    139a <main+0x20a>
mov    -0x2738(%rbp),%eax
cmp    -0x2744(%rbp),%eax
jle    1395 <main+0x205>
mov    -0x2738(%rbp),%eax
mov    %eax,-0x2744(%rbp)
mov    -0x14(%rbp),%esi
lea    0xc8e(%rip),%rdi
call   10a0 <gmp_printf@plt>
mov    -0x2738(%rbp),%esi
lea    -0x2730(%rbp),%rdx
lea    0xc7a(%rip),%rdi
call   1050 <printf@plt>
jmp    13d1 <main+0x241>
jmp    139f <main+0x20f>
mov    -0x2738(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2738(%rbp)
jmp    127e <main+0xee>
jmp    13b8 <main+0x228>
mov    -0x2734(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2734(%rbp)
jmp    124a <main+0xba>
jmp    13d1 <main+0x241>
jmp    13d6 <main+0x246>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d4 <main+0x44>
xor    %eax,%eax
add    $0x2750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2758,%rsp
mov    $0x4c36,%esi
call   10b0 <mpf_init2@plt>
mov    $0x1,%esi
call   1070 <mpf_init_set_d@plt>
movl   $0x0,0x8(%rsp)
lea    0xe3c(%rip),%r14
lea    0x40(%rsp),%r12
mov    $0xaaaaaaab,%r15d
xor    %ebx,%ebx
jmp    11ff <main+0x6f>
lea    0xe26(%rip),%r14
lea    0x40(%rsp),%r12
mov    $0xaaaaaaab,%r15d
mov    0xc(%rsp),%ebx
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x3e8,%ebx
je     1378 <main+0x1e8>
mov    $0x1,%edx
call   1090 <mpf_add_ui@plt>
mov    $0x1,%esi
call   1030 <mpf_ui_div@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <gmp_sprintf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    $0x32,%eax
jl     11f0 <main+0x60>
mov    %eax,%edx
mov    %eax,%esi
mov    %rsi,%rax
imul   %r15,%rax
shr    $0x21,%rax
lea    -0x1(%rdx),%ecx
cmp    %eax,%ecx
jbe    11f0 <main+0x60>
mov    %ebx,0xc(%rsp)
lea    -0x4(%rdx),%ecx
shr    %ecx
mov    %rcx,0x30(%rsp)
mov    %eax,%eax
mov    %rax,0x28(%rsp)
lea    0x3e(%rsp),%rax
add    %rsi,%rax
mov    %rax,0x18(%rsp)
add    $0xffffffffffffffff,%rsi
mov    %edx,%eax
mov    %rax,0x10(%rsp)
mov    %rdx,0x38(%rsp)
jmp    129a <main+0x10a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x20(%rsp),%rsi
add    $0xffffffffffffffff,%rsi
addq   $0xffffffffffffffff,0x18(%rsp)
cmp    0x28(%rsp),%rsi
jle    11d3 <main+0x43>
mov    0x10(%rsp),%rax
mov    %rsi,0x20(%rsp)
mov    %rsi,0x10(%rsp)
cmp    %edx,%eax
jge    1280 <main+0xf0>
mov    0x20(%rsp),%rax
lea    (%rsp,%rax,1),%r15
add    $0x40,%r15
mov    $0x1,%ebp
mov    $0xffffffffffffffff,%r14
mov    0x18(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
xor    %r13d,%r13d
mov    %rbx,%r12
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1080 <memcmp@plt>
add    $0x1,%r13d
add    %r14,%r12
test   %rax,%rax
je     12e0 <main+0x150>
cmp    $0x5,%r13d
jae    1330 <main+0x1a0>
add    $0x1,%rbp
cmp    0x30(%rsp),%rbp
mov    0x38(%rsp),%rdx
jae    1280 <main+0xf0>
mov    0x10(%rsp),%rax
add    %ebp,%eax
add    $0xffffffffffffffff,%rbx
add    $0xffffffffffffffff,%r14
cmp    %edx,%eax
jl     12d0 <main+0x140>
jmp    1280 <main+0xf0>
nopl   0x0(%rax,%rax,1)
cmp    %ebp,0x8(%rsp)
lea    0xcc5(%rip),%r14
lea    0x40(%rsp),%r12
mov    $0xaaaaaaab,%r15d
mov    0xc(%rsp),%ebx
jge    11f0 <main+0x60>
lea    0xcae(%rip),%rdi
call   10a0 <gmp_printf@plt>
lea    0xca7(%rip),%rdi
mov    %ebp,%esi
mov    %r12,%rdx
call   1050 <printf@plt>
mov    %ebp,%eax
mov    %ebp,0x8(%rsp)
jmp    11f0 <main+0x60>
xor    %eax,%eax
add    $0x2758,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%.Ff\00"
@.str.1 = [5 x i8] c"%Ff \00"
@.str.2 = [8 x i8] c":%d %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [10000 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %14
%15 = load i32, i32* %7
%16 = call i32 @mpf_init2(i32 %15, i64 19510)
%17 = load i32, i32* %6
%18 = call i32 @mpf_init_set_d(i32 %17, i32 1)
store i32 0, i32* %8
br label %19
19: ; preds = %107, %2
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 1000
br i1 %21, label %22, label %110
22: ; preds = %19
%23 = load i32, i32* %6
%24 = load i32, i32* %6
%25 = call i32 @mpf_add_ui(i32 %23, i32 %24, i32 1)
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = call i32 @mpf_ui_div(i32 %26, i32 1, i32 %27)
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%30 = load i32, i32* %7
%31 = call i32 @gmp_sprintf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %12
%34 = load i32, i32* %12
%35 = icmp slt i32 %34, 50
br i1 %35, label %36, label %37
36: ; preds = %22
br label %107
37: ; preds = %22
%38 = load i32, i32* %12
%39 = sub nsw i32 %38, 1
store i32 %39, i32* %10
br label %40
40: ; preds = %102, %37
%41 = load i32, i32* %10
%42 = load i32, i32* %12
%43 = sdiv i32 %42, 3
%44 = icmp sgt i32 %41, %43
br i1 %44, label %45, label %105
45: ; preds = %40
store i32 1, i32* %11
br label %46
46: ; preds = %98, %45
%47 = load i32, i32* %11
%48 = load i32, i32* %12
%49 = sub nsw i32 %48, 4
%50 = sdiv i32 %49, 2
%51 = icmp slt i32 %47, %50
br i1 %51, label %52, label %58
52: ; preds = %46
%53 = load i32, i32* %11
%54 = load i32, i32* %10
%55 = add nsw i32 %53, %54
%56 = load i32, i32* %12
%57 = icmp slt i32 %55, %56
br label %58
58: ; preds = %52, %46
%59 = phi i1 [ false, %46 ], [ %57, %52 ]
br i1 %59, label %60, label %101
60: ; preds = %58
store i32 1, i32* %13
br label %61
61: ; preds = %79, %60
%62 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
%70 = load i32, i32* %13
%71 = load i32, i32* %11
%72 = mul nsw i32 %70, %71
%73 = sext i32 %72 to i64
%74 = sub i64 0, %73
%75 = getelementptr inbounds i8, i8* %69, i64 %74
%76 = load i32, i32* %11
%77 = call i64 @memcmp(i8* %65, i8* %75, i32 %76)
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %61
%80 = load i32, i32* %13
%81 = add nsw i32 %80, 1
store i32 %81, i32* %13
br label %61
82: ; preds = %61
%83 = load i32, i32* %13
%84 = icmp sgt i32 %83, 4
br i1 %84, label %85, label %97
85: ; preds = %82
%86 = load i32, i32* %11
%87 = load i32, i32* %14
%88 = icmp sgt i32 %86, %87
br i1 %88, label %89, label %96
89: ; preds = %85
%90 = load i32, i32* %11
store i32 %90, i32* %14
%91 = load i32, i32* %6
%92 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %11
%94 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%95 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %93, i8* %94)
br label %96
96: ; preds = %89, %85
br label %106
97: ; preds = %82
br label %98
98: ; preds = %97
%99 = load i32, i32* %11
%100 = add nsw i32 %99, 1
store i32 %100, i32* %11
br label %46
101: ; preds = %58
br label %102
102: ; preds = %101
%103 = load i32, i32* %10
%104 = add nsw i32 %103, -1
store i32 %104, i32* %10
br label %40
105: ; preds = %40
br label %106
106: ; preds = %105, %96
br label %107
107: ; preds = %106, %36
%108 = load i32, i32* %8
%109 = add nsw i32 %108, 1
store i32 %109, i32* %8
br label %19
110: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.Ff\00"
@.str.1 = [5 x i8] c"%Ff \00"
@.str.2 = [8 x i8] c":%d %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10000 x i8]
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @mpf_init2(i32 undef, i64 19510)
%6 = tail call i32 @mpf_init_set_d(i32 undef, i32 1)
br label %7
7: ; preds = %2, %63
%8 = phi i32 [ 0, %2 ], [ %64, %63 ]
%9 = phi i32 [ 0, %2 ], [ %65, %63 ]
%10 = call i32 @mpf_add_ui(i32 undef, i32 undef, i32 1)
%11 = call i32 @mpf_ui_div(i32 undef, i32 1, i32 undef)
%12 = call i32 @gmp_sprintf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 undef)
%13 = call i32 @strlen(i8* %4)
%14 = icmp slt i32 %13, 50
br i1 %14, label %63, label %15
15: ; preds = %7
%16 = udiv i32 %13, 3
%17 = add nsw i32 %13, -1
%18 = icmp ugt i32 %17, %16
br i1 %18, label %19, label %63
19: ; preds = %15
%20 = add nsw i32 %13, -4
%21 = lshr i32 %20, 1
%22 = zext i32 %21 to i64
%23 = zext i32 %13 to i64
%24 = add nsw i64 %23, -1
%25 = zext i32 %16 to i64
br label %29
26: ; preds = %56, %29
%27 = add nsw i64 %30, -1
%28 = icmp sgt i64 %27, %25
br i1 %28, label %29, label %63
29: ; preds = %19, %26
%30 = phi i64 [ %24, %19 ], [ %27, %26 ]
%31 = phi i32 [ %13, %19 ], [ %32, %26 ]
%32 = trunc i64 %30 to i32
%33 = icmp slt i32 %31, %13
br i1 %33, label %34, label %26
34: ; preds = %29
%35 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %30
br label %36
36: ; preds = %34, %56
%37 = phi i64 [ 1, %34 ], [ %57, %56 ]
%38 = trunc i64 %37 to i32
br label %39
39: ; preds = %39, %36
%40 = phi i64 [ %46, %39 ], [ 1, %36 ]
%41 = mul nuw nsw i64 %40, %37
%42 = sub nsw i64 0, %41
%43 = getelementptr inbounds i8, i8* %35, i64 %42
%44 = call i64 @memcmp(i8* %35, i8* %43, i32 %38)
%45 = icmp eq i64 %44, 0
%46 = add nuw i64 %40, 1
br i1 %45, label %39, label %47
47: ; preds = %39
%48 = trunc i64 %40 to i32
%49 = icmp ugt i32 %48, 4
br i1 %49, label %50, label %56
50: ; preds = %47
%51 = trunc i64 %37 to i32
%52 = icmp slt i32 %8, %51
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%55 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %51, i8* %4)
br label %63
56: ; preds = %47
%57 = add nuw nsw i64 %37, 1
%58 = trunc i64 %57 to i32
%59 = icmp ult i64 %57, %22
%60 = add nsw i32 %58, %32
%61 = icmp slt i32 %60, %13
%62 = select i1 %59, i1 %61, i1 false
br i1 %62, label %36, label %26
63: ; preds = %26, %15, %53, %50, %7
%64 = phi i32 [ %8, %7 ], [ %51, %53 ], [ %8, %50 ], [ %8, %15 ], [ %8, %26 ]
%65 = add nuw nsw i32 %9, 1
%66 = icmp eq i32 %65, 1000
br i1 %66, label %67, label %7
67: ; preds = %63
ret i32 0
}