#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 _ada_use_solcon(int, int *, int *, double *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ retrieve_and_write(int, int);
int /*<<< orphan*/ scanf(char *, int *);
void test_replace_solution(int n) {
  int i, k, m[2], fail;
  double sol[2 * n + 5];
  printf("Give k : ");
  scanf("%d", &k);
  retrieve_and_write(n, k);
  printf("Setting solution vector to 1,2,3,...\n");
  sol[0] = 1.111;
  sol[1] = 2.222;
  m[0] = n;
  m[1] = 12345;
  sol[2 * n + 2] = 3.333;
  sol[2 * n + 3] = 4.444;
  sol[2 * n + 4] = 5.555;
  for (i = 0; i < 2 * n; i++)
    sol[2 + i] = i;
  fail = _ada_use_solcon(5, &k, m, sol);
  if (fail == 1)
    printf("some failure occurred...\n");
  else {
    printf("The changed solution retrieved again :\n");
    retrieve_and_write(n, k);
  }
}


x86 assembly (clang, -O0):
<test_replace_solution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,%eax
lea    0x5(%rax,%rax,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <retrieve_and_write@plt>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  0xe55(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x4(%rbp),%ecx
mov    %ecx,-0x14(%rbp)
movl   $0x3039,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  0xe06(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movsd  0xde5(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    125d <test_replace_solution+0x11d>
mov    -0x30(%rbp),%rax
cvtsi2sdl -0x8(%rbp),%xmm0
mov    -0x8(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1227 <test_replace_solution+0xe7>
mov    -0x30(%rbp),%rcx
lea    -0x14(%rbp),%rdx
mov    $0x5,%edi
lea    -0xc(%rbp),%rsi
call   1040 <_ada_use_solcon@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1291 <test_replace_solution+0x151>
lea    0xdd4(%rip),%rdi
call   1030 <printf@plt>
jmp    12a8 <test_replace_solution+0x168>
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <retrieve_and_write@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_replace_solution>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
mov    %rsp,-0x40(%rbp)
lea    (%r14,%r14,1),%r12d
lea    (%r14,%r14,1),%eax
add    $0x5,%eax
lea    0xf(,%rax,8),%r13
and    $0xfffffffffffffff0,%r13
mov    %rsp,%r15
mov    %r15,%rbx
sub    %r13,%rbx
neg    %r13
mov    %rbx,%rsp
lea    0xedb(%rip),%rdi
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%esi
mov    %r14d,%edi
call   1060 <retrieve_and_write@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
movaps 0xe38(%rip),%xmm0
movaps %xmm0,(%r15,%r13,1)
mov    %r14d,-0x34(%rbp)
movl   $0x3039,-0x30(%rbp)
movdqa 0xe30(%rip),%xmm0
movslq %r12d,%rax
movdqa %xmm0,0x10(%rbx,%rax,8)
movabs $0x40163851eb851eb8,%rcx
38 16 40
mov    %rcx,0x20(%rbx,%rax,8)
test   %r14d,%r14d
jle    12f6 <test_replace_solution+0x1a6>
cmp    $0x2,%r12d
mov    $0x1,%eax
cmovge %r12d,%eax
cmp    $0x4,%eax
jae    121a <test_replace_solution+0xca>
xor    %ecx,%ecx
jmp    12e0 <test_replace_solution+0x190>
mov    %eax,%ecx
and    $0x7ffffffc,%ecx
lea    -0x4(%rcx),%rsi
mov    %rsi,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     1348 <test_replace_solution+0x1f8>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
movdqa 0xdd7(%rip),%xmm0
mov    $0x2,%esi
movdqa 0xdda(%rip),%xmm1
movdqa 0xde2(%rip),%xmm2
movdqa 0xdea(%rip),%xmm3
movdqa 0xdf2(%rip),%xmm4
xchg   %ax,%ax
movdqa %xmm0,%xmm5
cvtdq2pd %xmm0,%xmm6
paddd  %xmm1,%xmm5
cvtdq2pd %xmm5,%xmm5
movaps %xmm6,(%rbx,%rsi,8)
movaps %xmm5,0x10(%rbx,%rsi,8)
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm0,%xmm6
cvtdq2pd %xmm5,%xmm5
paddd  %xmm3,%xmm6
cvtdq2pd %xmm6,%xmm6
movaps %xmm5,0x20(%rbx,%rsi,8)
movaps %xmm6,0x30(%rbx,%rsi,8)
paddd  %xmm4,%xmm0
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1270 <test_replace_solution+0x120>
test   $0x1,%dl
je     12d9 <test_replace_solution+0x189>
cvtdq2pd %xmm0,%xmm1
paddd  0xd66(%rip),%xmm0
cvtdq2pd %xmm0,%xmm0
movdqa %xmm1,(%rbx,%rsi,8)
movdqa %xmm0,0x10(%rbx,%rsi,8)
cmp    %rax,%rcx
je     12f6 <test_replace_solution+0x1a6>
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    12e0 <test_replace_solution+0x190>
lea    -0x2c(%rbp),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x5,%edi
mov    %rbx,%rcx
call   1050 <_ada_use_solcon@plt>
cmp    $0x1,%eax
jne    131e <test_replace_solution+0x1ce>
lea    0xdb2(%rip),%rdi
call   1030 <puts@plt>
jmp    1335 <test_replace_solution+0x1e5>
lea    0xd7d(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%esi
mov    %r14d,%edi
call   1060 <retrieve_and_write@plt>
mov    -0x40(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movdqa 0xcd0(%rip),%xmm0
mov    $0x2,%esi
test   $0x1,%dl
jne    12be <test_replace_solution+0x16e>
jmp    12d9 <test_replace_solution+0x189>

LLVM IR (-O0):
@.str = [10 x i8] c"Give k : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Setting solution vector to 1,2,3,...\0A\00"
@.str.3 = [26 x i8] c"some failure occurred...\0A\00"
@.str.4 = [40 x i8] c"The changed solution retrieved again :\0A\00"
define void @test_replace_solution(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 %0, i32* %2
%9 = load i32, i32* %2
%10 = mul nsw i32 2, %9
%11 = add nsw i32 %10, 5
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca double, i64 %12
store i64 %12, i64* %8
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = call i32 @retrieve_and_write(i32 %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds double, double* %14, i64 0
store double 1.111000e+00, double* %21
%22 = getelementptr inbounds double, double* %14, i64 1
store double 2.222000e+00, double* %22
%23 = load i32, i32* %2
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %23, i32* %24
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 12345, i32* %25
%26 = load i32, i32* %2
%27 = mul nsw i32 2, %26
%28 = add nsw i32 %27, 2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %14, i64 %29
store double 3.333000e+00, double* %30
%31 = load i32, i32* %2
%32 = mul nsw i32 2, %31
%33 = add nsw i32 %32, 3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %14, i64 %34
store double 4.444000e+00, double* %35
%36 = load i32, i32* %2
%37 = mul nsw i32 2, %36
%38 = add nsw i32 %37, 4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %14, i64 %39
store double 5.555000e+00, double* %40
store i32 0, i32* %3
br label %41
41: ; preds = %53, %1
%42 = load i32, i32* %3
%43 = load i32, i32* %2
%44 = mul nsw i32 2, %43
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %56
46: ; preds = %41
%47 = load i32, i32* %3
%48 = sitofp i32 %47 to double
%49 = load i32, i32* %3
%50 = add nsw i32 2, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %14, i64 %51
store double %48, double* %52
br label %53
53: ; preds = %46
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %41
56: ; preds = %41
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%58 = call i32 @_ada_use_solcon(i32 5, i32* %4, i32* %57, double* %14)
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %68
63: ; preds = %56
%64 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* %2
%66 = load i32, i32* %4
%67 = call i32 @retrieve_and_write(i32 %65, i32 %66)
br label %68
68: ; preds = %63, %61
%69 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Give k : \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [37 x i8] c"Setting solution vector to 1,2,3,...\00"
@str.5 = [39 x i8] c"The changed solution retrieved again :\00"
@str.6 = [25 x i8] c"some failure occurred...\00"
define void @test_replace_solution(i32 %0) {
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = bitcast i32* %2 to i8*
%5 = bitcast [2 x i32]* %3 to i8*
%6 = shl i32 %0, 1
%7 = add nsw i32 %6, 5
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca double, i64 %8
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = call i32 @retrieve_and_write(i32 %0, i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%16 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 1.111000e+00, double 2.222000e+00>, <2 x double>* %16
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %0, i32* %17
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 12345, i32* %18
%19 = add nsw i32 %6, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %10, i64 %20
%22 = bitcast double* %21 to <2 x double>*
store <2 x double> <double 3.333000e+00, double 4.444000e+00>, <2 x double>* %22
%23 = add nsw i32 %6, 4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %10, i64 %24
store double 5.555000e+00, double* %25
%26 = icmp sgt i32 %0, 0
br i1 %26, label %27, label %91
27: ; preds = %1
%28 = call i32 @llvm.smax.i32(i32 %6, i32 1)
%29 = zext i32 %28 to i64
%30 = icmp ult i32 %28, 4
br i1 %30, label %81, label %31
31: ; preds = %27
%32 = and i64 %29, 2147483644
%33 = add nsw i64 %32, -4
%34 = lshr exact i64 %33, 2
%35 = add nuw nsw i64 %34, 1
%36 = and i64 %35, 1
%37 = icmp eq i64 %33, 0
br i1 %37, label %67, label %38
38: ; preds = %31
%39 = and i64 %35, 9223372036854775806
br label %40
40: ; preds = %40, %38
%41 = phi i64 [ 0, %38 ], [ %61, %40 ]
%42 = phi <2 x i32> [ <i32 0, i32 1>, %38 ], [ %62, %40 ]
%43 = phi i64 [ 0, %38 ], [ %63, %40 ]
%44 = add <2 x i32> %42, <i32 2, i32 2>
%45 = sitofp <2 x i32> %42 to <2 x double>
%46 = sitofp <2 x i32> %44 to <2 x double>
%47 = or i64 %41, 2
%48 = getelementptr inbounds double, double* %10, i64 %47
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %45, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %46, <2 x double>* %51
%52 = add <2 x i32> %42, <i32 4, i32 4>
%53 = add <2 x i32> %42, <i32 6, i32 6>
%54 = sitofp <2 x i32> %52 to <2 x double>
%55 = sitofp <2 x i32> %53 to <2 x double>
%56 = or i64 %41, 6
%57 = getelementptr inbounds double, double* %10, i64 %56
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %54, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %55, <2 x double>* %60
%61 = add nuw i64 %41, 8
%62 = add <2 x i32> %42, <i32 8, i32 8>
%63 = add i64 %43, 2
%64 = icmp eq i64 %63, %39
br i1 %64, label %65, label %40
65: ; preds = %40
%66 = or i64 %61, 2
br label %67
67: ; preds = %65, %31
%68 = phi i64 [ 2, %31 ], [ %66, %65 ]
%69 = phi <2 x i32> [ <i32 0, i32 1>, %31 ], [ %62, %65 ]
%70 = icmp eq i64 %36, 0
br i1 %70, label %79, label %71
71: ; preds = %67
%72 = add <2 x i32> %69, <i32 2, i32 2>
%73 = sitofp <2 x i32> %69 to <2 x double>
%74 = sitofp <2 x i32> %72 to <2 x double>
%75 = getelementptr inbounds double, double* %10, i64 %68
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %73, <2 x double>* %76
%77 = getelementptr inbounds double, double* %75, i64 2
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %74, <2 x double>* %78
br label %79
79: ; preds = %67, %71
%80 = icmp eq i64 %32, %29
br i1 %80, label %91, label %81
81: ; preds = %27, %79
%82 = phi i64 [ 0, %27 ], [ %32, %79 ]
br label %83
83: ; preds = %81, %83
%84 = phi i64 [ %89, %83 ], [ %82, %81 ]
%85 = trunc i64 %84 to i32
%86 = sitofp i32 %85 to double
%87 = add nuw nsw i64 %84, 2
%88 = getelementptr inbounds double, double* %10, i64 %87
store double %86, double* %88
%89 = add nuw nsw i64 %84, 1
%90 = icmp eq i64 %89, %29
br i1 %90, label %91, label %83
91: ; preds = %83, %79, %1
%92 = call i32 @_ada_use_solcon(i32 5, i32* %2, i32* %17, double* %10)
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %96
94: ; preds = %91
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %100
96: ; preds = %91
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
%98 = load i32, i32* %2
%99 = call i32 @retrieve_and_write(i32 %0, i32 %98)
br label %100
100: ; preds = %96, %94
ret void
}