#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 /*<<< orphan*/ computeAverageAPSP(int **, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int caseId, u, v, adjMatrix[100][100], numV, i, j;
  caseId = 1;
  while (1) {
    scanf("%d %d", &u, &v);
    if (u == 0 && v == 0)
      break;
    numV = 0;
    memset((int *)adjMatrix, 0, 100 * 100 * sizeof(int));
    if (u > numV)
      numV = u;
    if (v > numV)
      numV = v;
    adjMatrix[u - 1][v - 1] = 1;
    while (1) {
      scanf("%d %d", &u, &v);
      if (u == 0 && v == 0)
        break;
      adjMatrix[u - 1][v - 1] = 1;
      if (u > numV)
        numV = u;
      if (v > numV)
        numV = v;
    }
    printf("Case %d: average length between pages = %.3lf clicks\n", caseId,
           computeAverageAPSP(adjMatrix, numV));
    caseId++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1186 <main+0x46>
cmpl   $0x0,-0x10(%rbp)
jne    1186 <main+0x46>
jmp    12c6 <main+0x186>
movl   $0x0,-0x9c54(%rbp)
lea    -0x9c50(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1040 <memset@plt>
mov    -0xc(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jle    11bb <main+0x7b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x9c54(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jle    11d3 <main+0x93>
mov    -0x10(%rbp),%eax
mov    %eax,-0x9c54(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
lea    0xdfc(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    122a <main+0xea>
cmpl   $0x0,-0x10(%rbp)
jne    122a <main+0xea>
jmp    1289 <main+0x149>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jle    126c <main+0x12c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x9c54(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jle    1284 <main+0x144>
mov    -0x10(%rbp),%eax
mov    %eax,-0x9c54(%rbp)
jmp    11fd <main+0xbd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x9c60(%rbp)
lea    -0x9c50(%rbp),%rdi
mov    -0x9c54(%rbp),%esi
call   1050 <computeAverageAPSP@plt>
mov    -0x9c60(%rbp),%esi
mov    %eax,%edx
lea    0xd53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
or     0x8(%rsp),%eax
jne    1185 <main+0x45>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r15d
lea    0x10(%rsp),%r14
lea    0xe69(%rip),%r12
lea    0xc(%rsp),%rbp
lea    0x8(%rsp),%rbx
jmp    11e8 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r13d,%esi
call   1050 <computeAverageAPSP@plt>
lea    0xe44(%rip),%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <printf@plt>
add    $0x1,%r15d
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
or     0x8(%rsp),%eax
je     1171 <main+0x31>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1040 <memset@plt>
movslq 0xc(%rsp),%rax
test   %rax,%rax
mov    %eax,%r13d
mov    $0x0,%ecx
cmovs  %ecx,%r13d
movslq 0x8(%rsp),%rcx
cmp    %r13d,%ecx
cmovg  %ecx,%r13d
imul   $0x190,%rax,%rax
add    %r14,%rax
movl   $0x1,-0x194(%rax,%rcx,4)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ecx
mov    %eax,%edx
or     %ecx,%edx
je     11b0 <main+0x70>
lea    -0x1(%rax),%edx
movslq %edx,%rdx
movslq %ecx,%rcx
imul   $0x190,%rdx,%rdx
add    %rsp,%rdx
add    $0x10,%rdx
cmp    %r13d,%eax
cmovg  %eax,%r13d
movl   $0x1,-0x4(%rdx,%rcx,4)
cmp    %r13d,%ecx
cmovg  %ecx,%r13d
jmp    1230 <main+0xf0>

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [54 x i8] c"Case %d: average length between pages = %.3lf clicks\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x [100 x i32]]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %9
9: ; preds = %0, %70
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
br label %79
17: ; preds = %13, %9
store i32 0, i32* %6
%18 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 0
%19 = bitcast [100 x i32]* %18 to i32*
%20 = call i32 @memset(i32* %19, i32 0, i32 40000)
%21 = load i32, i32* %3
%22 = load i32, i32* %6
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = load i32, i32* %3
store i32 %25, i32* %6
br label %26
26: ; preds = %24, %17
%27 = load i32, i32* %4
%28 = load i32, i32* %6
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i32, i32* %4
store i32 %31, i32* %6
br label %32
32: ; preds = %30, %26
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 %35
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %36, i64 0, i64 %39
store i32 1, i32* %40
br label %41
41: ; preds = %32, %69
%42 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %45
br label %70
49: ; preds = %45, %41
%50 = load i32, i32* %3
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 %52
%54 = load i32, i32* %4
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x i32], [100 x i32]* %53, i64 0, i64 %56
store i32 1, i32* %57
%58 = load i32, i32* %3
%59 = load i32, i32* %6
%60 = icmp sgt i32 %58, %59
br i1 %60, label %61, label %63
61: ; preds = %49
%62 = load i32, i32* %3
store i32 %62, i32* %6
br label %63
63: ; preds = %61, %49
%64 = load i32, i32* %4
%65 = load i32, i32* %6
%66 = icmp sgt i32 %64, %65
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = load i32, i32* %4
store i32 %68, i32* %6
br label %69
69: ; preds = %67, %63
br label %41
70: ; preds = %48
%71 = load i32, i32* %2
%72 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 0
%73 = bitcast [100 x i32]* %72 to i32**
%74 = load i32, i32* %6
%75 = call i32 @computeAverageAPSP(i32** %73, i32 %74)
%76 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %71, i32 %75)
%77 = load i32, i32* %2
%78 = add nsw i32 %77, 1
store i32 %78, i32* %2
br label %9
79: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [54 x i8] c"Case %d: average length between pages = %.3lf clicks\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x [100 x i32]]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [100 x [100 x i32]]* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %66, label %13
13: ; preds = %0
%14 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 0, i64 0
%15 = bitcast [100 x [100 x i32]]* %3 to i32**
br label %16
16: ; preds = %13, %55
%17 = phi i32 [ 1, %13 ], [ %59, %55 ]
%18 = call i32 @memset(i32* %14, i32 0, i32 40000)
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 0
%21 = select i1 %20, i32 %19, i32 0
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, %21
%24 = select i1 %23, i32 %22, i32 %21
%25 = add nsw i32 %19, -1
%26 = sext i32 %25 to i64
%27 = add nsw i32 %22, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 %26, i64 %28
store i32 1, i32* %29
%30 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%31 = load i32, i32* %1
%32 = icmp eq i32 %31, 0
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 0
%35 = select i1 %32, i1 %34, i1 false
br i1 %35, label %55, label %36
36: ; preds = %16, %36
%37 = phi i32 [ %52, %36 ], [ %33, %16 ]
%38 = phi i32 [ %50, %36 ], [ %31, %16 ]
%39 = phi i32 [ %48, %36 ], [ %24, %16 ]
%40 = add nsw i32 %38, -1
%41 = sext i32 %40 to i64
%42 = add nsw i32 %37, -1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 %41, i64 %43
store i32 1, i32* %44
%45 = icmp sgt i32 %38, %39
%46 = select i1 %45, i32 %38, i32 %39
%47 = icmp sgt i32 %37, %46
%48 = select i1 %47, i32 %37, i32 %46
%49 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%50 = load i32, i32* %1
%51 = icmp eq i32 %50, 0
%52 = load i32, i32* %2
%53 = icmp eq i32 %52, 0
%54 = select i1 %51, i1 %53, i1 false
br i1 %54, label %55, label %36
55: ; preds = %36, %16
%56 = phi i32 [ %24, %16 ], [ %48, %36 ]
%57 = call i32 @computeAverageAPSP(i32** %15, i32 %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %57)
%59 = add nuw nsw i32 %17, 1
%60 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%61 = load i32, i32* %1
%62 = icmp eq i32 %61, 0
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 0
%65 = select i1 %62, i1 %64, i1 false
br i1 %65, label %66, label %16
66: ; preds = %55, %0
ret i32 0
}