#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, ...);
int solcon_dimension_of_standard_solutions(int *);
int solcon_length_current_standard_solution_string(int *, int *);
int solcon_move_current_standard_to_next(int *);
int solcon_number_of_standard_solutions(int *);
int solcon_write_current_standard_solution_string(int *, int, char *);
void retrieve_all_standard_solution_strings(void) {
  int dim, len, fail;
  fail = solcon_dimension_of_standard_solutions(&dim);
  fail = solcon_number_of_standard_solutions(&len);
  printf("The container has %d solutions of dimension %d.\n", len, dim);
  {
    int k, len;
    do {
      fail = solcon_length_current_standard_solution_string(&k, &len);
      if (fail != 0)
        printf("return value of k is %d\n", k);
      else {
        char sol[len + 1];
        fail = solcon_write_current_standard_solution_string(&k, len, sol);
        printf("The solution vector %d :\n%s\n", k, sol);
        fail = solcon_move_current_standard_to_next(&k);
      }
    } while (k > 0);
  }
}


x86 assembly (clang, -O0):
<retrieve_all_standard_solution_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x4(%rbp),%rdi
call   1050 <solcon_dimension_of_standard_solutions@plt>
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <solcon_number_of_standard_solutions@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <solcon_length_current_standard_solution_string@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11c4 <retrieve_all_standard_solution_strings+0x64>
mov    -0x10(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <retrieve_all_standard_solution_strings+0xc4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1080 <solcon_write_current_standard_solution_string@plt>
mov    -0x30(%rbp),%rdx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1060 <solcon_move_current_standard_to_next@plt>
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    1229 <retrieve_all_standard_solution_strings+0xc9>
cmpl   $0x0,-0x10(%rbp)
jg     1194 <retrieve_all_standard_solution_strings+0x34>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<retrieve_all_standard_solution_strings>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    -0x38(%rbp),%rdi
call   1050 <solcon_dimension_of_standard_solutions@plt>
lea    -0x34(%rbp),%rdi
call   1040 <solcon_number_of_standard_solutions@plt>
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    -0x2c(%rbp),%r13
lea    -0x30(%rbp),%r14
lea    0xe8b(%rip),%r12
jmp    11fd <retrieve_all_standard_solution_strings+0x9d>
nopl   0x0(%rax,%rax,1)
mov    %rsp,%r15
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x30(%rbp),%esi
mov    %r13,%rdi
mov    %rbx,%rdx
call   1080 <solcon_write_current_standard_solution_string@plt>
mov    -0x2c(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
call   1060 <solcon_move_current_standard_to_next@plt>
mov    %r15,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    121f <retrieve_all_standard_solution_strings+0xbf>
mov    %r13,%rdi
mov    %r14,%rsi
call   1070 <solcon_length_current_standard_solution_string@plt>
test   %eax,%eax
je     11b0 <retrieve_all_standard_solution_strings+0x50>
mov    -0x2c(%rbp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jg     11fd <retrieve_all_standard_solution_strings+0x9d>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"The container has %d solutions of dimension %d.\0A\00"
@.str.1 = [25 x i8] c"return value of k is %d\0A\00"
@.str.2 = [29 x i8] c"The solution vector %d :\0A%s\0A\00"
define void @retrieve_all_standard_solution_strings() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = call i32 @solcon_dimension_of_standard_solutions(i32* %1)
store i32 %8, i32* %3
%9 = call i32 @solcon_number_of_standard_solutions(i32* %2)
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = load i32, i32* %1
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
br label %13
13: ; preds = %33, %0
%14 = call i32 @solcon_length_current_standard_solution_string(i32* %4, i32* %5)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %4
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %32
20: ; preds = %13
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %6
%25 = alloca i8, i64 %23
store i64 %23, i64* %7
%26 = load i32, i32* %5
%27 = call i32 @solcon_write_current_standard_solution_string(i32* %4, i32 %26, i8* %25)
store i32 %27, i32* %3
%28 = load i32, i32* %4
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %28, i8* %25)
%30 = call i32 @solcon_move_current_standard_to_next(i32* %4)
store i32 %30, i32* %3
%31 = load i8*, i8** %6
br label %32
32: ; preds = %20, %17
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 0
br i1 %35, label %13, label %36
36: ; preds = %33
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"The container has %d solutions of dimension %d.\0A\00"
@.str.1 = [25 x i8] c"return value of k is %d\0A\00"
@.str.2 = [29 x i8] c"The solution vector %d :\0A%s\0A\00"
define void @retrieve_all_standard_solution_strings() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = call i32 @solcon_dimension_of_standard_solutions(i32* %1)
%8 = call i32 @solcon_number_of_standard_solutions(i32* %2)
%9 = load i32, i32* %2
%10 = load i32, i32* %1
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
br label %14
14: ; preds = %31, %0
%15 = call i32 @solcon_length_current_standard_solution_string(i32* %3, i32* %4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %3
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %31
20: ; preds = %14
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
%25 = alloca i8, i64 %23
%26 = load i32, i32* %4
%27 = call i32 @solcon_write_current_standard_solution_string(i32* %3, i32 %26, i8* %25)
%28 = load i32, i32* %3
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %28, i8* %25)
%30 = call i32 @solcon_move_current_standard_to_next(i32* %3)
br label %31
31: ; preds = %17, %20
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, 0
br i1 %33, label %14, label %34
34: ; preds = %31
ret void
}