int main(void) {
  int i, j;
  float sum, r[(2 * 5) + 1], x[5 + 1], y[5 + 1];
  for (i = 1; i <= 5; i++)
    y[i] = 0.1 * i;
  for (i = 1; i < (2 * 5); i++)
    r[i] = 1.0 / i;
  toeplz(r, x, y, 5);
  printf("Solution vector:\n");
  for (i = 1; i <= 5; i++)
    printf("%7s%1d%s %13f\n", "x[", i, "] =", x[i]);
  printf("\nTest of solution:\n");
  printf("%13s %12s\n", "mtrx*soln", "original");
  for (i = 1; i <= 5; i++) {
    sum = 0.0;
    for (j = 1; j <= 5; j++)
      sum += (r[5 + i - j] * x[j]);
    printf("%12.4f %12.4f\n", sum, y[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     1170 <main+0x50>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xeb8(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x80(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <main+0x19>
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11ae <main+0x8e>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe72(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <main+0x57>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    $0x5,%ecx
mov    $0x0,%al
call   1030 <toeplz@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     1220 <main+0x100>
mov    -0x8(%rbp),%edx
movslq -0x8(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe25(%rip),%rdi
lea    0xe2d(%rip),%rsi
lea    0xe29(%rip),%rcx
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11db <main+0xbb>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe17(%rip),%rdi
lea    0xe1b(%rip),%rsi
lea    0xe1e(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     12e2 <main+0x1c2>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     12af <main+0x18f>
mov    -0x8(%rbp),%eax
add    $0x5,%eax
sub    -0xc(%rbp),%eax
cltq
movss  -0x40(%rbp,%rax,4),%xmm0
movslq -0xc(%rbp),%rax
movss  -0x60(%rbp,%rax,4),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    126a <main+0x14a>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  -0x80(%rbp,%rax,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd9d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1251 <main+0x131>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
movaps 0xebe(%rip),%xmm0
movups %xmm0,0x54(%rsp)
movl   $0x3f000000,0x64(%rsp)
3f
movaps 0xeba(%rip),%xmm0
movups %xmm0,0x24(%rsp)
movaps 0xebe(%rip),%xmm0
movups %xmm0,0x34(%rsp)
movl   $0x3de38e39,0x44(%rsp)
3d
xor    %ebx,%ebx
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
lea    0x50(%rsp),%rdx
mov    $0x5,%ecx
xor    %eax,%eax
call   1030 <toeplz@plt>
lea    0xee6(%rip),%rdi
call   1040 <puts@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8d(%rip),%r12
lea    0xe95(%rip),%r15
lea    0xe91(%rip),%r14
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
mov    %r14,%rcx
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
mov    %r14,%rcx
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
mov    %r14,%rcx
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
mov    %r14,%rcx
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf1(%rip),%rdi
lea    0xdf5(%rip),%rsi
lea    0xdf8(%rip),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf3(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x34(%rsp,%rbx,4),%xmm0
mulss  0x4(%rsp),%xmm0
addss  0xd9c(%rip),%xmm0
movss  0x30(%rsp,%rbx,4),%xmm1
mulss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  0x2c(%rsp,%rbx,4),%xmm0
mulss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  0x28(%rsp,%rbx,4),%xmm1
mulss  0x10(%rsp),%xmm1
movss  0x24(%rsp,%rbx,4),%xmm2
addss  %xmm0,%xmm1
mulss  0x14(%rsp),%xmm2
addss  %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movss  0x54(%rsp,%rbx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r14,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x5,%rbx
jne    1280 <main+0x150>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Solution vector:\0A\00"
@.str.1 = [15 x i8] c"%7s%1d%s %13f\0A\00"
@.str.2 = [3 x i8] c"x[\00"
@.str.3 = [4 x i8] c"] =\00"
@.str.4 = [20 x i8] c"\0ATest of solution:\0A\00"
@.str.5 = [11 x i8] c"%13s %12s\0A\00"
@.str.6 = [10 x i8] c"mtrx*soln\00"
@.str.7 = [9 x i8] c"original\00"
@.str.8 = [15 x i8] c"%12.4f %12.4f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca [11 x float]
%6 = alloca [6 x float]
%7 = alloca [6 x float]
store i32 0, i32* %1
store i32 1, i32* %2
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 5
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sitofp i32 %12 to double
%14 = fmul double 1.000000e-01, %13
%15 = fptrunc double %14 to float
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x float], [6 x float]* %7, i64 0, i64 %17
store float %15, float* %18
br label %19
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %8
22: ; preds = %8
store i32 1, i32* %2
br label %23
23: ; preds = %34, %22
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %37
26: ; preds = %23
%27 = load i32, i32* %2
%28 = sitofp i32 %27 to double
%29 = fdiv double 1.000000e+00, %28
%30 = fptrunc double %29 to float
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [11 x float], [11 x float]* %5, i64 0, i64 %32
store float %30, float* %33
br label %34
34: ; preds = %26
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %23
37: ; preds = %23
%38 = getelementptr inbounds [11 x float], [11 x float]* %5, i64 0, i64 0
%39 = getelementptr inbounds [6 x float], [6 x float]* %6, i64 0, i64 0
%40 = getelementptr inbounds [6 x float], [6 x float]* %7, i64 0, i64 0
%41 = call i32 (float*, float*, float*, i32, ...) bitcast (i32 (...)* @toeplz to i32 (float*, float*, float*, i32, ...)*)(float* %38, float* %39, float* %40, i32 5)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %43
43: ; preds = %54, %37
%44 = load i32, i32* %2
%45 = icmp sle i32 %44, 5
br i1 %45, label %46, label %57
46: ; preds = %43
%47 = load i32, i32* %2
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [6 x float], [6 x float]* %6, i64 0, i64 %49
%51 = load float, float* %50
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %52)
br label %54
54: ; preds = %46
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %43
57: ; preds = %43
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %2
br label %60
60: ; preds = %93, %57
%61 = load i32, i32* %2
%62 = icmp sle i32 %61, 5
br i1 %62, label %63, label %96
63: ; preds = %60
store float 0.000000e+00, float* %4
store i32 1, i32* %3
br label %64
64: ; preds = %81, %63
%65 = load i32, i32* %3
%66 = icmp sle i32 %65, 5
br i1 %66, label %67, label %84
67: ; preds = %64
%68 = load i32, i32* %2
%69 = add nsw i32 5, %68
%70 = load i32, i32* %3
%71 = sub nsw i32 %69, %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [11 x float], [11 x float]* %5, i64 0, i64 %72
%74 = load float, float* %73
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [6 x float], [6 x float]* %6, i64 0, i64 %76
%78 = load float, float* %77
%79 = load float, float* %4
%80 = call float @llvm.fmuladd.f32(float %74, float %78, float %79)
store float %80, float* %4
br label %81
81: ; preds = %67
%82 = load i32, i32* %3
%83 = add nsw i32 %82, 1
store i32 %83, i32* %3
br label %64
84: ; preds = %64
%85 = load float, float* %4
%86 = fpext float %85 to double
%87 = load i32, i32* %2
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [6 x float], [6 x float]* %7, i64 0, i64 %88
%90 = load float, float* %89
%91 = fpext float %90 to double
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %86, double %91)
br label %93
93: ; preds = %84
%94 = load i32, i32* %2
%95 = add nsw i32 %94, 1
store i32 %95, i32* %2
br label %60
96: ; preds = %60
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"%7s%1d%s %13f\0A\00"
@.str.2 = [3 x i8] c"x[\00"
@.str.3 = [4 x i8] c"] =\00"
@.str.5 = [11 x i8] c"%13s %12s\0A\00"
@.str.6 = [10 x i8] c"mtrx*soln\00"
@.str.7 = [9 x i8] c"original\00"
@.str.8 = [15 x i8] c"%12.4f %12.4f\0A\00"
@str = [17 x i8] c"Solution vector:\00"
@str.9 = [19 x i8] c"\0ATest of solution:\00"
define i32 @main() {
%1 = alloca [11 x float]
%2 = alloca [6 x float]
%3 = alloca [6 x float]
%4 = bitcast [11 x float]* %1 to i8*
%5 = bitcast [6 x float]* %2 to i8*
%6 = bitcast [6 x float]* %3 to i8*
%7 = getelementptr inbounds [6 x float], [6 x float]* %3, i64 0, i64 1
%8 = bitcast float* %7 to <4 x float>*
store <4 x float> <float 0x3FB99999A0000000, float 0x3FC99999A0000000, float 0x3FD3333340000000, float 0x3FD99999A0000000>, <4 x float>* %8
%9 = getelementptr inbounds [6 x float], [6 x float]* %3, i64 0, i64 5
store float 5.000000e-01, float* %9
%10 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 1
%11 = bitcast float* %10 to <4 x float>*
store <4 x float> <float 1.000000e+00, float 5.000000e-01, float 0x3FD5555560000000, float 2.500000e-01>, <4 x float>* %11
%12 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 5
%13 = bitcast float* %12 to <4 x float>*
store <4 x float> <float 0x3FC99999A0000000, float 0x3FC5555560000000, float 0x3FC24924A0000000, float 1.250000e-01>, <4 x float>* %13
%14 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 9
store float 0x3FBC71C720000000, float* %14
%15 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 0
%16 = getelementptr inbounds [6 x float], [6 x float]* %2, i64 0, i64 0
%17 = getelementptr inbounds [6 x float], [6 x float]* %3, i64 0, i64 0
%18 = call i32 (float*, float*, float*, i32, ...) bitcast (i32 (...)* @toeplz to i32 (float*, float*, float*, i32, ...)*)(float* %15, float* %16, float* %17, i32 5)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%20 = getelementptr inbounds [6 x float], [6 x float]* %2, i64 0, i64 1
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %22)
%24 = getelementptr inbounds [6 x float], [6 x float]* %2, i64 0, i64 2
%25 = load float, float* %24
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %26)
%28 = getelementptr inbounds [6 x float], [6 x float]* %2, i64 0, i64 3
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = getelementptr inbounds [6 x float], [6 x float]* %2, i64 0, i64 4
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %34)
%36 = getelementptr inbounds [6 x float], [6 x float]* %2, i64 0, i64 5
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %38)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %42
42: ; preds = %0, %42
%43 = phi i64 [ 1, %0 ], [ %73, %42 ]
%44 = add nuw nsw i64 %43, 4
%45 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 %44
%46 = load float, float* %45
%47 = load float, float* %20
%48 = call float @llvm.fmuladd.f32(float %46, float %47, float 0.000000e+00)
%49 = add nuw nsw i64 %43, 3
%50 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 %49
%51 = load float, float* %50
%52 = load float, float* %24
%53 = call float @llvm.fmuladd.f32(float %51, float %52, float %48)
%54 = add nuw nsw i64 %43, 2
%55 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 %54
%56 = load float, float* %55
%57 = load float, float* %28
%58 = call float @llvm.fmuladd.f32(float %56, float %57, float %53)
%59 = add nuw nsw i64 %43, 1
%60 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 %59
%61 = load float, float* %60
%62 = load float, float* %32
%63 = call float @llvm.fmuladd.f32(float %61, float %62, float %58)
%64 = getelementptr inbounds [11 x float], [11 x float]* %1, i64 0, i64 %43
%65 = load float, float* %64
%66 = load float, float* %36
%67 = call float @llvm.fmuladd.f32(float %65, float %66, float %63)
%68 = fpext float %67 to double
%69 = getelementptr inbounds [6 x float], [6 x float]* %3, i64 0, i64 %43
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), double %68, double %71)
%73 = add nuw nsw i64 %43, 1
%74 = icmp eq i64 %73, 6
br i1 %74, label %75, label %42
75: ; preds = %42
ret i32 0
}