#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 *, ...);
int /*<<< orphan*/ read_data_system(int, int, int, int *);
int /*<<< orphan*/ scanf(char *, int *);
void test_cosup_poly_system(void) {
  int n, m;
  printf("\nCreating a system from coefficients and supports.\n\n");
  printf("Give the number of variables : ");
  scanf("%d", &n);
  printf("Give the number of equations : ");
  scanf("%d", &m);
  {
    int i, moncnt[m], monsum = 0;
    printf("Reading the number of monomials in every polynomial...\n");
    for (i = 0; i < m; i++) {
      printf("  Give #monomials in polynomial %d : ", i + 1);
      scanf("%d", &moncnt[i]);
    }
    printf("The monomial count : ");
    for (i = 0; i < m; i++) {
      printf(" %d", moncnt[i]);
      monsum += moncnt[i];
    }
    printf(" and the sum is %d.\n", monsum);
    read_data_system(n, m, monsum, moncnt);
  }
}


x86 assembly (clang, -O0):
<test_cosup_poly_system>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x39(%rbp)
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xee2(%rip),%rdi
call   1040 <printf@plt>
lea    0xf8b(%rip),%rdi
mov    %rdi,-0x38(%rbp)
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x39(%rbp),%al
lea    0xedf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1214 <test_cosup_poly_system+0xe4>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xee9(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cb <test_cosup_poly_system+0x9b>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126d <test_cosup_poly_system+0x13d>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1229 <test_cosup_poly_system+0xf9>
mov    -0x24(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rcx
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <read_data_system@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_cosup_poly_system>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf08(%rip),%rbx
lea    -0x30(%rbp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x2c(%rbp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    120d <test_cosup_poly_system+0xcd>
lea    0xead(%rip),%r12
mov    %r14,%rbx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
lea    0xe55(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r15
jl     11e0 <test_cosup_poly_system+0xa0>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    124f <test_cosup_poly_system+0x10f>
lea    0xe54(%rip),%r15
xor    %ebx,%ebx
xor    %r13d,%r13d
nopl   (%rax)
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    (%r14,%rbx,4),%r13d
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1230 <test_cosup_poly_system+0xf0>
lea    0xe2a(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    %r13d,%edx
mov    %r14,%rcx
call   1040 <read_data_system@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"\0ACreating a system from coefficients and supports.\0A\0A\00"
@.str.1 = [32 x i8] c"Give the number of variables : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Give the number of equations : \00"
@.str.4 = [56 x i8] c"Reading the number of monomials in every polynomial...\0A\00"
@.str.5 = [38 x i8] c" Give #monomials in polynomial %d : \00"
@.str.6 = [22 x i8] c"The monomial count : \00"
@.str.7 = [4 x i8] c" %d\00"
@.str.8 = [21 x i8] c" and the sum is %d.\0A\00"
define void @test_cosup_poly_system() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %4
%15 = alloca i32, i64 %13
store i64 %13, i64* %5
store i32 0, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %17
17: ; preds = %29, %0
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %15, i64 %26
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %17
32: ; preds = %17
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %34
34: ; preds = %50, %32
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %53
38: ; preds = %34
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %15, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %15, i64 %45
%47 = load i32, i32* %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, %47
store i32 %49, i32* %6
br label %50
50: ; preds = %38
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %34
53: ; preds = %34
%54 = load i32, i32* %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %1
%57 = load i32, i32* %2
%58 = load i32, i32* %6
%59 = call i32 @read_data_system(i32 %56, i32 %57, i32 %58, i32* %15)
%60 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"Give the number of variables : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Give the number of equations : \00"
@.str.5 = [38 x i8] c" Give #monomials in polynomial %d : \00"
@.str.6 = [22 x i8] c"The monomial count : \00"
@.str.7 = [4 x i8] c" %d\00"
@.str.8 = [21 x i8] c" and the sum is %d.\0A\00"
@str = [52 x i8] c"\0ACreating a system from coefficients and supports.\0A\00"
@str.9 = [55 x i8] c"Reading the number of monomials in every polynomial...\00"
define void @test_cosup_poly_system() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
%13 = alloca i32, i64 %11
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.9, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %0, %17
%18 = phi i64 [ %19, %17 ], [ 0, %0 ]
%19 = add nuw nsw i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds i32, i32* %13, i64 %18
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %19, %25
br i1 %26, label %17, label %27
27: ; preds = %17, %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%29 = load i32, i32* %2
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %27, %31
%32 = phi i64 [ %39, %31 ], [ 0, %27 ]
%33 = phi i32 [ %38, %31 ], [ 0, %27 ]
%34 = getelementptr inbounds i32, i32* %13, i64 %32
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %34
%38 = add nsw i32 %37, %33
%39 = add nuw nsw i64 %32, 1
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %31, label %43
43: ; preds = %31, %27
%44 = phi i32 [ 0, %27 ], [ %38, %31 ]
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %1
%47 = load i32, i32* %2
%48 = call i32 @read_data_system(i32 %46, i32 %47, i32 %44, i32* %13)
ret void
}