#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 cmn_getline(int /*<<< orphan*/, char **);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char **argv) {
  long unsigned int lines = 0, length_overall = 0;
  char *line = NULL;
  int retval = 0;
  while ((retval = cmn_getline(stdin, &line)) >= 0) {
    length_overall += strlen(line) - 1;
    lines++;
    free(line);
  }
  if (retval == -2) {
    perror("avgll");
    return 1;
  }
  printf("%.2f\n", ((double)length_overall / (double)lines));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1070 <cmn_getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jl     11d3 <main+0x83>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    1185 <main+0x35>
cmpl   $0xfffffffe,-0x2c(%rbp)
jne    11f5 <main+0xa5>
lea    0xe3c(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    124b <main+0xfb>
movq   -0x20(%rbp),%xmm0
movaps 0xdff(%rip),%xmm3
punpckldq %xmm3,%xmm0
movapd 0xe03(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0x18(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2e81(%rip),%r14
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
call   1070 <cmn_getline@plt>
test   %eax,%eax
js     1233 <main+0xe3>
pxor   %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
movq   %rax,%xmm0
movdqa 0xe54(%rip),%xmm1
punpcklqdq %xmm0,%xmm1
movdqa 0x10(%rsp),%xmm0
paddq  %xmm1,%xmm0
movdqa %xmm0,0x10(%rsp)
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
call   1070 <cmn_getline@plt>
test   %eax,%eax
jns    1190 <main+0x40>
movdqa 0xe2f(%rip),%xmm0
movdqa 0x10(%rsp),%xmm1
pand   %xmm1,%xmm0
por    0xe2d(%rip),%xmm0
psrlq  $0x20,%xmm1
por    0xe30(%rip),%xmm1
subpd  0xe38(%rip),%xmm1
addpd  %xmm0,%xmm1
cmp    $0xfffffffe,%eax
je     123c <main+0xec>
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  %xmm1,%xmm0
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
xorpd  %xmm1,%xmm1
cmp    $0xfffffffe,%eax
jne    1211 <main+0xc1>
lea    0xe0d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%eax
jmp    122b <main+0xdb>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"avgll\00"
@.str.1 = [6 x i8] c"%.2f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 0, i64* %7
store i8* null, i8** %8
store i32 0, i32* %9
br label %10
10: ; preds = %14, %2
%11 = load i32, i32* @stdin
%12 = call i32 @cmn_getline(i32 %11, i8** %8)
store i32 %12, i32* %9
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i8*, i8** %8
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = load i64, i64* %7
%20 = add i64 %19, %18
store i64 %20, i64* %7
%21 = load i64, i64* %6
%22 = add i64 %21, 1
store i64 %22, i64* %6
%23 = load i8*, i8** %8
%24 = call i32 @free(i8* %23)
br label %10
25: ; preds = %10
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, -2
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %37
30: ; preds = %25
%31 = load i64, i64* %7
%32 = uitofp i64 %31 to double
%33 = load i64, i64* %6
%34 = uitofp i64 %33 to double
%35 = fdiv double %32, %34
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %35)
store i32 0, i32* %3
br label %37
37: ; preds = %30, %28
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"avgll\00"
@.str.1 = [6 x i8] c"%.2f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = load i32, i32* @stdin
%6 = call i32 @cmn_getline(i32 %5, i8** %3)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %23
8: ; preds = %2, %8
%9 = phi <2 x i64> [ %15, %8 ], [ zeroinitializer, %2 ]
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = insertelement <2 x i64> <i64 1, i64 poison>, i64 %13, i64 1
%15 = add <2 x i64> %9, %14
%16 = load i8*, i8** %3
%17 = call i32 @free(i8* %16)
%18 = load i32, i32* @stdin
%19 = call i32 @cmn_getline(i32 %18, i8** %3)
%20 = icmp sgt i32 %19, -1
br i1 %20, label %8, label %21
21: ; preds = %8
%22 = uitofp <2 x i64> %15 to <2 x double>
br label %23
23: ; preds = %21, %2
%24 = phi i32 [ %6, %2 ], [ %19, %21 ]
%25 = phi <2 x double> [ zeroinitializer, %2 ], [ %22, %21 ]
%26 = icmp eq i32 %24, -2
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %34
29: ; preds = %23
%30 = extractelement <2 x double> %25, i64 0
%31 = extractelement <2 x double> %25, i64 1
%32 = fdiv double %31, %30
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %32)
br label %34
34: ; preds = %29, %27
%35 = phi i32 [ 1, %27 ], [ 0, %29 ]
ret i32 %35
}