#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);
double pow(double, int);
double sqrt(double);
double cmod(double r, double i) {
  double ar, ai;
  ar = fabs(r);
  ai = fabs(i);
  if (ar < ai)
    return ai * sqrt(1.0 + pow(ar / ai, 2));
  if (ar > ai)
    return ar * sqrt(1.0 + pow(ai / ar, 2));
  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    11b8 <cmod+0x98>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe7f(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1238 <cmod+0x118>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1210 <cmod+0xf0>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe27(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1238 <cmod+0x118>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdee(%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 0xed0(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
jbe    116d <cmod+0x4d>
movapd %xmm1,(%rsp)
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0xebb(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a2 <cmod+0x82>
sqrtsd %xmm0,%xmm0
jmp    11a7 <cmod+0x87>
ucomisd %xmm1,%xmm2
jbe    11b5 <cmod+0x95>
movapd %xmm2,(%rsp)
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0xe86(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c6 <cmod+0xa6>
sqrtsd %xmm0,%xmm0
jmp    11cb <cmod+0xab>
call   1040 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xe53(%rip),%xmm0
mulsd  %xmm2,%xmm0
add    $0x18,%rsp
ret
call   1040 <sqrt@plt>
mulsd  (%rsp),%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, i32 2)
%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, i32 2)
%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 = tail call double @pow(double %7, i32 2)
%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 = tail call double @pow(double %15, i32 2)
%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
}