#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) {
  long l;
  int k, w, i, j, 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    $0x40,%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    -0x1c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
je     11c5 <main+0x55>
cmpl   $0x0,-0x1c(%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    -0x2c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
je     11fd <main+0x8d>
cmpl   $0x0,-0x2c(%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    -0x20(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
je     123f <main+0xcf>
cmpl   $0x0,-0x20(%rbp)
jle    123f <main+0xcf>
cmpl   $0x20,-0x20(%rbp)
jle    124b <main+0xdb>
lea    0xdc9(%rip),%rdi
call   1080 <usage@plt>
cmpl   $0x1e,-0x20(%rbp)
jg     127b <main+0x10b>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    -0x20(%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    -0x1c(%rbp),%edi
add    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <reed_sol_extended_vandermonde_matrix@plt>
mov    %rax,-0x38(%rbp)
lea    0xd8f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
add    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1090 <reed_sol_big_vandermonde_distribution_matrix@plt>
mov    %rax,-0x38(%rbp)
lea    0xd6c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd49(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <reed_sol_vandermonde_coding_matrix@plt>
mov    %rax,-0x38(%rbp)
lea    0xd50(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd0d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%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 i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @usage(i8* null)
br label %17
17: ; preds = %15, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = load i32, i32* %7
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23, %17
%27 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i64 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = load i32, i32* %11
%36 = icmp sle i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34, %28
%38 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i64 @sscanf(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%44 = icmp eq i64 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %39
%46 = load i32, i32* %8
%47 = icmp sle i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* %8
%50 = icmp sgt i32 %49, 32
br i1 %50, label %51, label %53
51: ; preds = %48, %45, %39
%52 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %51, %48
%54 = load i32, i32* %8
%55 = icmp sle i32 %54, 30
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = load i32, i32* %7
%58 = load i32, i32* %11
%59 = add nsw i32 %57, %58
%60 = load i32, i32* %8
%61 = shl i32 1, %60
%62 = icmp sgt i32 %59, %61
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = call i32 @usage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %65
65: ; preds = %63, %56, %53
%66 = load i32, i32* %7
%67 = load i32, i32* %11
%68 = add nsw i32 %66, %67
%69 = load i32, i32* %7
%70 = load i32, i32* %8
%71 = call i32* @reed_sol_extended_vandermonde_matrix(i32 %68, i32 %69, i32 %70)
store i32* %71, i32** %12
%72 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32*, i32** %12
%74 = load i32, i32* %7
%75 = load i32, i32* %11
%76 = add nsw i32 %74, %75
%77 = load i32, i32* %7
%78 = load i32, i32* %8
%79 = call i32 @jerasure_print_matrix(i32* %73, i32 %76, i32 %77, i32 %78)
%80 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%81 = load i32, i32* %7
%82 = load i32, i32* %11
%83 = add nsw i32 %81, %82
%84 = load i32, i32* %7
%85 = load i32, i32* %8
%86 = call i32* @reed_sol_big_vandermonde_distribution_matrix(i32 %83, i32 %84, i32 %85)
store i32* %86, i32** %12
%87 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%88 = load i32*, i32** %12
%89 = load i32, i32* %7
%90 = load i32, i32* %11
%91 = add nsw i32 %89, %90
%92 = load i32, i32* %7
%93 = load i32, i32* %8
%94 = call i32 @jerasure_print_matrix(i32* %88, i32 %91, i32 %92, i32 %93)
%95 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%96 = load i32, i32* %7
%97 = load i32, i32* %11
%98 = load i32, i32* %8
%99 = call i32* @reed_sol_vandermonde_coding_matrix(i32 %96, i32 %97, i32 %98)
store i32* %99, i32** %12
%100 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%101 = load i32*, i32** %12
%102 = load i32, i32* %11
%103 = load i32, i32* %7
%104 = load i32, i32* %8
%105 = call i32 @jerasure_print_matrix(i32* %101, i32 %102, i32 %103, i32 %104)
%106 = 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
}