#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 drand48();
double atan_domain(void) {
  if (drand48() > 0.5) {
    if (drand48() > 0.5)
      return (1 / drand48());
    else
      return (drand48());
  } else {
    if (drand48() > 0.5)
      return (-1 / drand48());
    else
      return (-1 * drand48());
  }
}


x86 assembly (clang, -O0):
<atan_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  0xed5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1186 <atan_domain+0x76>
mov    $0x0,%al
call   1030 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  0xeb8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1171 <atan_domain+0x61>
mov    $0x0,%al
call   1030 <drand48@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d8 <atan_domain+0xc8>
mov    $0x0,%al
call   1030 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d8 <atan_domain+0xc8>
mov    $0x0,%al
call   1030 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe67(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c2 <atan_domain+0xb2>
mov    $0x0,%al
call   1030 <drand48@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d8 <atan_domain+0xc8>
mov    $0x0,%al
call   1030 <drand48@plt>
imul   $0xffffffff,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan_domain>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <drand48@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <drand48@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <drand48@plt>
mov    %eax,%ecx
test   %ebp,%ebp
jle    1145 <atan_domain+0x35>
test   %ebx,%ebx
jle    1157 <atan_domain+0x47>
lea    0x1(%rcx),%eax
xor    %edx,%edx
cmp    $0x3,%eax
cmovb  %ecx,%edx
mov    %edx,%ecx
jmp    1157 <atan_domain+0x47>
test   %ebx,%ebx
jle    1155 <atan_domain+0x45>
mov    $0xffffffff,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
jmp    1157 <atan_domain+0x47>
neg    %ecx
cvtsi2sd %ecx,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @atan_domain() {
%1 = alloca double
%2 = call i32 (...) @drand48()
%3 = sitofp i32 %2 to double
%4 = fcmp ogt double %3, 5.000000e-01
br i1 %4, label %5, label %16
5: ; preds = %0
%6 = call i32 (...) @drand48()
%7 = sitofp i32 %6 to double
%8 = fcmp ogt double %7, 5.000000e-01
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = call i32 (...) @drand48()
%11 = sdiv i32 1, %10
%12 = sitofp i32 %11 to double
store double %12, double* %1
br label %28
13: ; preds = %5
%14 = call i32 (...) @drand48()
%15 = sitofp i32 %14 to double
store double %15, double* %1
br label %28
16: ; preds = %0
%17 = call i32 (...) @drand48()
%18 = sitofp i32 %17 to double
%19 = fcmp ogt double %18, 5.000000e-01
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = call i32 (...) @drand48()
%22 = sdiv i32 -1, %21
%23 = sitofp i32 %22 to double
store double %23, double* %1
br label %28
24: ; preds = %16
%25 = call i32 (...) @drand48()
%26 = mul nsw i32 -1, %25
%27 = sitofp i32 %26 to double
store double %27, double* %1
br label %28
28: ; preds = %24, %20, %13, %9
%29 = load double, double* %1
ret double %29
}

LLVM IR (-O2):
define double @atan_domain() {
%1 = tail call i32 (...) @drand48()
%2 = icmp sgt i32 %1, 0
%3 = tail call i32 (...) @drand48()
%4 = icmp sgt i32 %3, 0
%5 = tail call i32 (...) @drand48()
br i1 %2, label %6, label %11
6: ; preds = %0
br i1 %4, label %7, label %16
7: ; preds = %6
%8 = add i32 %5, 1
%9 = icmp ult i32 %8, 3
%10 = select i1 %9, i32 %5, i32 0
br label %16
11: ; preds = %0
br i1 %4, label %12, label %14
12: ; preds = %11
%13 = sdiv i32 -1, %5
br label %16
14: ; preds = %11
%15 = sub nsw i32 0, %5
br label %16
16: ; preds = %6, %14, %12, %7
%17 = phi i32 [ %10, %7 ], [ %13, %12 ], [ %15, %14 ], [ %5, %6 ]
%18 = sitofp i32 %17 to double
ret double %18
}