#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 syscon_number_of_standard_terms(int, int *);
int number_of_standard_terms(int neq, int *nbterms, int *nbtsum, int verbose) {
  int fail, idx, nbt;
  *nbtsum = 0;
  for (idx = 1; idx <= neq; idx++) {
    fail = syscon_number_of_standard_terms(idx, &nbt);
    if (verbose > 0)
      printf("  #terms in polynomial %d : %d\n", idx, nbt);
    nbterms[idx - 1] = nbt;
    *nbtsum = *nbtsum + nbt;
  }
  if (verbose > 0) {
    printf("Total number of terms : %d = %d", *nbtsum, nbterms[0]);
    for (idx = 1; idx < neq; idx++)
      printf(" + %d", nbterms[idx]);
    printf("\n");
  }
  return fail;
}


x86 assembly (clang, -O0):
<number_of_standard_terms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b0 <number_of_standard_terms+0x90>
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1040 <syscon_number_of_standard_terms@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1180 <number_of_standard_terms+0x60>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <number_of_standard_terms+0x27>
cmpl   $0x0,-0x1c(%rbp)
jle    121c <number_of_standard_terms+0xfc>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    120e <number_of_standard_terms+0xee>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11db <number_of_standard_terms+0xbb>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_of_standard_terms>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r13d
mov    %rsi,%r12
mov    %edi,%ebp
movl   $0x0,(%rdx)
test   %edi,%edi
jle    11bc <number_of_standard_terms+0x8c>
mov    %rdx,%rbx
mov    %rbp,0x10(%rsp)
lea    0x1(%rbp),%r14d
mov    $0x1,%ebp
jmp    1186 <number_of_standard_terms+0x56>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%esi
mov    %esi,-0x4(%r12,%rbp,4)
add    (%rbx),%esi
mov    %esi,(%rbx)
add    $0x1,%rbp
cmp    %rbp,%r14
je     11b0 <number_of_standard_terms+0x80>
mov    %ebp,%edi
lea    0xc(%rsp),%rsi
call   1050 <syscon_number_of_standard_terms@plt>
mov    %eax,%r15d
test   %r13d,%r13d
jle    1170 <number_of_standard_terms+0x40>
mov    0xc(%rsp),%edx
lea    0xe5b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <number_of_standard_terms+0x40>
mov    0x10(%rsp),%rbp
test   %r13d,%r13d
jg     11c3 <number_of_standard_terms+0x93>
jmp    1211 <number_of_standard_terms+0xe1>
xor    %esi,%esi
test   %r13d,%r13d
jle    1211 <number_of_standard_terms+0xe1>
mov    (%r12),%edx
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jl     1207 <number_of_standard_terms+0xd7>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xe58(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11f0 <number_of_standard_terms+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c" #terms in polynomial %d : %d\0A\00"
@.str.1 = [32 x i8] c"Total number of terms : %d = %d\00"
@.str.2 = [6 x i8] c" + %d\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @number_of_standard_terms(i32 %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%12 = load i32*, i32** %7
store i32 0, i32* %12
store i32 1, i32* %10
br label %13
13: ; preds = %38, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %5
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %41
17: ; preds = %13
%18 = load i32, i32* %10
%19 = call i32 @syscon_number_of_standard_terms(i32 %18, i32* %11)
store i32 %19, i32* %9
%20 = load i32, i32* %8
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i32, i32* %10
%24 = load i32, i32* %11
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
br label %26
26: ; preds = %22, %17
%27 = load i32, i32* %11
%28 = load i32*, i32** %6
%29 = load i32, i32* %10
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %28, i64 %31
store i32 %27, i32* %32
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
%35 = load i32, i32* %11
%36 = add nsw i32 %34, %35
%37 = load i32*, i32** %7
store i32 %36, i32* %37
br label %38
38: ; preds = %26
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %13
41: ; preds = %13
%42 = load i32, i32* %8
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %67
44: ; preds = %41
%45 = load i32*, i32** %7
%46 = load i32, i32* %45
%47 = load i32*, i32** %6
%48 = getelementptr inbounds i32, i32* %47, i64 0
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %46, i32 %49)
store i32 1, i32* %10
br label %51
51: ; preds = %62, %44
%52 = load i32, i32* %10
%53 = load i32, i32* %5
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %65
55: ; preds = %51
%56 = load i32*, i32** %6
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %56, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %55
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %51
65: ; preds = %51
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %41
%68 = load i32, i32* %9
ret i32 %68
}

LLVM IR (-O2):
@.str = [32 x i8] c" #terms in polynomial %d : %d\0A\00"
@.str.1 = [32 x i8] c"Total number of terms : %d = %d\00"
@.str.2 = [6 x i8] c" + %d\00"
define i32 @number_of_standard_terms(i32 %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
store i32 0, i32* %2
%7 = icmp slt i32 %0, 1
br i1 %7, label %27, label %8
8: ; preds = %4
%9 = icmp sgt i32 %3, 0
%10 = add nuw i32 %0, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %8, %19
%13 = phi i64 [ 1, %8 ], [ %25, %19 ]
%14 = trunc i64 %13 to i32
%15 = call i32 @syscon_number_of_standard_terms(i32 %14, i32* %5)
br i1 %9, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %17)
br label %19
19: ; preds = %16, %12
%20 = load i32, i32* %5
%21 = add nsw i64 %13, -1
%22 = getelementptr inbounds i32, i32* %1, i64 %21
store i32 %20, i32* %22
%23 = load i32, i32* %2
%24 = add nsw i32 %23, %20
store i32 %24, i32* %2
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %12
27: ; preds = %19, %4
%28 = phi i32 [ 0, %4 ], [ %24, %19 ]
%29 = phi i32 [ undef, %4 ], [ %15, %19 ]
%30 = icmp sgt i32 %3, 0
br i1 %30, label %31, label %46
31: ; preds = %27
%32 = load i32, i32* %1
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %32)
%34 = icmp sgt i32 %0, 1
br i1 %34, label %35, label %44
35: ; preds = %31
%36 = zext i32 %0 to i64
br label %37
37: ; preds = %35, %37
%38 = phi i64 [ 1, %35 ], [ %42, %37 ]
%39 = getelementptr inbounds i32, i32* %1, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = add nuw nsw i64 %38, 1
%43 = icmp eq i64 %42, %36
br i1 %43, label %44, label %37
44: ; preds = %37, %31
%45 = call i32 @putchar(i32 10)
br label %46
46: ; preds = %44, %27
ret i32 %29
}