#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*/ printf(char *, ...);
size_t MultiplicationPrincipleR(size_t pos, int **val, int *sol,
                                size_t *num_choices, size_t n, size_t count) {
  int i;
  if (pos >= n) {
    for (i = 0; i < n; i++)
      printf("%d ", sol[i]);
    printf("\n");
    return (count + 1);
  }
  for (i = 0; i < num_choices[pos]; i++) {
    sol[pos] = val[pos][i];
    count = MultiplicationPrincipleR(pos + 1, val, sol, num_choices, n, count);
  }
  return (count);
}


x86 assembly (clang, -O0):
<MultiplicationPrincipleR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x30(%rbp),%rax
jb     11a9 <MultiplicationPrincipleR+0x89>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    118a <MultiplicationPrincipleR+0x6a>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1155 <MultiplicationPrincipleR+0x35>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    121f <MultiplicationPrincipleR+0xff>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jae    1217 <MultiplicationPrincipleR+0xf7>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1040 <MultiplicationPrincipleR@plt>
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b0 <MultiplicationPrincipleR+0x90>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MultiplicationPrincipleR>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbx
mov    %rdx,%r15
cmp    %r8,%rdi
jae    11a7 <MultiplicationPrincipleR+0x77>
mov    %rcx,%r12
mov    %rdi,%rbp
cmpq   $0x0,(%rcx,%rdi,8)
je     11e5 <MultiplicationPrincipleR+0xb5>
mov    %rsi,%r13
lea    0x1(%rbp),%rax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
mov    %r8,0x8(%rsp)
xchg   %ax,%ax
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%r14,4),%eax
mov    %eax,(%r15,%rbp,4)
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    0x8(%rsp),%r8
mov    %rbx,%r9
call   1050 <MultiplicationPrincipleR@plt>
mov    %rax,%rbx
add    $0x1,%r14
cmp    %r14,(%r12,%rbp,8)
ja     1170 <MultiplicationPrincipleR+0x40>
jmp    11e5 <MultiplicationPrincipleR+0xb5>
test   %r8,%r8
je     11d7 <MultiplicationPrincipleR+0xa7>
mov    %r8,%r12
lea    0xe4a(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11c0 <MultiplicationPrincipleR+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i64 @MultiplicationPrincipleR(i64 %0, i32** nocapture %1, i32* nocapture %2, i64* nocapture %3, i64 %4, i64 %5) {
%7 = icmp ult i64 %0, %4
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = icmp eq i64 %4, 0
br i1 %9, label %25, label %18
10: ; preds = %6
%11 = getelementptr inbounds i64, i64* %3, i64 %0
%12 = load i64, i64* %11
%13 = icmp eq i64 %12, 0
br i1 %13, label %38, label %14
14: ; preds = %10
%15 = getelementptr inbounds i32*, i32** %1, i64 %0
%16 = getelementptr inbounds i32, i32* %2, i64 %0
%17 = add nuw i64 %0, 1
br label %28
18: ; preds = %8, %18
%19 = phi i64 [ %23, %18 ], [ 0, %8 ]
%20 = getelementptr inbounds i32, i32* %2, i64 %19
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = add nuw i64 %19, 1
%24 = icmp eq i64 %23, %4
br i1 %24, label %25, label %18
25: ; preds = %18, %8
%26 = tail call i32 @putchar(i32 10)
%27 = add i64 %5, 1
br label %38
28: ; preds = %14, %28
%29 = phi i64 [ 0, %14 ], [ %35, %28 ]
%30 = phi i64 [ %5, %14 ], [ %34, %28 ]
%31 = load i32*, i32** %15
%32 = getelementptr inbounds i32, i32* %31, i64 %29
%33 = load i32, i32* %32
store i32 %33, i32* %16
%34 = tail call i64 @MultiplicationPrincipleR(i64 %17, i32** %1, i32* %2, i64* %3, i64 %4, i64 %30)
%35 = add nuw i64 %29, 1
%36 = load i64, i64* %11
%37 = icmp ugt i64 %36, %35
br i1 %37, label %28, label %38
38: ; preds = %28, %10, %25
%39 = phi i64 [ %27, %25 ], [ %5, %10 ], [ %34, %28 ]
ret i64 %39
}