#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 */
double fabs(double const);
double pow(double, double);
double sqrt(double);
double cmod(const double r, const double i) {
  double ar, ai;
  ar = fabs(r);
  ai = fabs(i);
  if (ar < ai)
    return ai * sqrt(1.0 + pow((ar / ai), 2.0));
  if (ar > ai)
    return ar * sqrt(1.0 + pow((ai / ar), 2.0));
  return ar * sqrt(2.0);
}


x86 assembly (clang, -O0):
<cmod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xec2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xead(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bb <cmod+0x9b>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe7c(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123e <cmod+0x11e>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1216 <cmod+0xf6>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  0xe29(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe21(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123e <cmod+0x11e>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xde8(%rip),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmod>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xee0(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
jbe    1151 <cmod+0x41>
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
addsd  0xeda(%rip),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     117a <cmod+0x6a>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    118d <cmod+0x7d>
ucomisd %xmm1,%xmm2
jbe    1196 <cmod+0x86>
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xeb1(%rip),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11a0 <cmod+0x90>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11b3 <cmod+0xa3>
movapd %xmm2,%xmm0
movapd %xmm1,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xe72(%rip),%xmm0
jmp    11b3 <cmod+0xa3>
movapd %xmm1,%xmm0
movapd %xmm2,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm2
mulsd  %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @cmod(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = call double @llvm.fabs.f64(double %8)
store double %9, double* %6
%10 = load double, double* %5
%11 = call double @llvm.fabs.f64(double %10)
store double %11, double* %7
%12 = load double, double* %6
%13 = load double, double* %7
%14 = fcmp olt double %12, %13
br i1 %14, label %15, label %24
15: ; preds = %2
%16 = load double, double* %7
%17 = load double, double* %6
%18 = load double, double* %7
%19 = fdiv double %17, %18
%20 = call double @pow(double %19, double 2.000000e+00)
%21 = fadd double 1.000000e+00, %20
%22 = call double @sqrt(double %21)
%23 = fmul double %16, %22
store double %23, double* %3
br label %41
24: ; preds = %2
%25 = load double, double* %6
%26 = load double, double* %7
%27 = fcmp ogt double %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load double, double* %6
%30 = load double, double* %7
%31 = load double, double* %6
%32 = fdiv double %30, %31
%33 = call double @pow(double %32, double 2.000000e+00)
%34 = fadd double 1.000000e+00, %33
%35 = call double @sqrt(double %34)
%36 = fmul double %29, %35
store double %36, double* %3
br label %41
37: ; preds = %24
%38 = load double, double* %6
%39 = call double @sqrt(double 2.000000e+00)
%40 = fmul double %38, %39
store double %40, double* %3
br label %41
41: ; preds = %37, %28, %15
%42 = load double, double* %3
ret double %42
}

LLVM IR (-O2):
define double @cmod(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call double @llvm.fabs.f64(double %1)
%5 = fcmp olt double %3, %4
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = fdiv double %3, %4
%8 = fmul double %7, %7
%9 = fadd double %8, 1.000000e+00
%10 = tail call double @sqrt(double %9)
%11 = fmul double %4, %10
br label %22
12: ; preds = %2
%13 = fcmp ogt double %3, %4
br i1 %13, label %14, label %20
14: ; preds = %12
%15 = fdiv double %4, %3
%16 = fmul double %15, %15
%17 = fadd double %16, 1.000000e+00
%18 = tail call double @sqrt(double %17)
%19 = fmul double %3, %18
br label %22
20: ; preds = %12
%21 = fmul double %3, 0x3FF6A09E667F3BCD
br label %22
22: ; preds = %20, %14, %6
%23 = phi double [ %11, %6 ], [ %19, %14 ], [ %21, %20 ]
ret double %23
}