#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*/ adafinal();
int /*<<< orphan*/ adainit();
int /*<<< orphan*/ clear_set_structure();
int /*<<< orphan*/ compute_m_homogeneous_Bezout_number(int *);
int /*<<< orphan*/ compute_root_count(int *);
int /*<<< orphan*/ construct_start_system(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int r;
  printf("\nTesting linear-product root counts and systems...\n");
  adainit();
  printf("MENU for computing Bezout bounds :\n");
  printf("  1. test m-homogeneous Bezout numbers;\n");
  printf("  2. test general linear-product root counts.\n");
  printf("Type 1 or 2 to make your choice : ");
  scanf("%d", &r);
  if (r == 1) {
    compute_m_homogeneous_Bezout_number(&r);
  } else if (r == 2) {
    compute_root_count(&r);
    construct_start_system(r);
    clear_set_structure();
  } else
    printf("Wrong choice, please try again...\n");
  adafinal();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <adainit@plt>
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
lea    0xec0(%rip),%rdi
call   1050 <printf@plt>
lea    0xee3(%rip),%rdi
call   1050 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11fa <main+0x7a>
lea    -0x8(%rbp),%rdi
call   1040 <compute_m_homogeneous_Bezout_number@plt>
jmp    1232 <main+0xb2>
cmpl   $0x2,-0x8(%rbp)
jne    1221 <main+0xa1>
lea    -0x8(%rbp),%rdi
call   1030 <compute_root_count@plt>
mov    -0x8(%rbp),%edi
call   1090 <construct_start_system@plt>
mov    $0x0,%al
call   10a0 <clear_set_structure@plt>
jmp    122d <main+0xad>
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
jmp    1232 <main+0xb2>
mov    $0x0,%al
call   1060 <adafinal@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe8e(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1090 <adainit@plt>
lea    0xeae(%rip),%rdi
call   1050 <puts@plt>
lea    0xec5(%rip),%rdi
call   1050 <puts@plt>
lea    0xee1(%rip),%rdi
call   1050 <puts@plt>
lea    0xe31(%rip),%rdi
call   1060 <printf@plt>
lea    0xe48(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     11ff <main+0x6f>
cmp    $0x1,%eax
jne    121b <main+0x8b>
lea    0x4(%rsp),%rdi
call   1040 <compute_m_homogeneous_Bezout_number@plt>
jmp    1227 <main+0x97>
lea    0x4(%rsp),%rdi
call   1030 <compute_root_count@plt>
mov    0x4(%rsp),%edi
call   10a0 <construct_start_system@plt>
xor    %eax,%eax
call   10b0 <clear_set_structure@plt>
jmp    1227 <main+0x97>
lea    0xeb0(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <adafinal@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [52 x i8] c"\0ATesting linear-product root counts and systems...\0A\00"
@.str.1 = [36 x i8] c"MENU for computing Bezout bounds :\0A\00"
@.str.2 = [41 x i8] c" 1. test m-homogeneous Bezout numbers;\0A\00"
@.str.3 = [47 x i8] c" 2. test general linear-product root counts.\0A\00"
@.str.4 = [35 x i8] c"Type 1 or 2 to make your choice : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [35 x i8] c"Wrong choice, please try again...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @adainit()
%5 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @compute_m_homogeneous_Bezout_number(i32* %2)
br label %25
14: ; preds = %0
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call i32 @compute_root_count(i32* %2)
%19 = load i32, i32* %2
%20 = call i32 @construct_start_system(i32 %19)
%21 = call i32 (...) @clear_set_structure()
br label %24
22: ; preds = %14
%23 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %24
24: ; preds = %22, %17
br label %25
25: ; preds = %24, %12
%26 = call i32 (...) @adafinal()
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [35 x i8] c"Type 1 or 2 to make your choice : \00"
@.str.5 = [3 x i8] c"%d\00"
@str = [51 x i8] c"\0ATesting linear-product root counts and systems...\00"
@str.7 = [35 x i8] c"MENU for computing Bezout bounds :\00"
@str.8 = [40 x i8] c" 1. test m-homogeneous Bezout numbers;\00"
@str.9 = [46 x i8] c" 2. test general linear-product root counts.\00"
@str.10 = [34 x i8] c"Wrong choice, please try again...\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @adainit()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
switch i32 %10, label %18 [
i32 1, label %11
i32 2, label %13
]
11: ; preds = %0
%12 = call i32 @compute_m_homogeneous_Bezout_number(i32* %1)
br label %20
13: ; preds = %0
%14 = call i32 @compute_root_count(i32* %1)
%15 = load i32, i32* %1
%16 = call i32 @construct_start_system(i32 %15)
%17 = call i32 (...) @clear_set_structure()
br label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
br label %20
20: ; preds = %13, %18, %11
%21 = call i32 (...) @adafinal()
ret i32 0
}