#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 atoi(char *);
long binomial_coefficient(int, int);
long count_partitions_(int, int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "usage: %s <M> <N>\n", argv[0]);
    return 1;
  }
  int M = atoi(argv[1]);
  int N = atoi(argv[2]);
  if (N <= 0 || N > M * 7)
    return 1;
  long colors_count = 0;
  long choices_count = 0;
  for (int colors = 1; colors <= 7; colors++) {
    long possible_choices =
        count_partitions_(N, colors, M, 1) * binomial_coefficient(7, colors);
    choices_count += possible_choices;
    colors_count += colors * possible_choices;
  }
  printf("%.9f\n", (double)colors_count / choices_count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1198 <main+0x48>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    127f <main+0x12f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11d1 <main+0x81>
mov    -0x18(%rbp),%eax
imul   $0x7,-0x14(%rbp),%ecx
cmp    %ecx,%eax
jle    11dd <main+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    127f <main+0x12f>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
cmpl   $0x7,-0x2c(%rbp)
jg     125c <main+0x10c>
mov    -0x18(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%esi
mov    $0x7,%edi
call   1040 <binomial_coefficient@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movslq -0x2c(%rbp),%rax
imul   -0x38(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f4 <main+0xa4>
cvtsi2sdq -0x20(%rbp),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xda0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbp
cmp    $0x3,%edi
jne    132b <main+0x1db>
mov    0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r12d
mov    $0x1,%eax
test   %r12d,%r12d
jle    1349 <main+0x1f9>
lea    0x0(,%r15,8),%ecx
sub    %r15d,%ecx
cmp    %ecx,%r12d
jg     1349 <main+0x1f9>
mov    %r12d,%edi
mov    $0x1,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%r14
mov    $0x7,%edi
mov    $0x1,%esi
call   1040 <binomial_coefficient@plt>
mov    %rax,%rbx
imul   %r14,%rbx
mov    %r12d,%edi
mov    $0x2,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%r14
mov    $0x7,%edi
mov    $0x2,%esi
call   1040 <binomial_coefficient@plt>
imul   %r14,%rax
lea    (%rax,%rbx,1),%rbp
lea    (%rbx,%rax,2),%r14
mov    %r12d,%edi
mov    $0x3,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%rbx
mov    $0x7,%edi
mov    $0x3,%esi
call   1040 <binomial_coefficient@plt>
imul   %rbx,%rax
add    %rax,%rbp
lea    (%rax,%rax,2),%rbx
add    %r14,%rbx
mov    %r12d,%edi
mov    $0x4,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%r14
mov    $0x7,%edi
mov    $0x4,%esi
call   1040 <binomial_coefficient@plt>
imul   %r14,%rax
add    %rax,%rbp
lea    (%rbx,%rax,4),%r14
mov    %r12d,%edi
mov    $0x5,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%rbx
mov    $0x7,%edi
mov    $0x5,%esi
call   1040 <binomial_coefficient@plt>
imul   %rbx,%rax
add    %rax,%rbp
lea    (%rax,%rax,4),%rbx
add    %r14,%rbx
mov    %r12d,%edi
mov    $0x6,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%r14
mov    $0x7,%edi
mov    $0x6,%esi
call   1040 <binomial_coefficient@plt>
imul   %r14,%rax
add    %rax,%rbp
lea    (%rax,%rax,2),%rax
lea    (%rbx,%rax,2),%r14
mov    %r12d,%edi
mov    $0x7,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <count_partitions_@plt>
mov    %rax,%rbx
mov    $0x7,%edi
mov    $0x7,%esi
call   1040 <binomial_coefficient@plt>
imul   %rbx,%rax
lea    0x0(,%rax,8),%rcx
sub    %rax,%rcx
add    %r14,%rcx
cvtsi2sd %rcx,%xmm0
add    %rax,%rbp
cvtsi2sd %rbp,%xmm1
divsd  %xmm1,%xmm0
lea    0xcf1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    1349 <main+0x1f9>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xcc1(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"usage: %s <M> <N>\0A\00"
@.str.1 = [6 x i8] c"%.9f\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 i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %68
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = icmp sle i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %20
%32 = load i32, i32* %7
%33 = load i32, i32* %6
%34 = mul nsw i32 %33, 7
%35 = icmp sgt i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %31, %20
store i32 1, i32* %3
br label %68
37: ; preds = %31
store i64 0, i64* %8
store i64 0, i64* %9
store i32 1, i32* %10
br label %38
38: ; preds = %58, %37
%39 = load i32, i32* %10
%40 = icmp sle i32 %39, 7
br i1 %40, label %41, label %61
41: ; preds = %38
%42 = load i32, i32* %7
%43 = load i32, i32* %10
%44 = load i32, i32* %6
%45 = call i64 @count_partitions_(i32 %42, i32 %43, i32 %44, i32 1)
%46 = load i32, i32* %10
%47 = call i64 @binomial_coefficient(i32 7, i32 %46)
%48 = mul nsw i64 %45, %47
store i64 %48, i64* %11
%49 = load i64, i64* %11
%50 = load i64, i64* %9
%51 = add nsw i64 %50, %49
store i64 %51, i64* %9
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = load i64, i64* %11
%55 = mul nsw i64 %53, %54
%56 = load i64, i64* %8
%57 = add nsw i64 %56, %55
store i64 %57, i64* %8
br label %58
58: ; preds = %41
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
store i32 %60, i32* %10
br label %38
61: ; preds = %38
%62 = load i64, i64* %8
%63 = sitofp i64 %62 to double
%64 = load i64, i64* %9
%65 = sitofp i64 %64 to double
%66 = fdiv double %63, %65
%67 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %66)
store i32 0, i32* %3
br label %68
68: ; preds = %61, %36, %14
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"usage: %s <M> <N>\0A\00"
@.str.1 = [6 x i8] c"%.9f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %63
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp slt i32 %14, 1
%16 = mul nsw i32 %11, 7
%17 = icmp sgt i32 %14, %16
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %63, label %19
19: ; preds = %8
%20 = tail call i64 @count_partitions_(i32 %14, i32 1, i32 %11, i32 1)
%21 = tail call i64 @binomial_coefficient(i32 7, i32 1)
%22 = mul nsw i64 %21, %20
%23 = tail call i64 @count_partitions_(i32 %14, i32 2, i32 %11, i32 1)
%24 = tail call i64 @binomial_coefficient(i32 7, i32 2)
%25 = mul nsw i64 %24, %23
%26 = add nsw i64 %25, %22
%27 = shl nsw i64 %25, 1
%28 = add nsw i64 %27, %22
%29 = tail call i64 @count_partitions_(i32 %14, i32 3, i32 %11, i32 1)
%30 = tail call i64 @binomial_coefficient(i32 7, i32 3)
%31 = mul nsw i64 %30, %29
%32 = add nsw i64 %31, %26
%33 = mul nsw i64 %31, 3
%34 = add nsw i64 %33, %28
%35 = tail call i64 @count_partitions_(i32 %14, i32 4, i32 %11, i32 1)
%36 = tail call i64 @binomial_coefficient(i32 7, i32 4)
%37 = mul nsw i64 %36, %35
%38 = add nsw i64 %37, %32
%39 = shl nsw i64 %37, 2
%40 = add nsw i64 %39, %34
%41 = tail call i64 @count_partitions_(i32 %14, i32 5, i32 %11, i32 1)
%42 = tail call i64 @binomial_coefficient(i32 7, i32 5)
%43 = mul nsw i64 %42, %41
%44 = add nsw i64 %43, %38
%45 = mul nsw i64 %43, 5
%46 = add nsw i64 %45, %40
%47 = tail call i64 @count_partitions_(i32 %14, i32 6, i32 %11, i32 1)
%48 = tail call i64 @binomial_coefficient(i32 7, i32 6)
%49 = mul nsw i64 %48, %47
%50 = add nsw i64 %49, %44
%51 = mul nsw i64 %49, 6
%52 = add nsw i64 %51, %46
%53 = tail call i64 @count_partitions_(i32 %14, i32 7, i32 %11, i32 1)
%54 = tail call i64 @binomial_coefficient(i32 7, i32 7)
%55 = mul nsw i64 %54, %53
%56 = add nsw i64 %55, %50
%57 = mul nsw i64 %55, 7
%58 = add nsw i64 %57, %52
%59 = sitofp i64 %58 to double
%60 = sitofp i64 %56 to double
%61 = fdiv double %59, %60
%62 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %61)
br label %63
63: ; preds = %19, %8, %4
%64 = phi i32 [ 1, %4 ], [ 0, %19 ], [ 1, %8 ]
ret i32 %64
}