#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 ass(float);
int exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
float valutaHorner(float *, float);
int main() {
  int grado = 0;
  int i = 0;
  float dimInt = 0;
  float c[10 + 1] = {0};
  float a, b;
  float integrale = 0;
  int M;
  printf("Grado del polinomio? ");
  scanf("%d", &grado);
  (grado <= 10 && grado > 0) ? 1 : (exit(-1));
  for (i = 0; i < grado + 1; i++) {
    printf("Coefficiente termine di grado %d:", i);
    scanf("%f", &c[i]);
  }
  printf("Estremo a: ");
  scanf("%f", &a);
  printf("Estremo b: ");
  scanf("%f", &b);
  printf("Sottointervalli: ");
  scanf("%d", &M);
  dimInt = ass(a - b) / M;
  for (i = 0; i < M; i++) {
    integrale += valutaHorner(c, (a + dimInt / 2 + i * dimInt)) * dimInt;
  }
  printf("L'integrale vale: %.4f", integrale);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2c,%edx
call   1050 <memset@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmpl   $0xa,-0x8(%rbp)
jg     11d6 <main+0x76>
cmpl   $0x0,-0x8(%rbp)
jle    11d6 <main+0x76>
jmp    11e0 <main+0x80>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1234 <main+0xd4>
mov    -0xc(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0xc(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <main+0x87>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf6(%rip),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd6(%rip),%rdi
lea    -0x48(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd91(%rip),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0x44(%rbp),%xmm0
subss  -0x48(%rbp),%xmm0
call   1030 <ass@plt>
cltd
idivl  -0x50(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    131d <main+0x1bd>
lea    -0x40(%rbp),%rdi
movss  -0x44(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movss  0xd27(%rip),%xmm2
divss  %xmm2,%xmm0
addss  %xmm0,%xmm1
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1060 <valutaHorner@plt>
movss  -0x10(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12b7 <main+0x157>
movss  -0x4c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd3f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
movl   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x3c(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x9,%eax
ja     1326 <main+0x1d6>
mov    $0xffffffffffffffff,%rbx
lea    0x20(%rsp),%r14
lea    0xe63(%rip),%r15
lea    0xe7e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movslq 0x8(%rsp),%rax
add    $0x4,%r14
cmp    %rax,%rbx
jl     11d0 <main+0x80>
lea    0xe40(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2d(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc7(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  0x14(%rsp),%xmm0
subss  0x1c(%rsp),%xmm0
call   1030 <ass@plt>
mov    0x10(%rsp),%ecx
cltd
idiv   %ecx
test   %ecx,%ecx
jle    1306 <main+0x1b6>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xd72(%rip),%xmm1
movss  %xmm0,0xc(%rsp)
mulss  %xmm0,%xmm1
movss  %xmm1,0x18(%rsp)
xorps  %xmm0,%xmm0
lea    0x20(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movss  0x14(%rsp),%xmm1
addss  0x18(%rsp),%xmm1
mulss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
mov    %rbx,%rdi
call   1050 <valutaHorner@plt>
mulss  0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
add    $0x1,%ebp
cmp    0x10(%rsp),%ebp
jl     12b0 <main+0x160>
cvtss2sd %xmm0,%xmm0
jmp    1309 <main+0x1b9>
xorps  %xmm0,%xmm0
lea    0xd5c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Grado del polinomio? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Coefficiente termine di grado %d:\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [12 x i8] c"Estremo a: \00"
@.str.5 = [12 x i8] c"Estremo b: \00"
@.str.6 = [18 x i8] c"Sottointervalli: \00"
@.str.7 = [23 x i8] c"L'integrale vale: %.4f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca [11 x float]
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store float 0.000000e+00, float* %4
%10 = bitcast [11 x float]* %5 to i8*
store float 0.000000e+00, float* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 10
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
br label %22
19: ; preds = %15, %0
%20 = call i32 @exit(i32 -1)
unreachable
21: ; No predecessors!
br label %22
22: ; preds = %21, %18
%23 = phi i32 [ 1, %18 ], [ undef, %21 ]
store i32 0, i32* %3
br label %24
24: ; preds = %36, %22
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %39
29: ; preds = %24
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [11 x float], [11 x float]* %5, i64 0, i64 %33
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %34)
br label %36
36: ; preds = %29
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %24
39: ; preds = %24
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %7)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%46 = load float, float* %6
%47 = load float, float* %7
%48 = fsub float %46, %47
%49 = call i32 @ass(float %48)
%50 = load i32, i32* %9
%51 = sdiv i32 %49, %50
%52 = sitofp i32 %51 to float
store float %52, float* %4
store i32 0, i32* %3
br label %53
53: ; preds = %71, %39
%54 = load i32, i32* %3
%55 = load i32, i32* %9
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %74
57: ; preds = %53
%58 = getelementptr inbounds [11 x float], [11 x float]* %5, i64 0, i64 0
%59 = load float, float* %6
%60 = load float, float* %4
%61 = fdiv float %60, 2.000000e+00
%62 = fadd float %59, %61
%63 = load i32, i32* %3
%64 = sitofp i32 %63 to float
%65 = load float, float* %4
%66 = call float @llvm.fmuladd.f32(float %64, float %65, float %62)
%67 = call float @valutaHorner(float* %58, float %66)
%68 = load float, float* %4
%69 = load float, float* %8
%70 = call float @llvm.fmuladd.f32(float %67, float %68, float %69)
store float %70, float* %8
br label %71
71: ; preds = %57
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 1
store i32 %73, i32* %3
br label %53
74: ; preds = %53
%75 = load float, float* %8
%76 = fpext float %75 to double
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), double %76)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Grado del polinomio? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Coefficiente termine di grado %d:\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [12 x i8] c"Estremo a: \00"
@.str.5 = [12 x i8] c"Estremo b: \00"
@.str.6 = [18 x i8] c"Sottointervalli: \00"
@.str.7 = [23 x i8] c"L'integrale vale: %.4f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x float]
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%7 = bitcast [11 x float]* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = add i32 %13, -1
%15 = icmp ult i32 %14, 10
br i1 %15, label %18, label %16
16: ; preds = %0
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %0, %18
%19 = phi i64 [ %24, %18 ], [ 0, %0 ]
%20 = trunc i64 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [11 x float], [11 x float]* %2, i64 0, i64 %19
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %22)
%24 = add nuw nsw i64 %19, 1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %19, %26
br i1 %27, label %18, label %28
28: ; preds = %18
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%35 = load float, float* %3
%36 = load float, float* %4
%37 = fsub float %35, %36
%38 = call i32 @ass(float %37)
%39 = load i32, i32* %5
%40 = sdiv i32 %38, %39
%41 = sitofp i32 %40 to float
%42 = icmp sgt i32 %39, 0
br i1 %42, label %43, label %60
43: ; preds = %28
%44 = getelementptr inbounds [11 x float], [11 x float]* %2, i64 0, i64 0
%45 = fmul float %41, 5.000000e-01
br label %46
46: ; preds = %43, %46
%47 = phi float [ 0.000000e+00, %43 ], [ %54, %46 ]
%48 = phi i32 [ 0, %43 ], [ %55, %46 ]
%49 = load float, float* %3
%50 = fadd float %45, %49
%51 = sitofp i32 %48 to float
%52 = call float @llvm.fmuladd.f32(float %51, float %41, float %50)
%53 = call float @valutaHorner(float* %44, float %52)
%54 = call float @llvm.fmuladd.f32(float %53, float %41, float %47)
%55 = add nuw nsw i32 %48, 1
%56 = load i32, i32* %5
%57 = icmp slt i32 %55, %56
br i1 %57, label %46, label %58
58: ; preds = %46
%59 = fpext float %54 to double
br label %60
60: ; preds = %58, %28
%61 = phi double [ 0.000000e+00, %28 ], [ %59, %58 ]
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), double %61)
ret i32 0
}