#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*/ jerasure_print_matrix(int *, int, int, int);
int /*<<< orphan*/ printf(char *);
int *reed_sol_big_vandermonde_distribution_matrix(int, int, int);
int *reed_sol_extended_vandermonde_matrix(int, int, int);
int *reed_sol_vandermonde_coding_matrix(int, int, int);
scalar_t__ sscanf(char *, char *, int *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int k, w, m;
  int *matrix;
  if (argc != 4)
    usage(NULL);
  if (sscanf(argv[1], "%d", &k) == 0 || k <= 0)
    usage("Bad k");
  if (sscanf(argv[2], "%d", &m) == 0 || m <= 0)
    usage("Bad m");
  if (sscanf(argv[3], "%d", &w) == 0 || w <= 0 || w > 32)
    usage("Bad w");
  if (w <= 30 && k + m > (1 << w))
    usage("k + m is too big");
  matrix = reed_sol_extended_vandermonde_matrix(k + m, k, w);
  printf("Extended Vandermonde Matrix:\n\n");
  jerasure_print_matrix(matrix, k + m, k, w);
  printf("\n");
  matrix = reed_sol_big_vandermonde_distribution_matrix(k + m, k, w);
  printf("Vandermonde Distribution Matrix:\n\n");
  jerasure_print_matrix(matrix, k + m, k, w);
  printf("\n");
  matrix = reed_sol_vandermonde_coding_matrix(k, m, w);
  printf("Vandermonde Coding Matrix:\n\n");
  jerasure_print_matrix(matrix, m, k, w);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1199 <main+0x29>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe58(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
je     11c5 <main+0x55>
cmpl   $0x0,-0x14(%rbp)
jg     11d1 <main+0x61>
lea    0xe37(%rip),%rdi
call   1080 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe20(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
je     11fd <main+0x8d>
cmpl   $0x0,-0x1c(%rbp)
jg     1209 <main+0x99>
lea    0xe05(%rip),%rdi
call   1080 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xde8(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
je     123f <main+0xcf>
cmpl   $0x0,-0x18(%rbp)
jle    123f <main+0xcf>
cmpl   $0x20,-0x18(%rbp)
jle    124b <main+0xdb>
lea    0xdc9(%rip),%rdi
call   1080 <usage@plt>
cmpl   $0x1e,-0x18(%rbp)
jg     127b <main+0x10b>
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jle    127b <main+0x10b>
lea    0xd9f(%rip),%rdi
call   1080 <usage@plt>
mov    -0x14(%rbp),%edi
add    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <reed_sol_extended_vandermonde_matrix@plt>
mov    %rax,-0x28(%rbp)
lea    0xd8f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
add    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <reed_sol_big_vandermonde_distribution_matrix@plt>
mov    %rax,-0x28(%rbp)
lea    0xd6c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd49(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <reed_sol_vandermonde_coding_matrix@plt>
mov    %rax,-0x28(%rbp)
lea    0xd50(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd0d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
je     1194 <main+0x14>
xor    %edi,%edi
call   1090 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe61(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     11b5 <main+0x35>
cmpl   $0x0,0xc(%rsp)
jg     11c1 <main+0x41>
lea    0xe47(%rip),%rdi
call   1090 <usage@plt>
mov    0x10(%rbx),%rdi
lea    0xe34(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     11e2 <main+0x62>
cmpl   $0x0,0x4(%rsp)
jg     11ee <main+0x6e>
lea    0xe20(%rip),%rdi
call   1090 <usage@plt>
mov    0x18(%rbx),%rdi
lea    0xe07(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     1215 <main+0x95>
mov    0x8(%rsp),%edx
test   %edx,%edx
jle    1215 <main+0x95>
cmp    $0x21,%edx
jl     1225 <main+0xa5>
lea    0xdf3(%rip),%rdi
call   1090 <usage@plt>
mov    0x8(%rsp),%edx
cmp    $0x1e,%edx
jg     124f <main+0xcf>
mov    0x4(%rsp),%eax
add    0xc(%rsp),%eax
mov    $0x1,%esi
mov    %edx,%ecx
shl    %cl,%esi
cmp    %esi,%eax
jle    124f <main+0xcf>
lea    0xdcf(%rip),%rdi
call   1090 <usage@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%esi
mov    0x4(%rsp),%edi
add    %esi,%edi
call   1060 <reed_sol_extended_vandermonde_matrix@plt>
mov    %rax,%rbx
lea    0xdbe(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edx
mov    0x4(%rsp),%esi
add    %edx,%esi
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
call   1070 <jerasure_print_matrix@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
mov    0x4(%rsp),%edi
add    %esi,%edi
mov    0x8(%rsp),%edx
call   10a0 <reed_sol_big_vandermonde_distribution_matrix@plt>
mov    %rax,%rbx
lea    0xd9a(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edx
mov    0x4(%rsp),%esi
add    %edx,%esi
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
call   1070 <jerasure_print_matrix@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%edi
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
call   1050 <reed_sol_vandermonde_coding_matrix@plt>
mov    %rax,%rbx
lea    0xd7c(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
call   1070 <jerasure_print_matrix@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"Bad k\00"
@.str.2 = [6 x i8] c"Bad m\00"
@.str.3 = [6 x i8] c"Bad w\00"
@.str.4 = [17 x i8] c"k + m is too big\00"
@.str.5 = [31 x i8] c"Extended Vandermonde Matrix:\0A\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [35 x i8] c"Vandermonde Distribution Matrix:\0A\0A\00"
@.str.8 = [29 x i8] c"Vandermonde Coding Matrix:\0A\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 i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @usage(i8* null)
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = load i32, i32* %6
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20, %14
%24 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %25
%32 = load i32, i32* %8
%33 = icmp sle i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31, %25
%35 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call i64 @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%41 = icmp eq i64 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %36
%43 = load i32, i32* %7
%44 = icmp sle i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = load i32, i32* %7
%47 = icmp sgt i32 %46, 32
br i1 %47, label %48, label %50
48: ; preds = %45, %42, %36
%49 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = load i32, i32* %7
%52 = icmp sle i32 %51, 30
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = load i32, i32* %6
%55 = load i32, i32* %8
%56 = add nsw i32 %54, %55
%57 = load i32, i32* %7
%58 = shl i32 1, %57
%59 = icmp sgt i32 %56, %58
br i1 %59, label %60, label %62
60: ; preds = %53
%61 = call i32 @usage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %53, %50
%63 = load i32, i32* %6
%64 = load i32, i32* %8
%65 = add nsw i32 %63, %64
%66 = load i32, i32* %6
%67 = load i32, i32* %7
%68 = call i32* @reed_sol_extended_vandermonde_matrix(i32 %65, i32 %66, i32 %67)
store i32* %68, i32** %9
%69 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%70 = load i32*, i32** %9
%71 = load i32, i32* %6
%72 = load i32, i32* %8
%73 = add nsw i32 %71, %72
%74 = load i32, i32* %6
%75 = load i32, i32* %7
%76 = call i32 @jerasure_print_matrix(i32* %70, i32 %73, i32 %74, i32 %75)
%77 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* %6
%79 = load i32, i32* %8
%80 = add nsw i32 %78, %79
%81 = load i32, i32* %6
%82 = load i32, i32* %7
%83 = call i32* @reed_sol_big_vandermonde_distribution_matrix(i32 %80, i32 %81, i32 %82)
store i32* %83, i32** %9
%84 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%85 = load i32*, i32** %9
%86 = load i32, i32* %6
%87 = load i32, i32* %8
%88 = add nsw i32 %86, %87
%89 = load i32, i32* %6
%90 = load i32, i32* %7
%91 = call i32 @jerasure_print_matrix(i32* %85, i32 %88, i32 %89, i32 %90)
%92 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%93 = load i32, i32* %6
%94 = load i32, i32* %8
%95 = load i32, i32* %7
%96 = call i32* @reed_sol_vandermonde_coding_matrix(i32 %93, i32 %94, i32 %95)
store i32* %96, i32** %9
%97 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%98 = load i32*, i32** %9
%99 = load i32, i32* %8
%100 = load i32, i32* %6
%101 = load i32, i32* %7
%102 = call i32 @jerasure_print_matrix(i32* %98, i32 %99, i32 %100, i32 %101)
%103 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"Bad k\00"
@.str.2 = [6 x i8] c"Bad m\00"
@.str.3 = [6 x i8] c"Bad w\00"
@.str.4 = [17 x i8] c"k + m is too big\00"
@str = [30 x i8] c"Extended Vandermonde Matrix:\0A\00"
@str.9 = [34 x i8] c"Vandermonde Distribution Matrix:\0A\00"
@str.10 = [28 x i8] c"Vandermonde Coding Matrix:\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 4
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @usage(i8* null)
br label %12
12: ; preds = %10, %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 1
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %12, %20
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i64 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%26 = icmp eq i64 %25, 0
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 1
%29 = select i1 %26, i1 true, i1 %28
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %22, %30
%33 = getelementptr inbounds i8*, i8** %1, i64 3
%34 = load i8*, i8** %33
%35 = call i64 @sscanf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%36 = icmp eq i64 %35, 0
%37 = load i32, i32* %4
%38 = icmp slt i32 %37, 1
%39 = select i1 %36, i1 true, i1 %38
%40 = icmp sgt i32 %37, 32
%41 = select i1 %39, i1 true, i1 %40
br i1 %41, label %42, label %45
42: ; preds = %32
%43 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* %4
br label %45
45: ; preds = %32, %42
%46 = phi i32 [ %37, %32 ], [ %44, %42 ]
%47 = icmp slt i32 %46, 31
br i1 %47, label %48, label %57
48: ; preds = %45
%49 = load i32, i32* %3
%50 = load i32, i32* %5
%51 = add nsw i32 %50, %49
%52 = shl nuw nsw i32 1, %46
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %57
54: ; preds = %48
%55 = call i32 @usage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%56 = load i32, i32* %4
br label %57
57: ; preds = %54, %48, %45
%58 = phi i32 [ %56, %54 ], [ %46, %48 ], [ %46, %45 ]
%59 = load i32, i32* %3
%60 = load i32, i32* %5
%61 = add nsw i32 %60, %59
%62 = call i32* @reed_sol_extended_vandermonde_matrix(i32 %61, i32 %59, i32 %58)
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%64 = load i32, i32* %3
%65 = load i32, i32* %5
%66 = add nsw i32 %65, %64
%67 = load i32, i32* %4
%68 = call i32 @jerasure_print_matrix(i32* %62, i32 %66, i32 %64, i32 %67)
%69 = call i32 @putchar(i32 10)
%70 = load i32, i32* %3
%71 = load i32, i32* %5
%72 = add nsw i32 %71, %70
%73 = load i32, i32* %4
%74 = call i32* @reed_sol_big_vandermonde_distribution_matrix(i32 %72, i32 %70, i32 %73)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
%76 = load i32, i32* %3
%77 = load i32, i32* %5
%78 = add nsw i32 %77, %76
%79 = load i32, i32* %4
%80 = call i32 @jerasure_print_matrix(i32* %74, i32 %78, i32 %76, i32 %79)
%81 = call i32 @putchar(i32 10)
%82 = load i32, i32* %3
%83 = load i32, i32* %5
%84 = load i32, i32* %4
%85 = call i32* @reed_sol_vandermonde_coding_matrix(i32 %82, i32 %83, i32 %84)
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
%87 = load i32, i32* %5
%88 = load i32, i32* %3
%89 = load i32, i32* %4
%90 = call i32 @jerasure_print_matrix(i32* %85, i32 %87, i32 %88, i32 %89)
%91 = call i32 @putchar(i32 10)
ret i32 0
}