#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 standard_scale_system(int, double *);
int syscon_number_of_standard_polynomials(int *);
int syscon_read_standard_system();
int syscon_write_standard_system();
int standard_scaler(void) {
  int fail, dim, i;
  fail = syscon_read_standard_system();
  if (fail == 0) {
    printf("\nThe system in the container : \n");
    fail = syscon_write_standard_system();
    fail = syscon_number_of_standard_polynomials(&dim);
    if (fail == 0) {
      double c[4 * dim + 2];
      fail = standard_scale_system(2, c);
      printf("The estimated inverse condition number : %.3e\n", c[4 * dim]);
      printf("The scaling coefficients : \n");
      for (i = 0; i < 4 * dim; i = i + 2)
        printf("%2d : %.15e  %.15e\n", i / 2, c[i], c[i + 1]);
      printf("\nThe system in the container : \n");
      fail = syscon_write_standard_system();
    }
  }
  return fail;
}


x86 assembly (clang, -O0):
<standard_scaler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1070 <syscon_read_standard_system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1282 <standard_scaler+0x132>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <syscon_write_standard_system@plt>
mov    %eax,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <syscon_number_of_standard_polynomials@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    127d <standard_scaler+0x12d>
mov    -0x8(%rbp),%ecx
mov    %ecx,%eax
lea    0x2(,%rax,4),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
shl    $0x3,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
call   1040 <standard_scale_system@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,-0x4(%rbp)
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    125e <standard_scaler+0x10e>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe24(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1209 <standard_scaler+0xb9>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <syscon_write_standard_system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    1282 <standard_scaler+0x132>
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<standard_scaler>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <syscon_read_standard_system@plt>
test   %eax,%eax
jne    1255 <standard_scaler+0xf5>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <syscon_write_standard_system@plt>
lea    -0x2c(%rbp),%rdi
call   1070 <syscon_number_of_standard_polynomials@plt>
test   %eax,%eax
jne    1255 <standard_scaler+0xf5>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
lea    0x2(,%rax,4),%eax
shl    $0x3,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    $0x2,%edi
mov    %r14,%rsi
call   1050 <standard_scale_system@plt>
movslq -0x2c(%rbp),%rax
shl    $0x5,%rax
movsd  (%rax,%r14,1),%xmm0
lea    0xe23(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    123f <standard_scaler+0xdf>
xor    %r13d,%r13d
lea    0xe2f(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm0
movsd  0x8(%r14,%rbx,8),%xmm1
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x2,%rbx
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    $0x1,%r13d
cmp    %rax,%rbx
jl     1210 <standard_scaler+0xb0>
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <syscon_write_standard_system@plt>
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0AThe system in the container : \0A\00"
@.str.1 = [47 x i8] c"The estimated inverse condition number : %.3e\0A\00"
@.str.2 = [29 x i8] c"The scaling coefficients : \0A\00"
@.str.3 = [20 x i8] c"%2d : %.15e %.15e\0A\00"
define i32 @standard_scaler() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = call i32 (...) @syscon_read_standard_system()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %56
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (...) @syscon_write_standard_system()
store i32 %11, i32* %1
%12 = call i32 @syscon_number_of_standard_polynomials(i32* %2)
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %55
15: ; preds = %9
%16 = load i32, i32* %2
%17 = mul nsw i32 4, %16
%18 = add nsw i32 %17, 2
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %4
%21 = alloca double, i64 %19
store i64 %19, i64* %5
%22 = call i32 @standard_scale_system(i32 2, double* %21)
store i32 %22, i32* %1
%23 = load i32, i32* %2
%24 = mul nsw i32 4, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %21, i64 %25
%27 = load double, double* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %30
30: ; preds = %48, %15
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = mul nsw i32 4, %32
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %51
35: ; preds = %30
%36 = load i32, i32* %3
%37 = sdiv i32 %36, 2
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %21, i64 %39
%41 = load double, double* %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %21, i64 %44
%46 = load double, double* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %37, double %41, double %46)
br label %48
48: ; preds = %35
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 2
store i32 %50, i32* %3
br label %30
51: ; preds = %30
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%53 = call i32 (...) @syscon_write_standard_system()
store i32 %53, i32* %1
%54 = load i8*, i8** %4
br label %55
55: ; preds = %51, %9
br label %56
56: ; preds = %55, %0
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [47 x i8] c"The estimated inverse condition number : %.3e\0A\00"
@.str.3 = [20 x i8] c"%2d : %.15e %.15e\0A\00"
@str.4 = [28 x i8] c"The scaling coefficients : \00"
@str.5 = [32 x i8] c"\0AThe system in the container : \00"
define i32 @standard_scaler() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @syscon_read_standard_system()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %45
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 (...) @syscon_write_standard_system()
%8 = call i32 @syscon_number_of_standard_polynomials(i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %45
10: ; preds = %5
%11 = load i32, i32* %1
%12 = shl nsw i32 %11, 2
%13 = or i32 %12, 2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
%16 = alloca double, i64 %14
%17 = call i32 @standard_scale_system(i32 2, double* %16)
%18 = load i32, i32* %1
%19 = shl nsw i32 %18, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %16, i64 %20
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%25 = load i32, i32* %1
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %42
27: ; preds = %10, %27
%28 = phi i64 [ %37, %27 ], [ 0, %10 ]
%29 = lshr exact i64 %28, 1
%30 = getelementptr inbounds double, double* %16, i64 %28
%31 = load double, double* %30
%32 = or i64 %28, 1
%33 = getelementptr inbounds double, double* %16, i64 %32
%34 = load double, double* %33
%35 = trunc i64 %29 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %35, double %31, double %34)
%37 = add nuw nsw i64 %28, 2
%38 = load i32, i32* %1
%39 = shl nsw i32 %38, 2
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %37, %40
br i1 %41, label %27, label %42
42: ; preds = %27, %10
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%44 = call i32 (...) @syscon_write_standard_system()
br label %45
45: ; preds = %5, %42, %0
%46 = phi i32 [ %44, %42 ], [ %8, %5 ], [ %3, %0 ]
ret i32 %46
}