#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 */
scalar_t__ calloc(int, int);
int number_of_standard_terms(int, int *, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int standard_tableau_form(int, int, int *, double *, int *, int);
int /*<<< orphan*/ store_standard_tableau_form(int, int, int *, double *, int *,
                                               int);
int syscon_clear_standard_system();
int syscon_number_of_standard_polynomials(int *);
int syscon_number_of_symbols(int *);
int syscon_write_standard_system();
int /*<<< orphan*/ write_standard_tableau_form(int, int, int *, double *,
                                               int *);
int make_standard_tableau_form(int verbose) {
  int fail, neq, nvr, nbtsum;
  int *nbterms;
  int *exponents;
  double *coefficients;
  fail = syscon_number_of_standard_polynomials(&neq);
  if (fail != 0)
    return fail;
  fail = syscon_number_of_symbols(&nvr);
  if (fail != 0)
    return fail;
  printf("\nThe number of equations in the system : %d\n", neq);
  printf("The number of variables in the system : %d\n\n", nvr);
  nbterms = (int *)calloc(neq, sizeof(int));
  fail = number_of_standard_terms(neq, nbterms, &nbtsum, 1);
  coefficients = (double *)calloc(2 * nbtsum, sizeof(double));
  exponents = (int *)calloc(nvr * nbtsum, sizeof(int));
  fail = standard_tableau_form(neq, nvr, nbterms, coefficients, exponents,
                               verbose);
  if (fail == 0) {
    printf("The tableau format :\n");
    write_standard_tableau_form(neq, nvr, nbterms, coefficients, exponents);
    fail = syscon_clear_standard_system();
    store_standard_tableau_form(neq, nvr, nbterms, coefficients, exponents,
                                verbose);
    printf("After storing the system defined by the tableau format :\n");
    fail = syscon_write_standard_system();
  }
  return fail;
}


x86 assembly (clang, -O0):
<make_standard_tableau_form>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   10a0 <syscon_number_of_standard_polynomials@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11cc <make_standard_tableau_form+0x2c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f1 <make_standard_tableau_form+0x151>
lea    -0x14(%rbp),%rdi
call   1070 <syscon_number_of_symbols@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11ed <make_standard_tableau_form+0x4d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f1 <make_standard_tableau_form+0x151>
mov    -0x10(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x1,%ecx
call   1050 <number_of_standard_terms@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%edi
shl    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
imul   -0x18(%rbp),%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x8(%rbp),%r9d
call   1080 <standard_tableau_form@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    12eb <make_standard_tableau_form+0x14b>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   10b0 <write_standard_tableau_form@plt>
mov    $0x0,%al
call   1030 <syscon_clear_standard_system@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x8(%rbp),%r9d
call   10c0 <store_standard_tableau_form@plt>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1090 <syscon_write_standard_system@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_standard_tableau_form>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rdi
call   10b0 <syscon_number_of_standard_polynomials@plt>
test   %eax,%eax
jne    12c7 <make_standard_tableau_form+0x117>
lea    0x10(%rsp),%rdi
call   1080 <syscon_number_of_symbols@plt>
test   %eax,%eax
jne    12c7 <make_standard_tableau_form+0x117>
mov    0xc(%rsp),%esi
lea    0xe14(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
lea    0x14(%rsp),%rdx
mov    %rax,%rsi
mov    $0x1,%ecx
call   1060 <number_of_standard_terms@plt>
mov    0x14(%rsp),%edi
add    %edi,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%r15
mov    0x14(%rsp),%edi
imul   0x10(%rsp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%r12
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rax,%r8
mov    %ebx,%r9d
call   1090 <standard_tableau_form@plt>
test   %eax,%eax
jne    12c7 <make_standard_tableau_form+0x117>
lea    0xde1(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   10c0 <write_standard_tableau_form@plt>
xor    %eax,%eax
call   1030 <syscon_clear_standard_system@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %ebx,%r9d
call   10d0 <store_standard_tableau_form@plt>
lea    0xdb4(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10a0 <syscon_write_standard_system@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"\0AThe number of equations in the system : %d\0A\00"
@.str.1 = [45 x i8] c"The number of variables in the system : %d\0A\0A\00"
@.str.2 = [22 x i8] c"The tableau format :\0A\00"
@.str.3 = [58 x i8] c"After storing the system defined by the tableau format :\0A\00"
define i32 @make_standard_tableau_form(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca double*
store i32 %0, i32* %3
%11 = call i32 @syscon_number_of_standard_polynomials(i32* %5)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load i32, i32* %4
store i32 %15, i32* %2
br label %71
16: ; preds = %1
%17 = call i32 @syscon_number_of_symbols(i32* %6)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %71
22: ; preds = %16
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %5
%28 = call i64 @calloc(i32 %27, i32 4)
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %8
%30 = load i32, i32* %5
%31 = load i32*, i32** %8
%32 = call i32 @number_of_standard_terms(i32 %30, i32* %31, i32* %7, i32 1)
store i32 %32, i32* %4
%33 = load i32, i32* %7
%34 = mul nsw i32 2, %33
%35 = call i64 @calloc(i32 %34, i32 8)
%36 = inttoptr i64 %35 to double*
store double* %36, double** %10
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = mul nsw i32 %37, %38
%40 = call i64 @calloc(i32 %39, i32 4)
%41 = inttoptr i64 %40 to i32*
store i32* %41, i32** %9
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = load i32*, i32** %8
%45 = load double*, double** %10
%46 = load i32*, i32** %9
%47 = load i32, i32* %3
%48 = call i32 @standard_tableau_form(i32 %42, i32 %43, i32* %44, double* %45, i32* %46, i32 %47)
store i32 %48, i32* %4
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %69
51: ; preds = %22
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* %5
%54 = load i32, i32* %6
%55 = load i32*, i32** %8
%56 = load double*, double** %10
%57 = load i32*, i32** %9
%58 = call i32 @write_standard_tableau_form(i32 %53, i32 %54, i32* %55, double* %56, i32* %57)
%59 = call i32 (...) @syscon_clear_standard_system()
store i32 %59, i32* %4
%60 = load i32, i32* %5
%61 = load i32, i32* %6
%62 = load i32*, i32** %8
%63 = load double*, double** %10
%64 = load i32*, i32** %9
%65 = load i32, i32* %3
%66 = call i32 @store_standard_tableau_form(i32 %60, i32 %61, i32* %62, double* %63, i32* %64, i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%68 = call i32 (...) @syscon_write_standard_system()
store i32 %68, i32* %4
br label %69
69: ; preds = %51, %22
%70 = load i32, i32* %4
store i32 %70, i32* %2
br label %71
71: ; preds = %69, %20, %14
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@.str = [45 x i8] c"\0AThe number of equations in the system : %d\0A\00"
@.str.1 = [45 x i8] c"The number of variables in the system : %d\0A\0A\00"
@str = [21 x i8] c"The tableau format :\00"
@str.4 = [57 x i8] c"After storing the system defined by the tableau format :\00"
define i32 @make_standard_tableau_form(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 @syscon_number_of_standard_polynomials(i32* %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %47
10: ; preds = %1
%11 = call i32 @syscon_number_of_symbols(i32* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %47
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = call i64 @calloc(i32 %18, i32 4)
%20 = inttoptr i64 %19 to i32*
%21 = load i32, i32* %2
%22 = call i32 @number_of_standard_terms(i32 %21, i32* %20, i32* %4, i32 1)
%23 = load i32, i32* %4
%24 = shl nsw i32 %23, 1
%25 = call i64 @calloc(i32 %24, i32 8)
%26 = inttoptr i64 %25 to double*
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = mul nsw i32 %28, %27
%30 = call i64 @calloc(i32 %29, i32 4)
%31 = inttoptr i64 %30 to i32*
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = call i32 @standard_tableau_form(i32 %32, i32 %33, i32* %20, double* %26, i32* %31, i32 %0)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %47
36: ; preds = %13
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = call i32 @write_standard_tableau_form(i32 %38, i32 %39, i32* %20, double* %26, i32* %31)
%41 = call i32 (...) @syscon_clear_standard_system()
%42 = load i32, i32* %2
%43 = load i32, i32* %3
%44 = call i32 @store_standard_tableau_form(i32 %42, i32 %43, i32* %20, double* %26, i32* %31, i32 %0)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.4, i64 0, i64 0))
%46 = call i32 (...) @syscon_write_standard_system()
br label %47
47: ; preds = %13, %36, %10, %1
%48 = phi i32 [ %8, %1 ], [ %11, %10 ], [ %46, %36 ], [ %34, %13 ]
ret i32 %48
}