int main() {
  int i, iN;
  double X[2], X0[2], Xn[2], U[1], Uprev[1];
  double reference[0 + 1], region;
  double A[2][2] = {{1.0, 1.0}, {0.0, 1.0}};
  double B[2] = {1.0, 0.5};
  if (2 != 2) {
    printf("Wrong dimension of state vector!\n");
    return 0;
  }
  if (1 != 1) {
    printf("Wrong dimension of input vector!\n");
    return 0;
  }
  for (i = 0; i < 2; i++) {
    X0[i] = 1;
  }
  for (i = 0; i < 1; i++) {
    Uprev[i] = 0;
  }
  if (0 > 0) {
    reference[0] = 1;
    if (0 > 1) {
      for (i = 1; i < 0; i++) {
        reference[i] = 0;
      }
    }
  }
  for (iN = 0; iN < 20; iN++) {
    printf("time: %d X = [%f %f]\n", iN, X0[0], X0[1]);
    mpt_augmentState(X, X0, Uprev, reference);
    region = mpt_getInput(X, U);
    if (region < 1) {
      printf("No feasible control law found!\n");
      return 0;
    }
    mpt_augmentInput(U, Uprev);
    *Uprev = *U;
    Xn[0] = (A[0][0]) * (X0[0]) + (A[0][1]) * (X0[1]) + (B[0]) * (U[0]);
    Xn[1] = (A[1][0]) * (X0[0]) + (A[1][1]) * (X0[1]) + (B[1]) * (U[0]);
    X0[0] = Xn[0];
    X0[1] = Xn[1];
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cb <main+0x8b>
movslq -0x8(%rbp),%rax
movsd  0xe49(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a1 <main+0x61>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    11f7 <main+0xb7>
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <main+0x92>
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    1326 <main+0x1e6>
mov    -0xc(%rbp),%esi
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe24(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
mov    $0x0,%al
call   1060 <mpt_augmentState@plt>
lea    -0x20(%rbp),%rdi
lea    -0x48(%rbp),%rsi
mov    $0x0,%al
call   1050 <mpt_getInput@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xda6(%rip),%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    127f <main+0x13f>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1326 <main+0x1e6>
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x0,%al
call   1040 <mpt_augmentInput@plt>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x80(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x70(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11fe <main+0xbe>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x18(%rsp)
movsd  0xe96(%rip),%xmm1
lea    0x30(%rsp),%r12
mov    %rsp,%r15
lea    0x18(%rsp),%rbx
lea    0x28(%rsp),%r13
lea    0x20(%rsp),%rbp
movapd %xmm1,%xmm0
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
lea    0xe81(%rip),%rdi
mov    %r14d,%esi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1070 <mpt_augmentState@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <mpt_getInput@plt>
test   %eax,%eax
jle    1238 <main+0xe8>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <mpt_augmentInput@plt>
movsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movapd %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe13(%rip),%xmm2
addsd  %xmm3,%xmm2
mulsd  0xdff(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x8(%rsp)
add    $0x1,%r14d
cmp    $0x14,%r14d
jne    11a0 <main+0x50>
jmp    1244 <main+0xf4>
lea    0xdff(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.A = [2 x [2 x double]] [[2 x double] [double 1.000000e+00, double 1.000000e+00], [2 x double] [double 0.000000e+00, double 1.000000e+00]]
@__const.main.B = [2 x double] [double 1.000000e+00, double 5.000000e-01]
@.str = [22 x i8] c"time: %d X = [%f %f]\0A\00"
@.str.1 = [32 x i8] c"No feasible control law found!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x double]
%5 = alloca [2 x double]
%6 = alloca [2 x double]
%7 = alloca [1 x double]
%8 = alloca [1 x double]
%9 = alloca [1 x double]
%10 = alloca double
%11 = alloca [2 x [2 x double]]
%12 = alloca [2 x double]
store i32 0, i32* %1
%13 = bitcast [2 x [2 x double]]* %11 to i8*
%14 = bitcast [2 x double]* %12 to i8*
store i32 0, i32* %2
br label %15
15: ; preds = %22, %0
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 %20
store double 1.000000e+00, double* %21
br label %22
22: ; preds = %18
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %15
25: ; preds = %15
store i32 0, i32* %2
br label %26
26: ; preds = %33, %25
%27 = load i32, i32* %2
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1 x double], [1 x double]* %8, i64 0, i64 %31
store double 0.000000e+00, double* %32
br label %33
33: ; preds = %29
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %26
36: ; preds = %26
store i32 0, i32* %3
br label %37
37: ; preds = %109, %36
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 20
br i1 %39, label %40, label %112
40: ; preds = %37
%41 = load i32, i32* %3
%42 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%43 = load double, double* %42
%44 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%45 = load double, double* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %41, double %43, double %45)
%47 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%48 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%49 = getelementptr inbounds [1 x double], [1 x double]* %8, i64 0, i64 0
%50 = getelementptr inbounds [1 x double], [1 x double]* %9, i64 0, i64 0
%51 = call i32 (double*, double*, double*, double*, ...) bitcast (i32 (...)* @mpt_augmentState to i32 (double*, double*, double*, double*, ...)*)(double* %47, double* %48, double* %49, double* %50)
%52 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%53 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%54 = call i32 (double*, double*, ...) bitcast (i32 (...)* @mpt_getInput to i32 (double*, double*, ...)*)(double* %52, double* %53)
%55 = sitofp i32 %54 to double
store double %55, double* %10
%56 = load double, double* %10
%57 = fcmp olt double %56, 1.000000e+00
br i1 %57, label %58, label %60
58: ; preds = %40
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %112
60: ; preds = %40
%61 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%62 = getelementptr inbounds [1 x double], [1 x double]* %8, i64 0, i64 0
%63 = call i32 (double*, double*, ...) bitcast (i32 (...)* @mpt_augmentInput to i32 (double*, double*, ...)*)(double* %61, double* %62)
%64 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%65 = load double, double* %64
%66 = getelementptr inbounds [1 x double], [1 x double]* %8, i64 0, i64 0
store double %65, double* %66
%67 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %11, i64 0, i64 0
%68 = getelementptr inbounds [2 x double], [2 x double]* %67, i64 0, i64 0
%69 = load double, double* %68
%70 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%71 = load double, double* %70
%72 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %11, i64 0, i64 0
%73 = getelementptr inbounds [2 x double], [2 x double]* %72, i64 0, i64 1
%74 = load double, double* %73
%75 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%76 = load double, double* %75
%77 = fmul double %74, %76
%78 = call double @llvm.fmuladd.f64(double %69, double %71, double %77)
%79 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 0
%80 = load double, double* %79
%81 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%82 = load double, double* %81
%83 = call double @llvm.fmuladd.f64(double %80, double %82, double %78)
%84 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
store double %83, double* %84
%85 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %11, i64 0, i64 1
%86 = getelementptr inbounds [2 x double], [2 x double]* %85, i64 0, i64 0
%87 = load double, double* %86
%88 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%89 = load double, double* %88
%90 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %11, i64 0, i64 1
%91 = getelementptr inbounds [2 x double], [2 x double]* %90, i64 0, i64 1
%92 = load double, double* %91
%93 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%94 = load double, double* %93
%95 = fmul double %92, %94
%96 = call double @llvm.fmuladd.f64(double %87, double %89, double %95)
%97 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 1
%98 = load double, double* %97
%99 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%100 = load double, double* %99
%101 = call double @llvm.fmuladd.f64(double %98, double %100, double %96)
%102 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 1
store double %101, double* %102
%103 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
%104 = load double, double* %103
%105 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
store double %104, double* %105
%106 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 1
%107 = load double, double* %106
%108 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
store double %107, double* %108
br label %109
109: ; preds = %60
%110 = load i32, i32* %3
%111 = add nsw i32 %110, 1
store i32 %111, i32* %3
br label %37
112: ; preds = %58, %37
%113 = load i32, i32* %1
ret i32 %113
}

LLVM IR (-O2):
@.str = [22 x i8] c"time: %d X = [%f %f]\0A\00"
@str = [31 x i8] c"No feasible control law found!\00"
define i32 @main() {
%1 = alloca [2 x double]
%2 = alloca <2 x double>
%3 = alloca [1 x double]
%4 = alloca [1 x double]
%5 = alloca [1 x double]
%6 = bitcast [2 x double]* %1 to i8*
%7 = bitcast <2 x double>* %2 to i8*
%8 = bitcast [1 x double]* %3 to i8*
%9 = bitcast [1 x double]* %4 to i8*
%10 = bitcast [1 x double]* %5 to i8*
%11 = getelementptr inbounds <2 x double>, <2 x double>* %2, i64 0, i64 0
%12 = getelementptr inbounds <2 x double>, <2 x double>* %2, i64 0, i64 1
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %2
%13 = getelementptr inbounds [1 x double], [1 x double]* %4, i64 0, i64 0
store double 0.000000e+00, double* %13
%14 = getelementptr inbounds [2 x double], [2 x double]* %1, i64 0, i64 0
%15 = getelementptr inbounds [1 x double], [1 x double]* %5, i64 0, i64 0
%16 = getelementptr inbounds [1 x double], [1 x double]* %3, i64 0, i64 0
br label %17
17: ; preds = %0, %27
%18 = phi double [ 1.000000e+00, %0 ], [ %35, %27 ]
%19 = phi double [ 1.000000e+00, %0 ], [ %33, %27 ]
%20 = phi i32 [ 0, %0 ], [ %36, %27 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %20, double %19, double %18)
%22 = call i32 (double*, double*, double*, double*, ...) bitcast (i32 (...)* @mpt_augmentState to i32 (double*, double*, double*, double*, ...)*)(double* %14, double* %11, double* %13, double* %15)
%23 = call i32 (double*, double*, ...) bitcast (i32 (...)* @mpt_getInput to i32 (double*, double*, ...)*)(double* %14, double* %16)
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %38
27: ; preds = %17
%28 = call i32 (double*, double*, ...) bitcast (i32 (...)* @mpt_augmentInput to i32 (double*, double*, ...)*)(double* %16, double* %13)
%29 = load double, double* %16
store double %29, double* %13
%30 = load double, double* %11
%31 = load double, double* %12
%32 = fadd double %30, %31
%33 = fadd double %29, %32
%34 = call double @llvm.fmuladd.f64(double %30, double 0.000000e+00, double %31)
%35 = call double @llvm.fmuladd.f64(double %29, double 5.000000e-01, double %34)
store double %33, double* %11
store double %35, double* %12
%36 = add nuw nsw i32 %20, 1
%37 = icmp eq i32 %36, 20
br i1 %37, label %38, label %17
38: ; preds = %27, %25
ret i32 0
}