#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*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int, int);
int /*<<< orphan*/ zrhqr(float *, int, float *, float *);
int main(void) {
  static float a[(4 + 1)] = {-1.0, 0.0, 0.0, 0.0, 1.0};
  float *rti, *rtr;
  int i;
  rti = vector(1, 4);
  rtr = vector(1, 4);
  printf("\nRoots of polynomial x^4-1\n");
  printf("\n%15s %15s\n", "Real", "Complex");
  zrhqr(a, 4, rtr, rti);
  for (i = 1; i <= 4; i++) {
    printf("%5d %12.6f %12.6f\n", i, rtr[i], rti[i]);
  }
  free_vector(rtr, 1, 4);
  free_vector(rti, 1, 4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1050 <vector@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1050 <vector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0xe97(%rip),%rsi
lea    0xe95(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2ea2(%rip),%rdi
mov    $0x4,%esi
call   1060 <zrhqr@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jg     120a <main+0xca>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe40(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bf <main+0x7f>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <free_vector@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%edi
mov    $0x4,%esi
call   1060 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x4,%esi
call   1060 <vector@plt>
mov    %rax,%rbx
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%rdi
lea    0xe79(%rip),%rsi
lea    0xe77(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2ea8(%rip),%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1070 <zrhqr@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x4(%r14),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe47(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%r14),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r15,%rdi
mov    $0x2,%esi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0xc(%r14),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r15,%rdi
mov    $0x3,%esi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%r14),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.a = internal global [5 x float] [float -1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00]
@.str = [28 x i8] c"\0ARoots of polynomial x^4-1\0A\00"
@.str.1 = [12 x i8] c"\0A%15s %15s\0A\00"
@.str.2 = [5 x i8] c"Real\00"
@.str.3 = [8 x i8] c"Complex\00"
@.str.4 = [19 x i8] c"%5d %12.6f %12.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float*
%3 = alloca float*
%4 = alloca i32
store i32 0, i32* %1
%5 = call float* @vector(i32 1, i32 4)
store float* %5, float** %2
%6 = call float* @vector(i32 1, i32 4)
store float* %6, float** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = load float*, float** %3
%10 = load float*, float** %2
%11 = call i32 @zrhqr(float* getelementptr inbounds ([5 x float], [5 x float]* @main.a, i64 0, i64 0), i32 4, float* %9, float* %10)
store i32 1, i32* %4
br label %12
12: ; preds = %30, %0
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 4
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load float*, float** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds float, float* %17, i64 %19
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = load float*, float** %2
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds float, float* %23, i64 %25
%27 = load float, float* %26
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %16, double %22, double %28)
br label %30
30: ; preds = %15
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %12
33: ; preds = %12
%34 = load float*, float** %3
%35 = call i32 @free_vector(float* %34, i32 1, i32 4)
%36 = load float*, float** %2
%37 = call i32 @free_vector(float* %36, i32 1, i32 4)
ret i32 0
}

LLVM IR (-O2):
@main.a = internal global [5 x float] [float -1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00]
@.str.1 = [12 x i8] c"\0A%15s %15s\0A\00"
@.str.2 = [5 x i8] c"Real\00"
@.str.3 = [8 x i8] c"Complex\00"
@.str.4 = [19 x i8] c"%5d %12.6f %12.6f\0A\00"
@str = [27 x i8] c"\0ARoots of polynomial x^4-1\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 4)
%2 = tail call float* @vector(i32 1, i32 4)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @zrhqr(float* getelementptr inbounds ([5 x float], [5 x float]* @main.a, i64 0, i64 0), i32 4, float* %2, float* %1)
%6 = getelementptr inbounds float, float* %2, i64 1
%7 = load float, float* %6
%8 = fpext float %7 to double
%9 = getelementptr inbounds float, float* %1, i64 1
%10 = load float, float* %9
%11 = fpext float %10 to double
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 1, double %8, double %11)
%13 = getelementptr inbounds float, float* %2, i64 2
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = getelementptr inbounds float, float* %1, i64 2
%17 = load float, float* %16
%18 = fpext float %17 to double
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 2, double %15, double %18)
%20 = getelementptr inbounds float, float* %2, i64 3
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = getelementptr inbounds float, float* %1, i64 3
%24 = load float, float* %23
%25 = fpext float %24 to double
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 3, double %22, double %25)
%27 = getelementptr inbounds float, float* %2, i64 4
%28 = load float, float* %27
%29 = fpext float %28 to double
%30 = getelementptr inbounds float, float* %1, i64 4
%31 = load float, float* %30
%32 = fpext float %31 to double
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 4, double %29, double %32)
%34 = tail call i32 @free_vector(float* %2, i32 1, i32 4)
%35 = tail call i32 @free_vector(float* %1, i32 1, i32 4)
ret i32 0
}