#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_poly(int *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int solcon_length_dobldobl_solution_string(int, int *);
int solcon_write_dobldobl_solution_string(int, int, char *);
int solve_dobldobl_system(int *, int);
int syscon_initialize_number_of_dobldobl_polynomials(int);
int syscon_store_dobldobl_polynomial(int, int, int, char *);
int /*<<< orphan*/ syscon_write_dobldobl_system();
int dobldobl_interactive_input_output(void) {
  int n, fail, k, nc, i, rc, len, nbtasks;
  char ch, p[800];
  printf("\nGive the number of polynomials in the system : ");
  scanf("%d", &n);
  fail = syscon_initialize_number_of_dobldobl_polynomials(n);
  printf("\nReading %d polynomials, ", n);
  printf("terminate each with ; (semicolon)...\n");
  for (k = 1; k <= n; k++) {
    printf("-> polynomial %d : ", k);
    ch = getchar();
    read_poly(&nc, p);
    fail = syscon_store_dobldobl_polynomial(nc, n, k, p);
  }
  printf("The system in the container : \n");
  syscon_write_dobldobl_system();
  printf("\nGive the number of tasks : ");
  scanf("%d", &nbtasks);
  fail = solve_dobldobl_system(&rc, nbtasks);
  printf("\nThe root count : %d\n", rc);
  printf("interactive selection of solutions... \n");
  do {
    printf("\nGive an index to a solution (-1 to exit) : ");
    scanf("%d", &k);
    if (k < 0)
      break;
    fail = solcon_length_dobldobl_solution_string(k, &len);
    {
      char s[len];
      fail = solcon_write_dobldobl_solution_string(k, len, s);
      printf("\nSolution %d : \n%s", k, s);
    }
  } while (k >= 0);
  return fail;
}


x86 assembly (clang, -O0):
<dobldobl_interactive_input_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe71(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x4(%rbp),%edi
call   1060 <syscon_initialize_number_of_dobldobl_polynomials@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1257 <dobldobl_interactive_input_output+0xb7>
mov    -0xc(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x21(%rbp)
lea    -0x350(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1030 <read_poly@plt>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    -0x350(%rbp),%rcx
call   1070 <syscon_store_dobldobl_polynomial@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11fa <dobldobl_interactive_input_output+0x5a>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1050 <syscon_write_dobldobl_system@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xdb0(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x20(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   10b0 <solve_dobldobl_system@plt>
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd64(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10c0 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    12e5 <dobldobl_interactive_input_output+0x145>
jmp    135d <dobldobl_interactive_input_output+0x1bd>
mov    -0xc(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1040 <solcon_length_dobldobl_solution_string@plt>
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x358(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x368(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x360(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   10a0 <solcon_write_dobldobl_solution_string@plt>
mov    -0x368(%rbp),%rdx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x358(%rbp),%rax
mov    %rax,%rsp
cmpl   $0x0,-0xc(%rbp)
jge    12b8 <dobldobl_interactive_input_output+0x118>
mov    -0x8(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dobldobl_interactive_input_output>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x338,%rsp
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe58(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <scanf@plt>
mov    -0x30(%rbp),%edi
call   1070 <syscon_initialize_number_of_dobldobl_polynomials@plt>
mov    -0x30(%rbp),%esi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xed3(%rip),%rdi
call   1060 <puts@plt>
movl   $0x1,-0x2c(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    126b <dobldobl_interactive_input_output+0xbb>
mov    $0x1,%ebx
lea    0xe2e(%rip),%r14
lea    -0x40(%rbp),%r15
lea    -0x360(%rbp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <read_poly@plt>
mov    -0x40(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   1080 <syscon_store_dobldobl_polynomial@plt>
lea    0x1(%rbx),%eax
mov    %eax,-0x2c(%rbp)
cmp    -0x30(%rbp),%ebx
mov    %eax,%ebx
jl     1230 <dobldobl_interactive_input_output+0x80>
lea    0xe88(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1050 <syscon_write_dobldobl_system@plt>
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd9e(%rip),%r14
lea    -0x38(%rbp),%rsi
mov    %r14,%rdi
call   10d0 <scanf@plt>
mov    -0x38(%rbp),%esi
lea    -0x3c(%rbp),%rdi
call   10c0 <solve_dobldobl_system@plt>
mov    %eax,%ebx
mov    -0x3c(%rbp),%esi
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe54(%rip),%rdi
call   1060 <puts@plt>
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   10d0 <scanf@plt>
mov    -0x2c(%rbp),%edi
test   %edi,%edi
js     136d <dobldobl_interactive_input_output+0x1bd>
lea    0xd3b(%rip),%r13
lea    -0x2c(%rbp),%r14
nopw   0x0(%rax,%rax,1)
lea    -0x34(%rbp),%rsi
call   1040 <solcon_length_dobldobl_solution_string@plt>
mov    %rsp,%r15
mov    -0x34(%rbp),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    %r12,%rdx
call   10b0 <solcon_write_dobldobl_solution_string@plt>
mov    %eax,%ebx
mov    -0x2c(%rbp),%esi
lea    0xd88(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rsp
cmpl   $0x0,-0x2c(%rbp)
js     136d <dobldobl_interactive_input_output+0x1bd>
lea    0xd41(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
mov    -0x2c(%rbp),%edi
test   %edi,%edi
jns    1300 <dobldobl_interactive_input_output+0x150>
mov    %ebx,%eax
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"\0AGive the number of polynomials in the system : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AReading %d polynomials, \00"
@.str.3 = [38 x i8] c"terminate each with ; (semicolon)...\0A\00"
@.str.4 = [20 x i8] c"-> polynomial %d : \00"
@.str.5 = [32 x i8] c"The system in the container : \0A\00"
@.str.6 = [29 x i8] c"\0AGive the number of tasks : \00"
@.str.7 = [22 x i8] c"\0AThe root count : %d\0A\00"
@.str.8 = [40 x i8] c"interactive selection of solutions... \0A\00"
@.str.9 = [45 x i8] c"\0AGive an index to a solution (-1 to exit) : \00"
@.str.10 = [19 x i8] c"\0ASolution %d : \0A%s\00"
define i32 @dobldobl_interactive_input_output() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca [800 x i8]
%11 = alloca i8*
%12 = alloca i64
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = call i32 @syscon_initialize_number_of_dobldobl_polynomials(i32 %15)
store i32 %16, i32* %2
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %20
20: ; preds = %35, %0
%21 = load i32, i32* %3
%22 = load i32, i32* %1
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = call signext i8 (...) @getchar()
store i8 %27, i8* %9
%28 = getelementptr inbounds [800 x i8], [800 x i8]* %10, i64 0, i64 0
%29 = call i32 @read_poly(i32* %4, i8* %28)
%30 = load i32, i32* %4
%31 = load i32, i32* %1
%32 = load i32, i32* %3
%33 = getelementptr inbounds [800 x i8], [800 x i8]* %10, i64 0, i64 0
%34 = call i32 @syscon_store_dobldobl_polynomial(i32 %30, i32 %31, i32 %32, i8* %33)
store i32 %34, i32* %2
br label %35
35: ; preds = %24
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %20
38: ; preds = %20
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 (...) @syscon_write_dobldobl_system()
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%43 = load i32, i32* %8
%44 = call i32 @solve_dobldobl_system(i32* %6, i32 %43)
store i32 %44, i32* %2
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
br label %48
48: ; preds = %67, %38
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%51 = load i32, i32* %3
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %48
br label %70
54: ; preds = %48
%55 = load i32, i32* %3
%56 = call i32 @solcon_length_dobldobl_solution_string(i32 %55, i32* %7)
store i32 %56, i32* %2
%57 = load i32, i32* %7
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %11
%60 = alloca i8, i64 %58
store i64 %58, i64* %12
%61 = load i32, i32* %3
%62 = load i32, i32* %7
%63 = call i32 @solcon_write_dobldobl_solution_string(i32 %61, i32 %62, i8* %60)
store i32 %63, i32* %2
%64 = load i32, i32* %3
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 %64, i8* %60)
%66 = load i8*, i8** %11
br label %67
67: ; preds = %54
%68 = load i32, i32* %3
%69 = icmp sge i32 %68, 0
br i1 %69, label %48, label %70
70: ; preds = %67, %53
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
@.str = [49 x i8] c"\0AGive the number of polynomials in the system : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AReading %d polynomials, \00"
@.str.4 = [20 x i8] c"-> polynomial %d : \00"
@.str.6 = [29 x i8] c"\0AGive the number of tasks : \00"
@.str.7 = [22 x i8] c"\0AThe root count : %d\0A\00"
@.str.9 = [45 x i8] c"\0AGive an index to a solution (-1 to exit) : \00"
@.str.10 = [19 x i8] c"\0ASolution %d : \0A%s\00"
@str = [37 x i8] c"terminate each with ; (semicolon)...\00"
@str.11 = [31 x i8] c"The system in the container : \00"
@str.12 = [39 x i8] c"interactive selection of solutions... \00"
define i32 @dobldobl_interactive_input_output() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [800 x i8]
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = getelementptr inbounds [800 x i8], [800 x i8]* %7, i64 0, i64 0
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 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* %1)
%17 = load i32, i32* %1
%18 = call i32 @syscon_initialize_number_of_dobldobl_polynomials(i32 %17)
%19 = load i32, i32* %1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
store i32 1, i32* %2
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 1
br i1 %23, label %35, label %24
24: ; preds = %0, %24
%25 = phi i32 [ %32, %24 ], [ 1, %0 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = call signext i8 (...) @getchar()
%28 = call i32 @read_poly(i32* %3, i8* %14)
%29 = load i32, i32* %3
%30 = load i32, i32* %1
%31 = call i32 @syscon_store_dobldobl_polynomial(i32 %29, i32 %30, i32 %25, i8* %14)
%32 = add nuw nsw i32 %25, 1
store i32 %32, i32* %2
%33 = load i32, i32* %1
%34 = icmp slt i32 %25, %33
br i1 %34, label %24, label %35
35: ; preds = %24, %0
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.11, i64 0, i64 0))
%37 = call i32 (...) @syscon_write_dobldobl_system()
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%40 = load i32, i32* %6
%41 = call i32 @solve_dobldobl_system(i32* %4, i32 %40)
%42 = load i32, i32* %4
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.12, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%47 = load i32, i32* %2
%48 = icmp slt i32 %47, 0
br i1 %48, label %68, label %54
49: ; preds = %54
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%52 = load i32, i32* %2
%53 = icmp slt i32 %52, 0
br i1 %53, label %68, label %54
54: ; preds = %35, %49
%55 = phi i32 [ %52, %49 ], [ %47, %35 ]
%56 = call i32 @solcon_length_dobldobl_solution_string(i32 %55, i32* %5)
%57 = load i32, i32* %5
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
%60 = alloca i8, i64 %58
%61 = load i32, i32* %2
%62 = load i32, i32* %5
%63 = call i32 @solcon_write_dobldobl_solution_string(i32 %61, i32 %62, i8* %60)
%64 = load i32, i32* %2
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 %64, i8* %60)
%66 = load i32, i32* %2
%67 = icmp sgt i32 %66, -1
br i1 %67, label %49, label %68
68: ; preds = %54, %49, %35
%69 = phi i32 [ %41, %35 ], [ %63, %49 ], [ %63, %54 ]
ret i32 %69
}