#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 getchar();
int /*<<< orphan*/ printf(char *, double);
main() {
  long nc = 0;
  int end = getchar();
  while (getchar() != end)
    ++nc;
  printf("%ld\n", nc);
  double ncD;
  for (ncD = 0; getchar() != end; ++ncD)
    ;
  printf("%.0f\n", ncD);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
cmp    -0x14(%rbp),%eax
je     1162 <main+0x42>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1141 <main+0x21>
cvtsi2sdq -0x10(%rbp),%xmm0
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
cmp    -0x14(%rbp),%eax
je     11a8 <main+0x88>
jmp    1191 <main+0x71>
movsd  0xe67(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    117c <main+0x5c>
movsd  -0x20(%rbp),%xmm0
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebp
mov    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
cmp    %ebp,%eax
jne    1140 <main+0x20>
cvtsi2sd %rbx,%xmm0
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xorpd  %xmm0,%xmm0
cmp    %ebp,%eax
je     119d <main+0x7d>
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  0xe78(%rip),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
movsd  (%rsp),%xmm0
cmp    %ebp,%eax
jne    1180 <main+0x60>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
store i64 0, i64* %2
%5 = call i32 (...) @getchar()
store i32 %5, i32* %3
br label %6
6: ; preds = %10, %0
%7 = call i32 (...) @getchar()
%8 = load i32, i32* %3
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i64, i64* %2
%12 = add nsw i64 %11, 1
store i64 %12, i64* %2
br label %6
13: ; preds = %6
%14 = load i64, i64* %2
%15 = sitofp i64 %14 to double
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %15)
store double 0.000000e+00, double* %4
br label %17
17: ; preds = %22, %13
%18 = call i32 (...) @getchar()
%19 = load i32, i32* %3
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
br label %22
22: ; preds = %21
%23 = load double, double* %4
%24 = fadd double %23, 1.000000e+00
store double %24, double* %4
br label %17
25: ; preds = %17
%26 = load double, double* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
br label %2
2: ; preds = %2, %0
%3 = phi i64 [ 0, %0 ], [ %6, %2 ]
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, %1
%6 = add nuw nsw i64 %3, 1
br i1 %5, label %7, label %2
7: ; preds = %2
%8 = sitofp i64 %3 to double
%9 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %8)
%10 = tail call i32 (...) @getchar()
%11 = icmp eq i32 %10, %1
br i1 %11, label %17, label %12
12: ; preds = %7, %12
%13 = phi double [ %14, %12 ], [ 0.000000e+00, %7 ]
%14 = fadd double %13, 1.000000e+00
%15 = tail call i32 (...) @getchar()
%16 = icmp eq i32 %15, %1
br i1 %16, label %17, label %12
17: ; preds = %12, %7
%18 = phi double [ 0.000000e+00, %7 ], [ %14, %12 ]
%19 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %18)
ret i32 0
}