#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*/ already_solved(double *, double *);
unsigned int arc_find_angles(double *, double *);
unsigned int find_angle(double *);
unsigned int find_side(double *, double *);
int solve_polygon(double *angles, double *sides) {
  unsigned int new_discovery, new_discovery_old;
  new_discovery_old = 0;
  while (!already_solved(angles, sides)) {
    new_discovery = 0;
    new_discovery |= find_angle(angles);
    new_discovery |= find_side(sides, angles);
    new_discovery |= arc_find_angles(angles, sides);
    if (new_discovery == new_discovery_old && new_discovery == 0)
      return 0;
    new_discovery_old = new_discovery;
  }
  return 1;
}


x86 assembly (clang, -O0):
<solve_polygon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <already_solved@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1179 <solve_polygon+0x39>
jmp    11e2 <solve_polygon+0xa2>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <find_angle@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <find_side@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <arc_find_angles@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11d7 <solve_polygon+0x97>
cmpl   $0x0,-0x1c(%rbp)
jne    11d7 <solve_polygon+0x97>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <solve_polygon+0xa9>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1157 <solve_polygon+0x17>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_polygon>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <already_solved@plt>
test   %eax,%eax
jne    1191 <solve_polygon+0x51>
mov    %r12,%rdi
call   1060 <find_angle@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <find_side@plt>
mov    %eax,%ebp
or     %r15d,%ebp
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <arc_find_angles@plt>
or     %ebp,%eax
or     %eax,%ebx
mov    %eax,%ebx
jne    1150 <solve_polygon+0x10>
xor    %eax,%eax
jmp    1196 <solve_polygon+0x56>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @solve_polygon(double* %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 0, i32* %7
br label %8
8: ; preds = %36, %2
%9 = load double*, double** %4
%10 = load double*, double** %5
%11 = call i32 @already_solved(double* %9, double* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %38
14: ; preds = %8
store i32 0, i32* %6
%15 = load double*, double** %4
%16 = call i32 @find_angle(double* %15)
%17 = load i32, i32* %6
%18 = or i32 %17, %16
store i32 %18, i32* %6
%19 = load double*, double** %5
%20 = load double*, double** %4
%21 = call i32 @find_side(double* %19, double* %20)
%22 = load i32, i32* %6
%23 = or i32 %22, %21
store i32 %23, i32* %6
%24 = load double*, double** %4
%25 = load double*, double** %5
%26 = call i32 @arc_find_angles(double* %24, double* %25)
%27 = load i32, i32* %6
%28 = or i32 %27, %26
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %14
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 0, i32* %3
br label %39
36: ; preds = %32, %14
%37 = load i32, i32* %6
store i32 %37, i32* %7
br label %8
38: ; preds = %8
store i32 1, i32* %3
br label %39
39: ; preds = %38, %35
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @solve_polygon(double* %0, double* %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i32 [ 0, %2 ], [ %12, %7 ]
%5 = tail call i32 @already_solved(double* %0, double* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %3
%8 = tail call i32 @find_angle(double* %0)
%9 = tail call i32 @find_side(double* %1, double* %0)
%10 = or i32 %9, %8
%11 = tail call i32 @arc_find_angles(double* %0, double* %1)
%12 = or i32 %10, %11
%13 = or i32 %12, %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %3
15: ; preds = %3, %7
%16 = phi i32 [ 0, %7 ], [ 1, %3 ]
ret i32 %16
}