#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ solcon_write_solutions();
int /*<<< orphan*/ syscon_write_system();
int witness_set_of_hypersurface(int, int, char *);
int main(int argc, char *argv[]) {
  int i, n, fail;
  const int max = 80;
  char p[max];
  char nl;
  adainit();
  printf("\nMaking a witness set for a polynomial ...\n");
  printf("  give the number of variables : ");
  scanf("%d", &n);
  scanf("%c", &nl);
  printf("  give a polynomial (end with \';\'): ");
  for (i = 0; i < max; i++) {
    scanf("%c", &p[i]);
    if (p[i] == ';') {
      p[++i] = '\0';
      break;
    }
  }
  printf("Your polynomial in %d variables is %s\n", n, p);
  fail = witness_set_of_hypersurface(n, i + 1, p);
  printf("\nThe embedded system :\n");
  syscon_write_system();
  printf("\nThe witness points :\n");
  solcon_write_solutions();
  adafinal();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x50,-0x20(%rbp)
mov    %rsp,%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1090 <adainit@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe7e(%rip),%rdi
lea    -0x29(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    1250 <main+0xe0>
movslq -0x14(%rbp),%rax
lea    -0x80(%rbp),%rsi
add    %rax,%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
movslq -0x14(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x3b,%eax
jne    123d <main+0xcd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
jmp    1250 <main+0xe0>
jmp    1242 <main+0xd2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f3 <main+0x83>
mov    -0x18(%rbp),%esi
lea    0xe1f(%rip),%rdi
lea    -0x80(%rbp),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    -0x80(%rbp),%rdx
call   1060 <witness_set_of_hypersurface@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <syscon_write_system@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <solcon_write_solutions@plt>
mov    $0x0,%al
call   1070 <adafinal@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsp,%r15
xor    %eax,%eax
call   10a0 <adainit@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xe5e(%rip),%r14
lea    0xb(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rsi
add    $0x10,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
cmpb   $0x3b,0x10(%rsp,%rbx,1)
je     121a <main+0x9a>
add    $0x1,%rbx
cmp    $0x50,%rbx
jne    11f0 <main+0x70>
mov    $0x51,%ebx
jmp    1222 <main+0xa2>
movb   $0x0,0x11(%rsp,%rbx,1)
add    $0x2,%ebx
mov    0xc(%rsp),%esi
lea    0xe20(%rip),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   1070 <witness_set_of_hypersurface@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <syscon_write_system@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <solcon_write_solutions@plt>
xor    %eax,%eax
call   1080 <adafinal@plt>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"\0AMaking a witness set for a polynomial ...\0A\00"
@.str.1 = [34 x i8] c" give the number of variables : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [37 x i8] c" give a polynomial (end with ';'): \00"
@.str.5 = [39 x i8] c"Your polynomial in %d variables is %s\0A\00"
@.str.6 = [24 x i8] c"\0AThe embedded system :\0A\00"
@.str.7 = [23 x i8] c"\0AThe witness points :\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 80, i32* %9
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %10
%13 = alloca i8, i64 80
%14 = call i32 (...) @adainit()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %20
20: ; preds = %40, %2
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 80
br i1 %22, label %23, label %43
23: ; preds = %20
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %13, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %13, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 59
br i1 %33, label %34, label %39
34: ; preds = %23
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %13, i64 %37
store i8 0, i8* %38
br label %43
39: ; preds = %23
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %20
43: ; preds = %34, %20
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %44, i8* %13)
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
%49 = call i32 @witness_set_of_hypersurface(i32 %46, i32 %48, i8* %13)
store i32 %49, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%51 = call i32 (...) @syscon_write_system()
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%53 = call i32 (...) @solcon_write_solutions()
%54 = call i32 (...) @adafinal()
store i32 0, i32* %3
%55 = load i8*, i8** %10
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c" give the number of variables : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [37 x i8] c" give a polynomial (end with ';'): \00"
@.str.5 = [39 x i8] c"Your polynomial in %d variables is %s\0A\00"
@str = [43 x i8] c"\0AMaking a witness set for a polynomial ...\00"
@str.8 = [23 x i8] c"\0AThe embedded system :\00"
@str.9 = [22 x i8] c"\0AThe witness points :\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i8
%5 = bitcast i32* %3 to i8*
%6 = tail call i8* @llvm.stacksave()
%7 = alloca [80 x i8]
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%9 = tail call i32 (...) @adainit()
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %2, %27
%16 = phi i64 [ 0, %2 ], [ %28, %27 ]
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %16
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = load i8, i8* %17
%20 = icmp eq i8 %19, 59
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = trunc i64 %16 to i32
%23 = add nuw i64 %16, 1
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %24
store i8 0, i8* %25
%26 = add i32 %22, 2
br label %30
27: ; preds = %15
%28 = add nuw nsw i64 %16, 1
%29 = icmp eq i64 %28, 80
br i1 %29, label %30, label %15
30: ; preds = %27, %21
%31 = phi i32 [ %26, %21 ], [ 81, %27 ]
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %32, i8* %8)
%34 = load i32, i32* %3
%35 = call i32 @witness_set_of_hypersurface(i32 %34, i32 %31, i8* %8)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%37 = call i32 (...) @syscon_write_system()
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%39 = call i32 (...) @solcon_write_solutions()
%40 = call i32 (...) @adafinal()
ret i32 0
}