#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ pfprintf(int /*<<< orphan*/ *, int, char *, ...);
void print_mprf_outmuxes_gen(FILE *infile, unsigned int num_ni,
                             unsigned int num_no) {
  int i, j;
  if (num_no == 1) {
    for (i = 0; i < num_ni; i++) {
      pfprintf(infile, 2,
               "ram_output_v(DW*(%d+1)-1 downto DW*%d) <= "
               "ram_output_i(DW*(%d+1)-1 downto DW*%d);\n",
               i, i, i, i);
    }
  } else {
    for (j = 0; j < num_ni; j++) {
      pfprintf(infile, 2, "process (ram_output_i, banksel_v)\n");
      pfprintf(infile, 4, "variable ia_sel_part : integer range 0 to NWP-1;\n");
      pfprintf(infile, 2, "begin\n");
      pfprintf(infile, 4,
               "ia_sel(%d) <= banksel_v(log2c(NWP)*(%d+1)-1 downto "
               "log2c(NWP)*%d);\n",
               j, j, j);
      pfprintf(infile, 4, "ia_sel_part := conv_integer(ia_sel(%d));\n", j);
      pfprintf(infile, 4, "case ia_sel_part is\n");
      for (i = 0; i < num_no; i++) {
        pfprintf(infile, 6,
                 "when %d      => ram_output_v(DW*(%d+1)-1 downto DW*%d) <= "
                 "ram_output_i(DW*(%d+%d*NRP+1)-1 downto DW*(%d+%d*NRP));\n",
                 i, j, j, j, i, j, i);
      }
      pfprintf(infile, 6,
               "when others => ram_output_v(DW*(%d+1)-1 downto DW*%d) <= "
               "(others => '0');\n",
               j, j);
      pfprintf(infile, 4, "end case;\n");
      pfprintf(infile, 2, "end process;\n\n");
    }
  }
}


x86 assembly (clang, -O0):
<print_mprf_outmuxes_gen>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    117b <print_mprf_outmuxes_gen+0x6b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1176 <print_mprf_outmuxes_gen+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x1c(%rbp),%eax
mov    $0x2,%esi
lea    0xea2(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <print_mprf_outmuxes_gen+0x24>
jmp    12e7 <print_mprf_outmuxes_gen+0x1d7>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    12e2 <print_mprf_outmuxes_gen+0x1d2>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
lea    0xeb5(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
lea    0xec1(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
lea    0xedc(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    $0x4,%esi
lea    0xec1(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    $0x4,%esi
lea    0xeeb(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
lea    0xefe(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1288 <print_mprf_outmuxes_gen+0x178>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x20(%rbp),%ebx
mov    -0x1c(%rbp),%r11d
mov    -0x20(%rbp),%r10d
mov    -0x1c(%rbp),%eax
mov    $0x6,%esi
lea    0xed0(%rip),%rdx
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    122d <print_mprf_outmuxes_gen+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    $0x6,%esi
lea    0xf06(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
lea    0xf3a(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
lea    0xf2e(%rip),%rdx
mov    $0x0,%al
call   1030 <pfprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1182 <print_mprf_outmuxes_gen+0x72>
jmp    12e7 <print_mprf_outmuxes_gen+0x1d7>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mprf_outmuxes_gen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
cmp    $0x1,%edx
jne    1170 <print_mprf_outmuxes_gen+0x60>
test   %r14d,%r14d
je     12b5 <print_mprf_outmuxes_gen+0x1a5>
lea    0xeca(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %rbp
call   1030 <pfprintf@plt>
add    $0x10,%rsp
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1140 <print_mprf_outmuxes_gen+0x30>
jmp    12b5 <print_mprf_outmuxes_gen+0x1a5>
test   %r14d,%r14d
je     12b5 <print_mprf_outmuxes_gen+0x1a5>
mov    %edx,%ebp
lea    0xfb0(%rip),%r15
xor    %r12d,%r12d
jmp    11e5 <print_mprf_outmuxes_gen+0xd5>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x6,%esi
lea    0x1006(%rip),%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
lea    0x1035(%rip),%rdx
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
lea    0x102a(%rip),%rdx
xor    %eax,%eax
call   1030 <pfprintf@plt>
add    $0x1,%r12d
cmp    %r14d,%r12d
je     12b5 <print_mprf_outmuxes_gen+0x1a5>
mov    %rbx,%rdi
mov    $0x2,%esi
lea    0xe5f(%rip),%rdx
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
lea    0xe6c(%rip),%rdx
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
lea    0xe88(%rip),%rdx
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
lea    0xe79(%rip),%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
lea    0xe9e(%rip),%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1030 <pfprintf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
lea    0xeaf(%rip),%rdx
xor    %eax,%eax
call   1030 <pfprintf@plt>
test   %ebp,%ebp
je     1190 <print_mprf_outmuxes_gen+0x80>
xor    %r13d,%r13d
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %r15,%rdx
mov    %r13d,%ecx
mov    %r12d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
push   %r13
push   %r12
push   %r13
push   %r12
call   1030 <pfprintf@plt>
add    $0x20,%rsp
add    $0x1,%r13d
cmp    %r13d,%ebp
jne    1280 <print_mprf_outmuxes_gen+0x170>
jmp    1190 <print_mprf_outmuxes_gen+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [83 x i8] c"ram_output_v(DW*(%d+1)-1 downto DW*%d) <= ram_output_i(DW*(%d+1)-1 downto DW*%d);\0A\00"
@.str.1 = [35 x i8] c"process (ram_output_i, banksel_v)\0A\00"
@.str.2 = [50 x i8] c"variable ia_sel_part : integer range 0 to NWP-1;\0A\00"
@.str.3 = [7 x i8] c"begin\0A\00"
@.str.4 = [68 x i8] c"ia_sel(%d) <= banksel_v(log2c(NWP)*(%d+1)-1 downto log2c(NWP)*%d);\0A\00"
@.str.5 = [42 x i8] c"ia_sel_part := conv_integer(ia_sel(%d));\0A\00"
@.str.6 = [21 x i8] c"case ia_sel_part is\0A\00"
@.str.7 = [115 x i8] c"when %d => ram_output_v(DW*(%d+1)-1 downto DW*%d) <= ram_output_i(DW*(%d+%d*NRP+1)-1 downto DW*(%d+%d*NRP));\0A\00"
@.str.8 = [75 x i8] c"when others => ram_output_v(DW*(%d+1)-1 downto DW*%d) <= (others => '0');\0A\00"
@.str.9 = [11 x i8] c"end case;\0A\00"
@.str.10 = [15 x i8] c"end process;\0A\0A\00"
define void @print_mprf_outmuxes_gen(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %27
11: ; preds = %3
store i32 0, i32* %7
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %7
%14 = load i32, i32* %5
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i32, i32* %7
%19 = load i32, i32* %7
%20 = load i32, i32* %7
%21 = load i32, i32* %7
%22 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %17, i32 2, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %12
26: ; preds = %12
br label %79
27: ; preds = %3
store i32 0, i32* %8
br label %28
28: ; preds = %75, %27
%29 = load i32, i32* %8
%30 = load i32, i32* %5
%31 = icmp ult i32 %29, %30
br i1 %31, label %32, label %78
32: ; preds = %28
%33 = load i32*, i32** %4
%34 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %33, i32 2, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32*, i32** %4
%36 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %35, i32 4, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32*, i32** %4
%38 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %37, i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32*, i32** %4
%40 = load i32, i32* %8
%41 = load i32, i32* %8
%42 = load i32, i32* %8
%43 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %39, i32 4, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %41, i32 %42)
%44 = load i32*, i32** %4
%45 = load i32, i32* %8
%46 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %44, i32 4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = load i32*, i32** %4
%48 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %47, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %49
49: ; preds = %63, %32
%50 = load i32, i32* %7
%51 = load i32, i32* %6
%52 = icmp ult i32 %50, %51
br i1 %52, label %53, label %66
53: ; preds = %49
%54 = load i32*, i32** %4
%55 = load i32, i32* %7
%56 = load i32, i32* %8
%57 = load i32, i32* %8
%58 = load i32, i32* %8
%59 = load i32, i32* %7
%60 = load i32, i32* %8
%61 = load i32, i32* %7
%62 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %54, i32 6, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.7, i64 0, i64 0), i32 %55, i32 %56, i32 %57, i32 %58, i32 %59, i32 %60, i32 %61)
br label %63
63: ; preds = %53
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %49
66: ; preds = %49
%67 = load i32*, i32** %4
%68 = load i32, i32* %8
%69 = load i32, i32* %8
%70 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %67, i32 6, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.8, i64 0, i64 0), i32 %68, i32 %69)
%71 = load i32*, i32** %4
%72 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %71, i32 4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%73 = load i32*, i32** %4
%74 = call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %73, i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %75
75: ; preds = %66
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %28
78: ; preds = %28
br label %79
79: ; preds = %78, %26
ret void
}

LLVM IR (-O2):
@.str = [83 x i8] c"ram_output_v(DW*(%d+1)-1 downto DW*%d) <= ram_output_i(DW*(%d+1)-1 downto DW*%d);\0A\00"
@.str.1 = [35 x i8] c"process (ram_output_i, banksel_v)\0A\00"
@.str.2 = [50 x i8] c"variable ia_sel_part : integer range 0 to NWP-1;\0A\00"
@.str.3 = [7 x i8] c"begin\0A\00"
@.str.4 = [68 x i8] c"ia_sel(%d) <= banksel_v(log2c(NWP)*(%d+1)-1 downto log2c(NWP)*%d);\0A\00"
@.str.5 = [42 x i8] c"ia_sel_part := conv_integer(ia_sel(%d));\0A\00"
@.str.6 = [21 x i8] c"case ia_sel_part is\0A\00"
@.str.7 = [115 x i8] c"when %d => ram_output_v(DW*(%d+1)-1 downto DW*%d) <= ram_output_i(DW*(%d+%d*NRP+1)-1 downto DW*(%d+%d*NRP));\0A\00"
@.str.8 = [75 x i8] c"when others => ram_output_v(DW*(%d+1)-1 downto DW*%d) <= (others => '0');\0A\00"
@.str.9 = [11 x i8] c"end case;\0A\00"
@.str.10 = [15 x i8] c"end process;\0A\0A\00"
define void @print_mprf_outmuxes_gen(i32* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 1
%5 = icmp eq i32 %1, 0
br i1 %4, label %9, label %6
6: ; preds = %3
br i1 %5, label %34, label %7
7: ; preds = %6
%8 = icmp eq i32 %2, 0
br label %15
9: ; preds = %3
br i1 %5, label %34, label %10
10: ; preds = %9, %10
%11 = phi i32 [ %13, %10 ], [ 0, %9 ]
%12 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 2, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %11, i32 %11, i32 %11)
%13 = add nuw i32 %11, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %34, label %10
15: ; preds = %7, %28
%16 = phi i32 [ 0, %7 ], [ %32, %28 ]
%17 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 2, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 4, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 4, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %16, i32 %16)
%21 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%22 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br i1 %8, label %28, label %23
23: ; preds = %15, %23
%24 = phi i32 [ %26, %23 ], [ 0, %15 ]
%25 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 6, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.7, i64 0, i64 0), i32 %24, i32 %16, i32 %16, i32 %16, i32 %24, i32 %16, i32 %24)
%26 = add nuw i32 %24, 1
%27 = icmp eq i32 %26, %2
br i1 %27, label %28, label %23
28: ; preds = %23, %15
%29 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 6, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.8, i64 0, i64 0), i32 %16, i32 %16)
%30 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%31 = tail call i32 (i32*, i32, i8*, ...) @pfprintf(i32* %0, i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%32 = add nuw i32 %16, 1
%33 = icmp eq i32 %32, %1
br i1 %33, label %34, label %15
34: ; preds = %28, %10, %6, %9
ret void
}