#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 *, ...);
void retrieve_and_write(int n, int k) {
  int i, m, fail;
  double sol[2 * n + 5];
  fail = _ada_use_solcon(4, &k, &m, sol);
  if (fail == 1)
    printf("some failure occurred...\n");
  else {
    printf("The solution vector :\n");
    for (i = 0; i < n; i++)
      printf(" %.15e  %.15e\n", sol[2 + 2 * i], sol[2 + 2 * i + 1]);
  }
}


x86 assembly (clang, -O0):
<retrieve_and_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%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)
mov    $0x4,%edi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <_ada_use_solcon@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    118d <retrieve_and_write+0x6d>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f8 <retrieve_and_write+0xd8>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f3 <retrieve_and_write+0xd3>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe53(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a2 <retrieve_and_write+0x82>
jmp    11f8 <retrieve_and_write+0xd8>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<retrieve_and_write>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
mov    %rsp,%r15
mov    %esi,-0x2c(%rbp)
lea    (%r14,%r14,1),%eax
add    $0x5,%eax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x4,%edi
mov    %r13,%rcx
call   1050 <_ada_use_solcon@plt>
cmp    $0x1,%eax
jne    118b <retrieve_and_write+0x5b>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
jmp    11d1 <retrieve_and_write+0xa1>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
jle    11d1 <retrieve_and_write+0xa1>
mov    %r14d,%r12d
shl    $0x4,%r12
xor    %ebx,%ebx
lea    0xe54(%rip),%r14
nopl   0x0(%rax)
movsd  0x10(%r13,%rbx,1),%xmm0
movsd  0x18(%r13,%rbx,1),%xmm1
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x10,%rbx
cmp    %rbx,%r12
jne    11b0 <retrieve_and_write+0x80>
mov    %r15,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"some failure occurred...\0A\00"
@.str.1 = [23 x i8] c"The solution vector :\0A\00"
@.str.2 = [15 x i8] c" %.15e %.15e\0A\00"
define void @retrieve_and_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = mul nsw i32 2, %10
%12 = add nsw i32 %11, 5
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca double, i64 %13
store i64 %13, i64* %9
%16 = call i32 @_ada_use_solcon(i32 4, i32* %4, i32* %6, double* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %46
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %23
23: ; preds = %42, %21
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %45
27: ; preds = %23
%28 = load i32, i32* %5
%29 = mul nsw i32 2, %28
%30 = add nsw i32 2, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %15, i64 %31
%33 = load double, double* %32
%34 = load i32, i32* %5
%35 = mul nsw i32 2, %34
%36 = add nsw i32 2, %35
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %15, i64 %38
%40 = load double, double* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %33, double %40)
br label %42
42: ; preds = %27
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %23
45: ; preds = %23
br label %46
46: ; preds = %45, %19
%47 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@.str.2 = [15 x i8] c" %.15e %.15e\0A\00"
@str = [22 x i8] c"The solution vector :\00"
@str.3 = [25 x i8] c"some failure occurred...\00"
define void @retrieve_and_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %1, i32* %3
%5 = bitcast i32* %4 to i8*
%6 = shl nsw 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 = call i32 @_ada_use_solcon(i32 4, i32* %3, i32* %4, double* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
br label %32
15: ; preds = %2
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%17 = icmp sgt i32 %0, 0
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = zext i32 %0 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %30, %20 ]
%22 = shl nuw nsw i64 %21, 1
%23 = add nuw nsw i64 %22, 2
%24 = getelementptr inbounds double, double* %10, i64 %23
%25 = load double, double* %24
%26 = add nuw nsw i64 %22, 3
%27 = getelementptr inbounds double, double* %10, i64 %26
%28 = load double, double* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %25, double %28)
%30 = add nuw nsw i64 %21, 1
%31 = icmp eq i64 %30, %19
br i1 %31, label %32, label %20
32: ; preds = %20, %15, %13
ret void
}