#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 */
struct arc {
  int dummy;
};

/* Variables and functions */
double arc_ang(struct arc *);
scalar_t__ error();
int count_sub_arc(struct arc *a, double alpha) {
  double ang;
  int ndiv, npoint;
  ang = arc_ang(a);
  if (error())
    return (0);
  ndiv = ang / alpha + 1;
  if (ndiv < 2)
    ndiv = 2;
  npoint = ndiv + 1;
  return (npoint);
}


x86 assembly (clang, -O0):
<count_sub_arc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <arc_ang@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <error@plt>
cmp    $0x0,%rax
je     115c <count_sub_arc+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1199 <count_sub_arc+0x79>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    118a <count_sub_arc+0x6a>
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_sub_arc>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
call   1040 <arc_ang@plt>
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <error@plt>
test   %rax,%rax
jne    1168 <count_sub_arc+0x48>
movsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
addsd  0xeaa(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x3,%eax
mov    $0x2,%ebx
cmovge %eax,%ebx
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.arc = type { i32 }
define i32 @count_sub_arc(%struct.arc* %0, double %1) {
%3 = alloca i32
%4 = alloca %struct.arc*
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
store %struct.arc* %0, %struct.arc** %4
store double %1, double* %5
%9 = load %struct.arc*, %struct.arc** %4
%10 = call double @arc_ang(%struct.arc* %9)
store double %10, double* %6
%11 = call i64 (...) @error()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %27
14: ; preds = %2
%15 = load double, double* %6
%16 = load double, double* %5
%17 = fdiv double %15, %16
%18 = fadd double %17, 1.000000e+00
%19 = fptosi double %18 to i32
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 2, i32* %7
br label %23
23: ; preds = %22, %14
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
%26 = load i32, i32* %8
store i32 %26, i32* %3
br label %27
27: ; preds = %23, %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.arc = type { i32 }
define i32 @count_sub_arc(%struct.arc* %0, double %1) {
%3 = tail call double @arc_ang(%struct.arc* %0)
%4 = tail call i64 (...) @error()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = fdiv double %3, %1
%8 = fadd double %7, 1.000000e+00
%9 = fptosi double %8 to i32
%10 = icmp sgt i32 %9, 2
%11 = select i1 %10, i32 %9, i32 2
%12 = add nuw nsw i32 %11, 1
br label %13
13: ; preds = %2, %6
%14 = phi i32 [ %12, %6 ], [ 0, %2 ]
ret i32 %14
}