#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]);
    }
    for (i = 0; i < m; i++)
      monsum += moncnt[i];
    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    0xef6(%rip),%rdi
mov    %rdi,-0x38(%rbp)
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x39(%rbp),%al
lea    0xee2(%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    0xebb(%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    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe54(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cb <test_cosup_poly_system+0x9b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1246 <test_cosup_poly_system+0x116>
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    121b <test_cosup_poly_system+0xeb>
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    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%r14
lea    -0x3c(%rbp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    132d <test_cosup_poly_system+0x1ed>
mov    %r15,-0x38(%rbp)
lea    0xe6c(%rip),%r15
lea    0xe42(%rip),%r12
mov    %r14,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
movslq -0x2c(%rbp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11f0 <test_cosup_poly_system+0xb0>
test   %esi,%esi
jle    1230 <test_cosup_poly_system+0xf0>
mov    %esi,%eax
cmp    $0x8,%esi
jae    123b <test_cosup_poly_system+0xfb>
xor    %ecx,%ecx
xor    %ebx,%ebx
mov    -0x38(%rbp),%r15
jmp    1320 <test_cosup_poly_system+0x1e0>
xor    %ebx,%ebx
mov    -0x38(%rbp),%r15
jmp    132d <test_cosup_poly_system+0x1ed>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%rdi
mov    %rdi,%rdx
shr    $0x3,%rdx
add    $0x1,%rdx
mov    %edx,%ebx
and    $0x3,%ebx
cmp    $0x18,%rdi
mov    -0x38(%rbp),%r15
jae    126a <test_cosup_poly_system+0x12a>
pxor   %xmm0,%xmm0
xor    %edi,%edi
pxor   %xmm1,%xmm1
jmp    12c1 <test_cosup_poly_system+0x181>
and    $0xfffffffffffffffc,%rdx
pxor   %xmm0,%xmm0
xor    %edi,%edi
pxor   %xmm1,%xmm1
nopl   0x0(%rax,%rax,1)
paddd  (%r14,%rdi,4),%xmm0
paddd  0x10(%r14,%rdi,4),%xmm1
paddd  0x20(%r14,%rdi,4),%xmm0
paddd  0x30(%r14,%rdi,4),%xmm1
paddd  0x40(%r14,%rdi,4),%xmm0
paddd  0x50(%r14,%rdi,4),%xmm1
paddd  0x60(%r14,%rdi,4),%xmm0
paddd  0x70(%r14,%rdi,4),%xmm1
add    $0x20,%rdi
add    $0xfffffffffffffffc,%rdx
jne    1280 <test_cosup_poly_system+0x140>
test   %rbx,%rbx
je     12f4 <test_cosup_poly_system+0x1b4>
lea    (%r14,%rdi,4),%rdx
add    $0x10,%rdx
shl    $0x5,%rbx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
paddd  -0x10(%rdx,%rdi,1),%xmm0
paddd  (%rdx,%rdi,1),%xmm1
add    $0x20,%rdi
cmp    %rdi,%rbx
jne    12e0 <test_cosup_poly_system+0x1a0>
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%ebx
cmp    %rax,%rcx
je     132d <test_cosup_poly_system+0x1ed>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    (%r14,%rcx,4),%ebx
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1320 <test_cosup_poly_system+0x1e0>
mov    -0x3c(%rbp),%edi
mov    %ebx,%edx
mov    %r14,%rcx
call   1040 <read_data_system@plt>
mov    %r15,%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"
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
store i32 0, i32* %3
br label %33
33: ; preds = %44, %32
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %15, i64 %39
%41 = load i32, i32* %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, %41
store i32 %43, i32* %6
br label %44
44: ; preds = %37
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %33
47: ; preds = %33
%48 = load i32, i32* %1
%49 = load i32, i32* %2
%50 = load i32, i32* %6
%51 = call i32 @read_data_system(i32 %48, i32 %49, i32 %50, i32* %15)
%52 = 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 = [52 x i8] c"\0ACreating a system from coefficients and supports.\0A\00"
@str.6 = [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.6, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %106, label %124
17: ; preds = %106
%18 = icmp sgt i32 %113, 0
br i1 %18, label %19, label %124
19: ; preds = %17
%20 = zext i32 %113 to i64
%21 = icmp ult i32 %113, 8
br i1 %21, label %103, label %22
22: ; preds = %19
%23 = and i64 %20, 4294967288
%24 = add nsw i64 %23, -8
%25 = lshr exact i64 %24, 3
%26 = add nuw nsw i64 %25, 1
%27 = and i64 %26, 3
%28 = icmp ult i64 %24, 24
br i1 %28, label %74, label %29
29: ; preds = %22
%30 = and i64 %26, 4611686018427387900
br label %31
31: ; preds = %31, %29
%32 = phi i64 [ 0, %29 ], [ %71, %31 ]
%33 = phi <4 x i32> [ zeroinitializer, %29 ], [ %69, %31 ]
%34 = phi <4 x i32> [ zeroinitializer, %29 ], [ %70, %31 ]
%35 = phi i64 [ 0, %29 ], [ %72, %31 ]
%36 = getelementptr inbounds i32, i32* %13, i64 %32
%37 = bitcast i32* %36 to <4 x i32>*
%38 = load <4 x i32>, <4 x i32>* %37
%39 = getelementptr inbounds i32, i32* %36, i64 4
%40 = bitcast i32* %39 to <4 x i32>*
%41 = load <4 x i32>, <4 x i32>* %40
%42 = add <4 x i32> %38, %33
%43 = add <4 x i32> %41, %34
%44 = or i64 %32, 8
%45 = getelementptr inbounds i32, i32* %13, i64 %44
%46 = bitcast i32* %45 to <4 x i32>*
%47 = load <4 x i32>, <4 x i32>* %46
%48 = getelementptr inbounds i32, i32* %45, i64 4
%49 = bitcast i32* %48 to <4 x i32>*
%50 = load <4 x i32>, <4 x i32>* %49
%51 = add <4 x i32> %47, %42
%52 = add <4 x i32> %50, %43
%53 = or i64 %32, 16
%54 = getelementptr inbounds i32, i32* %13, i64 %53
%55 = bitcast i32* %54 to <4 x i32>*
%56 = load <4 x i32>, <4 x i32>* %55
%57 = getelementptr inbounds i32, i32* %54, i64 4
%58 = bitcast i32* %57 to <4 x i32>*
%59 = load <4 x i32>, <4 x i32>* %58
%60 = add <4 x i32> %56, %51
%61 = add <4 x i32> %59, %52
%62 = or i64 %32, 24
%63 = getelementptr inbounds i32, i32* %13, i64 %62
%64 = bitcast i32* %63 to <4 x i32>*
%65 = load <4 x i32>, <4 x i32>* %64
%66 = getelementptr inbounds i32, i32* %63, i64 4
%67 = bitcast i32* %66 to <4 x i32>*
%68 = load <4 x i32>, <4 x i32>* %67
%69 = add <4 x i32> %65, %60
%70 = add <4 x i32> %68, %61
%71 = add nuw i64 %32, 32
%72 = add i64 %35, 4
%73 = icmp eq i64 %72, %30
br i1 %73, label %74, label %31
74: ; preds = %31, %22
%75 = phi <4 x i32> [ undef, %22 ], [ %69, %31 ]
%76 = phi <4 x i32> [ undef, %22 ], [ %70, %31 ]
%77 = phi i64 [ 0, %22 ], [ %71, %31 ]
%78 = phi <4 x i32> [ zeroinitializer, %22 ], [ %69, %31 ]
%79 = phi <4 x i32> [ zeroinitializer, %22 ], [ %70, %31 ]
%80 = icmp eq i64 %27, 0
br i1 %80, label %97, label %81
81: ; preds = %74, %81
%82 = phi i64 [ %94, %81 ], [ %77, %74 ]
%83 = phi <4 x i32> [ %92, %81 ], [ %78, %74 ]
%84 = phi <4 x i32> [ %93, %81 ], [ %79, %74 ]
%85 = phi i64 [ %95, %81 ], [ 0, %74 ]
%86 = getelementptr inbounds i32, i32* %13, i64 %82
%87 = bitcast i32* %86 to <4 x i32>*
%88 = load <4 x i32>, <4 x i32>* %87
%89 = getelementptr inbounds i32, i32* %86, i64 4
%90 = bitcast i32* %89 to <4 x i32>*
%91 = load <4 x i32>, <4 x i32>* %90
%92 = add <4 x i32> %88, %83
%93 = add <4 x i32> %91, %84
%94 = add nuw i64 %82, 8
%95 = add i64 %85, 1
%96 = icmp eq i64 %95, %27
br i1 %96, label %97, label %81
97: ; preds = %81, %74
%98 = phi <4 x i32> [ %75, %74 ], [ %92, %81 ]
%99 = phi <4 x i32> [ %76, %74 ], [ %93, %81 ]
%100 = add <4 x i32> %99, %98
%101 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %100)
%102 = icmp eq i64 %23, %20
br i1 %102, label %124, label %103
103: ; preds = %19, %97
%104 = phi i64 [ 0, %19 ], [ %23, %97 ]
%105 = phi i32 [ 0, %19 ], [ %101, %97 ]
br label %116
106: ; preds = %0, %106
%107 = phi i64 [ %108, %106 ], [ 0, %0 ]
%108 = add nuw nsw i64 %107, 1
%109 = trunc i64 %108 to i32
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %109)
%111 = getelementptr inbounds i32, i32* %13, i64 %107
%112 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %111)
%113 = load i32, i32* %2
%114 = sext i32 %113 to i64
%115 = icmp slt i64 %108, %114
br i1 %115, label %106, label %17
116: ; preds = %103, %116
%117 = phi i64 [ %122, %116 ], [ %104, %103 ]
%118 = phi i32 [ %121, %116 ], [ %105, %103 ]
%119 = getelementptr inbounds i32, i32* %13, i64 %117
%120 = load i32, i32* %119
%121 = add nsw i32 %120, %118
%122 = add nuw nsw i64 %117, 1
%123 = icmp eq i64 %122, %20
br i1 %123, label %124, label %116
124: ; preds = %116, %97, %0, %17
%125 = phi i32 [ %113, %17 ], [ %15, %0 ], [ %113, %97 ], [ %113, %116 ]
%126 = phi i32 [ 0, %17 ], [ 0, %0 ], [ %101, %97 ], [ %121, %116 ]
%127 = load i32, i32* %1
%128 = call i32 @read_data_system(i32 %127, i32 %125, i32 %126, i32* %13)
ret void
}