#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 get_next_start_product(int *, int *, int, int, int, int, int, int, int, int,
                           double *, double *, double *);
int /*<<< orphan*/ printf(char *, int, int, int, ...);
int reporting_path_tracker(int, int *, double *, int *, int *, int *, int *);
int solcon_write_solution_banner_to_defined_output_file();
int solcon_write_solution_dimensions_to_defined_output_file(int, int);
int write_next_solution_with_diagnostics(int *, int, int, double *, int, int,
                                         int, int);
int intersect_two_witness_sets(int n1, int n2, int dim1, int dim2, int deg1,
                               int deg2, int cd, int monitor) {
  int fail, m, i, j, k, len, nbstep, nbfail, nbiter, nbsyst, ind;
  double sol1[2 * n1 + 5];
  double sol2[2 * n2 + 5];
  double ps[2 * cd + 5];
  fail = solcon_write_solution_banner_to_defined_output_file();
  len = deg1 * deg2;
  fail = solcon_write_solution_dimensions_to_defined_output_file(len, cd);
  for (k = 0, i = 0, j = 0; k < len; k++) {
    if (monitor == 1)
      printf("%d x %d = %d ... ", i, j, k);
    fail = get_next_start_product(&i, &j, monitor, n1, n2, dim1, dim2, deg1,
                                  deg2, cd, sol1, sol2, ps);
    m = 1;
    fail =
        reporting_path_tracker(cd, &m, ps, &nbstep, &nbfail, &nbiter, &nbsyst);
    if (monitor == 1)
      printf(" #step : %3d #fail : %3d #iter : %3d #syst : %3d\n", nbstep,
             nbfail, nbiter, nbsyst);
    ind = k;
    fail = write_next_solution_with_diagnostics(&ind, cd, m, ps, nbstep, nbfail,
                                                nbiter, nbsyst);
  }
  return fail;
}


x86 assembly (clang, -O0):
<intersect_two_witness_sets>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
mov    %ecx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
mov    %r9d,-0x38(%rbp)
mov    -0x24(%rbp),%ecx
mov    %ecx,%eax
lea    0x5(%rax,%rax,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x70(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%ecx
mov    %ecx,%eax
lea    0x5(%rax,%rax,1),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x80(%rbp)
mov    0x10(%rbp),%ecx
mov    %ecx,%eax
lea    0x5(%rax,%rax,1),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
mov    $0x0,%al
call   1050 <solcon_write_solution_banner_to_defined_output_file@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%edi
mov    0x10(%rbp),%esi
call   1040 <solcon_write_solution_dimensions_to_defined_output_file@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    138a <intersect_two_witness_sets+0x22a>
cmpl   $0x1,0x18(%rbp)
jne    1275 <intersect_two_witness_sets+0x115>
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    -0x4c(%rbp),%ecx
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rax
mov    -0x98(%rbp),%r10
mov    -0xa0(%rbp),%r11
mov    0x18(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%r12d
mov    -0x34(%rbp),%r15d
mov    -0x38(%rbp),%r14d
mov    0x10(%rbp),%ebx
lea    -0x44(%rbp),%rdi
lea    -0x48(%rbp),%rsi
sub    $0x40,%rsp
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1080 <get_next_start_product@plt>
mov    -0x90(%rbp),%rdx
add    $0x40,%rsp
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
mov    0x10(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x54(%rbp),%rcx
lea    -0x58(%rbp),%r8
lea    -0x5c(%rbp),%r9
lea    -0x60(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
call   1030 <reporting_path_tracker@plt>
add    $0x10,%rsp
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,0x18(%rbp)
jne    133e <intersect_two_witness_sets+0x1de>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
mov    -0x5c(%rbp),%ecx
mov    -0x60(%rbp),%r8d
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rcx
mov    -0x4c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    0x10(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x54(%rbp),%r8d
mov    -0x58(%rbp),%r9d
mov    -0x5c(%rbp),%r10d
mov    -0x60(%rbp),%eax
lea    -0x64(%rbp),%rdi
sub    $0x10,%rsp
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1070 <write_next_solution_with_diagnostics@plt>
add    $0x10,%rsp
mov    %eax,-0x3c(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1248 <intersect_two_witness_sets+0xe8>
mov    -0x3c(%rbp),%eax
mov    -0x70(%rbp),%rcx
mov    %rcx,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersect_two_witness_sets>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9d,%ebx
mov    %r8d,%r15d
mov    %rcx,-0x78(%rbp)
mov    %edx,-0x48(%rbp)
mov    %rsp,-0x88(%rbp)
mov    0x10(%rbp),%r12d
mov    %rdi,-0x68(%rbp)
lea    (%rdi,%rdi,1),%eax
add    $0x5,%eax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rsi,-0x70(%rbp)
lea    (%rsi,%rsi,1),%eax
add    $0x5,%eax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
lea    (%r12,%r12,1),%eax
add    $0x5,%eax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
xor    %eax,%eax
call   1050 <solcon_write_solution_banner_to_defined_output_file@plt>
mov    %rbx,-0x80(%rbp)
mov    %ebx,%r13d
mov    %r15,%rax
imul   %eax,%r13d
mov    %r13d,%edi
mov    %r12d,%esi
call   1040 <solcon_write_solution_dimensions_to_defined_output_file@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
test   %r13d,%r13d
jle    1372 <intersect_two_witness_sets+0x212>
mov    0x18(%rbp),%edx
xor    %ebx,%ebx
jmp    12cc <intersect_two_witness_sets+0x16c>
nopl   0x0(%rax)
sub    $0x8,%rsp
lea    -0x44(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x68(%rbp),%rcx
mov    -0x70(%rbp),%r8
mov    -0x48(%rbp),%r9d
push   %r14
push   -0x58(%rbp)
push   -0x60(%rbp)
push   %r12
push   -0x80(%rbp)
push   %r15
push   -0x78(%rbp)
call   1080 <get_next_start_product@plt>
add    $0x40,%rsp
movl   $0x1,-0x2c(%rbp)
sub    $0x8,%rsp
mov    %r12d,%edi
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x34(%rbp),%r9
lea    -0x30(%rbp),%rax
push   %rax
call   1030 <reporting_path_tracker@plt>
add    $0x10,%rsp
mov    %ebx,-0x4c(%rbp)
mov    -0x2c(%rbp),%edx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x34(%rbp),%r10d
mov    -0x30(%rbp),%eax
lea    -0x4c(%rbp),%rdi
mov    %r12d,%esi
mov    %r14,%rcx
push   %rax
push   %r10
call   1070 <write_next_solution_with_diagnostics@plt>
add    $0x10,%rsp
add    $0x1,%ebx
cmp    %ebx,%r13d
mov    0x18(%rbp),%edx
je     1372 <intersect_two_witness_sets+0x212>
cmp    $0x1,%edx
jne    1230 <intersect_two_witness_sets+0xd0>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
lea    0xd1e(%rip),%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
sub    $0x8,%rsp
lea    -0x44(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1,%edx
mov    -0x68(%rbp),%rcx
mov    -0x70(%rbp),%r8
mov    -0x48(%rbp),%r9d
push   %r14
push   -0x58(%rbp)
push   -0x60(%rbp)
push   %r12
push   -0x80(%rbp)
push   %r15
push   -0x78(%rbp)
call   1080 <get_next_start_product@plt>
add    $0x40,%rsp
movl   $0x1,-0x2c(%rbp)
sub    $0x8,%rsp
mov    %r12d,%edi
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x34(%rbp),%r9
lea    -0x30(%rbp),%rax
push   %rax
call   1030 <reporting_path_tracker@plt>
add    $0x10,%rsp
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    0xcac(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1292 <intersect_two_witness_sets+0x132>
mov    -0x88(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%d x %d = %d ... \00"
@.str.1 = [50 x i8] c" #step : %3d #fail : %3d #iter : %3d #syst : %3d\0A\00"
define i32 @intersect_two_witness_sets(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i8*
%29 = alloca i64
%30 = alloca i64
%31 = alloca i64
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%32 = load i32, i32* %9
%33 = mul nsw i32 2, %32
%34 = add nsw i32 %33, 5
%35 = zext i32 %34 to i64
%36 = call i8* @llvm.stacksave()
store i8* %36, i8** %28
%37 = alloca double, i64 %35
store i64 %35, i64* %29
%38 = load i32, i32* %10
%39 = mul nsw i32 2, %38
%40 = add nsw i32 %39, 5
%41 = zext i32 %40 to i64
%42 = alloca double, i64 %41
store i64 %41, i64* %30
%43 = load i32, i32* %15
%44 = mul nsw i32 2, %43
%45 = add nsw i32 %44, 5
%46 = zext i32 %45 to i64
%47 = alloca double, i64 %46
store i64 %46, i64* %31
%48 = call i32 (...) @solcon_write_solution_banner_to_defined_output_file()
store i32 %48, i32* %17
%49 = load i32, i32* %13
%50 = load i32, i32* %14
%51 = mul nsw i32 %49, %50
store i32 %51, i32* %22
%52 = load i32, i32* %22
%53 = load i32, i32* %15
%54 = call i32 @solcon_write_solution_dimensions_to_defined_output_file(i32 %52, i32 %53)
store i32 %54, i32* %17
store i32 0, i32* %21
store i32 0, i32* %19
store i32 0, i32* %20
br label %55
55: ; preds = %96, %8
%56 = load i32, i32* %21
%57 = load i32, i32* %22
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %99
59: ; preds = %55
%60 = load i32, i32* %16
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load i32, i32* %19
%64 = load i32, i32* %20
%65 = load i32, i32* %21
%66 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %63, i32 %64, i32 %65)
br label %67
67: ; preds = %62, %59
%68 = load i32, i32* %16
%69 = load i32, i32* %9
%70 = load i32, i32* %10
%71 = load i32, i32* %11
%72 = load i32, i32* %12
%73 = load i32, i32* %13
%74 = load i32, i32* %14
%75 = load i32, i32* %15
%76 = call i32 @get_next_start_product(i32* %19, i32* %20, i32 %68, i32 %69, i32 %70, i32 %71, i32 %72, i32 %73, i32 %74, i32 %75, double* %37, double* %42, double* %47)
store i32 %76, i32* %17
store i32 1, i32* %18
%77 = load i32, i32* %15
%78 = call i32 @reporting_path_tracker(i32 %77, i32* %18, double* %47, i32* %23, i32* %24, i32* %25, i32* %26)
store i32 %78, i32* %17
%79 = load i32, i32* %16
%80 = icmp eq i32 %79, 1
br i1 %80, label %81, label %87
81: ; preds = %67
%82 = load i32, i32* %23
%83 = load i32, i32* %24
%84 = load i32, i32* %25
%85 = load i32, i32* %26
%86 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %82, i32 %83, i32 %84, i32 %85)
br label %87
87: ; preds = %81, %67
%88 = load i32, i32* %21
store i32 %88, i32* %27
%89 = load i32, i32* %15
%90 = load i32, i32* %18
%91 = load i32, i32* %23
%92 = load i32, i32* %24
%93 = load i32, i32* %25
%94 = load i32, i32* %26
%95 = call i32 @write_next_solution_with_diagnostics(i32* %27, i32 %89, i32 %90, double* %47, i32 %91, i32 %92, i32 %93, i32 %94)
store i32 %95, i32* %17
br label %96
96: ; preds = %87
%97 = load i32, i32* %21
%98 = add nsw i32 %97, 1
store i32 %98, i32* %21
br label %55
99: ; preds = %55
%100 = load i32, i32* %17
%101 = load i8*, i8** %28
ret i32 %100
}

LLVM IR (-O2):
@.str = [18 x i8] c"%d x %d = %d ... \00"
@.str.1 = [50 x i8] c" #step : %3d #fail : %3d #iter : %3d #syst : %3d\0A\00"
define i32 @intersect_two_witness_sets(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = bitcast i32* %11 to i8*
%20 = bitcast i32* %12 to i8*
%21 = bitcast i32* %13 to i8*
%22 = bitcast i32* %14 to i8*
%23 = bitcast i32* %15 to i8*
%24 = bitcast i32* %16 to i8*
%25 = shl nsw i32 %0, 1
%26 = add nsw i32 %25, 5
%27 = zext i32 %26 to i64
%28 = tail call i8* @llvm.stacksave()
%29 = alloca double, i64 %27
%30 = shl nsw i32 %1, 1
%31 = add nsw i32 %30, 5
%32 = zext i32 %31 to i64
%33 = alloca double, i64 %32
%34 = shl nsw i32 %6, 1
%35 = add nsw i32 %34, 5
%36 = zext i32 %35 to i64
%37 = alloca double, i64 %36
%38 = tail call i32 (...) @solcon_write_solution_banner_to_defined_output_file()
%39 = mul nsw i32 %5, %4
%40 = tail call i32 @solcon_write_solution_dimensions_to_defined_output_file(i32 %39, i32 %6)
store i32 0, i32* %10
store i32 0, i32* %11
%41 = icmp sgt i32 %39, 0
br i1 %41, label %42, label %69
42: ; preds = %8
%43 = icmp eq i32 %7, 1
br label %44
44: ; preds = %42, %60
%45 = phi i32 [ 0, %42 ], [ %67, %60 ]
br i1 %43, label %46, label %57
46: ; preds = %44
%47 = load i32, i32* %10
%48 = load i32, i32* %11
%49 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %47, i32 %48, i32 %45)
%50 = call i32 @get_next_start_product(i32* %10, i32* %11, i32 1, i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double* %29, double* %33, double* %37)
store i32 1, i32* %9
%51 = call i32 @reporting_path_tracker(i32 %6, i32* %9, double* %37, i32* %12, i32* %13, i32* %14, i32* %15)
%52 = load i32, i32* %12
%53 = load i32, i32* %13
%54 = load i32, i32* %14
%55 = load i32, i32* %15
%56 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %52, i32 %53, i32 %54, i32 %55)
br label %60
57: ; preds = %44
%58 = call i32 @get_next_start_product(i32* %10, i32* %11, i32 %7, i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double* %29, double* %33, double* %37)
store i32 1, i32* %9
%59 = call i32 @reporting_path_tracker(i32 %6, i32* %9, double* %37, i32* %12, i32* %13, i32* %14, i32* %15)
br label %60
60: ; preds = %57, %46
store i32 %45, i32* %16
%61 = load i32, i32* %9
%62 = load i32, i32* %12
%63 = load i32, i32* %13
%64 = load i32, i32* %14
%65 = load i32, i32* %15
%66 = call i32 @write_next_solution_with_diagnostics(i32* %16, i32 %6, i32 %61, double* %37, i32 %62, i32 %63, i32 %64, i32 %65)
%67 = add nuw nsw i32 %45, 1
%68 = icmp eq i32 %67, %39
br i1 %68, label %69, label %44
69: ; preds = %60, %8
%70 = phi i32 [ %40, %8 ], [ %66, %60 ]
ret i32 %70
}