#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 computeCoeffMultinomial(int, int, int *, int *);
int /*<<< orphan*/ computeFactorial(int *, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *, ...);
int main(void) {
  int factorial[12 + 1], n, k, expo[12], i;
  computeFactorial(factorial, 12 + 1);
  while (scanf("%d %d", &n, &k) > 0) {
    for (i = 0; i < k; i++)
      scanf("%d", &expo[i]);
    printf("%d\n", computeCoeffMultinomial(n, k, expo, factorial));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0xd,%esi
call   1050 <computeFactorial@plt>
lea    0xe99(%rip),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
cmp    $0x0,%rax
jle    11f3 <main+0xb3>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    11cd <main+0x8d>
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    118a <main+0x4a>
mov    -0x44(%rbp),%edi
mov    -0x48(%rbp),%esi
lea    -0x80(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1040 <computeCoeffMultinomial@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0x10(%rsp),%rdi
mov    $0xd,%esi
call   1050 <computeFactorial@plt>
lea    0xe99(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
test   %rax,%rax
jle    1211 <main+0xd1>
lea    0x50(%rsp),%r12
lea    0xe76(%rip),%rbx
lea    0xc(%rsp),%rbp
lea    0x8(%rsp),%r15
jmp    11d8 <main+0x98>
nopl   0x0(%rax)
mov    0xc(%rsp),%edi
mov    %r12,%rdx
lea    0x10(%rsp),%rcx
call   1040 <computeCoeffMultinomial@plt>
lea    0xe4e(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
test   %rax,%rax
jle    1211 <main+0xd1>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    11a0 <main+0x60>
mov    %r12,%r14
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%r13
movslq 0x8(%rsp),%rsi
add    $0x4,%r14
cmp    %rsi,%r13
jl     11f0 <main+0xb0>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [12 x i32]
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 0
%8 = call i32 @computeFactorial(i32* %7, i32 13)
br label %9
9: ; preds = %25, %0
%10 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %9
store i32 0, i32* %6
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 %19
%21 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %13
25: ; preds = %13
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%29 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 0
%30 = call i32 @computeCoeffMultinomial(i32 %26, i32 %27, i32* %28, i32* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %9
32: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [13 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [12 x i32]
%5 = bitcast [13 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast [12 x i32]* %4 to i8*
%9 = getelementptr inbounds [13 x i32], [13 x i32]* %1, i64 0, i64 0
%10 = call i32 @computeFactorial(i32* %9, i32 13)
%11 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %0
%14 = getelementptr inbounds [12 x i32], [12 x i32]* %4, i64 0, i64 0
br label %15
15: ; preds = %13, %26
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15, %18
%19 = phi i64 [ %22, %18 ], [ 0, %15 ]
%20 = getelementptr inbounds [12 x i32], [12 x i32]* %4, i64 0, i64 %19
%21 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %26
26: ; preds = %18, %15
%27 = phi i32 [ %16, %15 ], [ %23, %18 ]
%28 = load i32, i32* %2
%29 = call i32 @computeCoeffMultinomial(i32 %28, i32 %27, i32* %14, i32* %9)
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%32 = icmp sgt i64 %31, 0
br i1 %32, label %15, label %33
33: ; preds = %26, %0
ret i32 0
}