#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 define_output_file();
int /*<<< orphan*/ printf(char *, ...);
int quaddobl_assign_labels(int, int);
int quaddobl_monodromy_breakup(int, int, int, int);
int read_quaddobl_witness_set(int *, int *, int *);
int /*<<< orphan*/ scanf(char *, ...);
int set_state_to_silent();
int syscon_write_quaddobl_system();
int quaddobl_test(void) {
  int fail, n, dim, deg, nbloops, kind;
  char ans;
  printf("\nReading a witness set ...\n");
  fail = read_quaddobl_witness_set(&n, &dim, &deg);
  printf("\nMENU for the kind of output :\n");
  printf("  0. remain silent with no intermediate output;\n");
  printf("  1. all intermediate output goes to screen;\n");
  printf("  2. give a file name for all intermediate output.\n");
  printf("Type 0, 1, or 2 to make a choice : ");
  scanf("%d", &kind);
  scanf("%c", &ans);
  if (kind == 0)
    fail = set_state_to_silent();
  if (kind == 2)
    fail = define_output_file();
  if (1 > 0) {
    printf("\nThe ambient dimension : %d.\n", n);
    printf("The dimension of the solution set : %d.\n", dim);
    printf("The degree of the solution set : %d.\n", deg);
    printf("\nDo you wish to see the embedded system ? (y/n) ");
    scanf("%c", &ans);
    if (ans == 'y') {
      printf("\nThe system read :\n");
      fail = syscon_write_quaddobl_system();
    }
  }
  fail = quaddobl_assign_labels(n, deg);
  printf("\nGive the number of loops : ");
  scanf("%d", &nbloops);
  fail = quaddobl_monodromy_breakup(nbloops, n, dim, deg);
  if (kind == 2)
    printf("See the output file for results.\n");
  return 0;
}


x86 assembly (clang, -O0):
<quaddobl_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   10a0 <read_quaddobl_witness_set@plt>
mov    %eax,-0x4(%rbp)
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    0xeed(%rip),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1228 <quaddobl_test+0xa8>
mov    $0x0,%al
call   1030 <set_state_to_silent@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    123c <quaddobl_test+0xbc>
mov    $0x0,%al
call   1050 <define_output_file@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe72(%rip),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x79,%eax
jne    12b4 <quaddobl_test+0x134>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <syscon_write_quaddobl_system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <quaddobl_assign_labels@plt>
mov    %eax,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1c(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1080 <quaddobl_monodromy_breakup@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    130e <quaddobl_test+0x18e>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quaddobl_test>:
sub    $0x18,%rsp
lea    0xf4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   10b0 <read_quaddobl_witness_set@plt>
lea    0xf45(%rip),%rdi
call   1030 <puts@plt>
lea    0xf58(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2b(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
lea    0xe1b(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     12fe <quaddobl_test+0x16e>
cmp    $0x2,%eax
jne    1230 <quaddobl_test+0xa0>
xor    %eax,%eax
call   1060 <define_output_file@plt>
mov    0xc(%rsp),%esi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe12(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdac(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
cmpb   $0x79,0x3(%rsp)
jne    12a1 <quaddobl_test+0x111>
lea    0xf3b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <syscon_write_quaddobl_system@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1080 <quaddobl_assign_labels@plt>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd61(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x8(%rsp),%ecx
call   1090 <quaddobl_monodromy_breakup@plt>
cmpl   $0x2,0x4(%rsp)
jne    12f7 <quaddobl_test+0x167>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
xor    %eax,%eax
call   1040 <set_state_to_silent@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1229 <quaddobl_test+0x99>
jmp    1230 <quaddobl_test+0xa0>

LLVM IR (-O0):
@.str = [28 x i8] c"\0AReading a witness set ...\0A\00"
@.str.1 = [32 x i8] c"\0AMENU for the kind of output :\0A\00"
@.str.2 = [49 x i8] c" 0. remain silent with no intermediate output;\0A\00"
@.str.3 = [46 x i8] c" 1. all intermediate output goes to screen;\0A\00"
@.str.4 = [52 x i8] c" 2. give a file name for all intermediate output.\0A\00"
@.str.5 = [36 x i8] c"Type 0, 1, or 2 to make a choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [30 x i8] c"\0AThe ambient dimension : %d.\0A\00"
@.str.9 = [41 x i8] c"The dimension of the solution set : %d.\0A\00"
@.str.10 = [38 x i8] c"The degree of the solution set : %d.\0A\00"
@.str.11 = [49 x i8] c"\0ADo you wish to see the embedded system ? (y/n) \00"
@.str.12 = [20 x i8] c"\0AThe system read :\0A\00"
@.str.13 = [29 x i8] c"\0AGive the number of loops : \00"
@.str.14 = [34 x i8] c"See the output file for results.\0A\00"
define i32 @quaddobl_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @read_quaddobl_witness_set(i32* %2, i32* %3, i32* %4)
store i32 %9, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = call i32 (...) @set_state_to_silent()
store i32 %20, i32* %1
br label %21
21: ; preds = %19, %0
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @define_output_file()
store i32 %25, i32* %1
br label %26
26: ; preds = %24, %21
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%35 = load i8, i8* %7
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 121
br i1 %37, label %38, label %41
38: ; preds = %26
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%40 = call i32 (...) @syscon_write_quaddobl_system()
store i32 %40, i32* %1
br label %41
41: ; preds = %38, %26
%42 = load i32, i32* %2
%43 = load i32, i32* %4
%44 = call i32 @quaddobl_assign_labels(i32 %42, i32 %43)
store i32 %44, i32* %1
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%46 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%47 = load i32, i32* %5
%48 = load i32, i32* %2
%49 = load i32, i32* %3
%50 = load i32, i32* %4
%51 = call i32 @quaddobl_monodromy_breakup(i32 %47, i32 %48, i32 %49, i32 %50)
store i32 %51, i32* %1
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 2
br i1 %53, label %54, label %56
54: ; preds = %41
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0))
br label %56
56: ; preds = %54, %41
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [36 x i8] c"Type 0, 1, or 2 to make a choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [30 x i8] c"\0AThe ambient dimension : %d.\0A\00"
@.str.9 = [41 x i8] c"The dimension of the solution set : %d.\0A\00"
@.str.10 = [38 x i8] c"The degree of the solution set : %d.\0A\00"
@.str.11 = [49 x i8] c"\0ADo you wish to see the embedded system ? (y/n) \00"
@.str.13 = [29 x i8] c"\0AGive the number of loops : \00"
@str = [27 x i8] c"\0AReading a witness set ...\00"
@str.15 = [31 x i8] c"\0AMENU for the kind of output :\00"
@str.16 = [48 x i8] c" 0. remain silent with no intermediate output;\00"
@str.17 = [45 x i8] c" 1. all intermediate output goes to screen;\00"
@str.18 = [51 x i8] c" 2. give a file name for all intermediate output.\00"
@str.19 = [33 x i8] c"See the output file for results.\00"
@str.20 = [19 x i8] c"\0AThe system read :\00"
define i32 @quaddobl_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%13 = call i32 @read_quaddobl_witness_set(i32* %1, i32* %2, i32* %3)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.15, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.16, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.17, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.18, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = call i32 (...) @set_state_to_silent()
%25 = load i32, i32* %5
br label %26
26: ; preds = %23, %0
%27 = phi i32 [ %25, %23 ], [ %21, %0 ]
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (...) @define_output_file()
br label %31
31: ; preds = %29, %26
%32 = load i32, i32* %1
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0))
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%40 = load i8, i8* %6
%41 = icmp eq i8 %40, 121
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.20, i64 0, i64 0))
%44 = call i32 (...) @syscon_write_quaddobl_system()
br label %45
45: ; preds = %42, %31
%46 = load i32, i32* %1
%47 = load i32, i32* %3
%48 = call i32 @quaddobl_assign_labels(i32 %46, i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%51 = load i32, i32* %4
%52 = load i32, i32* %1
%53 = load i32, i32* %2
%54 = load i32, i32* %3
%55 = call i32 @quaddobl_monodromy_breakup(i32 %51, i32 %52, i32 %53, i32 %54)
%56 = load i32, i32* %5
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %60
58: ; preds = %45
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.19, i64 0, i64 0))
br label %60
60: ; preds = %58, %45
ret i32 0
}