#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 sqrt(double);
double zabs_(double *zr, double *zi) {
  double ret_val;
  double q, s, u, v;
  u = ((*zr) >= 0 ? (*zr) : -(*zr));
  v = ((*zi) >= 0 ? (*zi) : -(*zi));
  s = u + v;
  s *= 1.;
  if (s == 0.) {
    goto L20;
  }
  if (u > v) {
    goto L10;
  }
  q = u / v;
  ret_val = v * sqrt(q * q + 1.);
  return ret_val;
L10:
  q = v / u;
  ret_val = u * sqrt(q * q + 1.);
  return ret_val;
L20:
  ret_val = 0.;
  return ret_val;
}


x86 assembly (clang, -O0):
<zabs_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1147 <zabs_+0x37>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    116b <zabs_+0x5b>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119c <zabs_+0x8c>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11c0 <zabs_+0xb0>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe1f(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1208 <zabs_+0xf8>
jp     1208 <zabs_+0xf8>
jmp    12cd <zabs_+0x1bd>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    121d <zabs_+0x10d>
jmp    1275 <zabs_+0x165>
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdb4(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12df <zabs_+0x1cf>
movsd  -0x40(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd5c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12df <zabs_+0x1cf>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zabs_>:
push   %rax
movsd  (%rdi),%xmm1
movapd 0xee3(%rip),%xmm2
movapd %xmm1,%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
xorpd  %xmm0,%xmm0
cmpnlesd %xmm1,%xmm0
andpd  %xmm0,%xmm3
andnpd %xmm1,%xmm0
orpd   %xmm3,%xmm0
movsd  (%rsi),%xmm3
xorpd  %xmm3,%xmm2
xorpd  %xmm1,%xmm1
cmpnlesd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
ucomisd %xmm4,%xmm2
jne    116b <zabs_+0x5b>
jnp    11c2 <zabs_+0xb2>
ucomisd %xmm1,%xmm0
jbe    118b <zabs_+0x7b>
movapd %xmm0,%xmm4
divsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xe8b(%rip),%xmm1
movapd %xmm1,%xmm0
jmp    119f <zabs_+0x8f>
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
addsd  0xe75(%rip),%xmm0
movapd %xmm1,%xmm4
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11af <zabs_+0x9f>
sqrtsd %xmm0,%xmm0
jmp    11be <zabs_+0xae>
movsd  %xmm4,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm4,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @zabs_(double* %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %4
store double* %1, double** %5
%11 = load double*, double** %4
%12 = load double, double* %11
%13 = fcmp oge double %12, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load double*, double** %4
%16 = load double, double* %15
br label %21
17: ; preds = %2
%18 = load double*, double** %4
%19 = load double, double* %18
%20 = fneg double %19
br label %21
21: ; preds = %17, %14
%22 = phi double [ %16, %14 ], [ %20, %17 ]
store double %22, double* %9
%23 = load double*, double** %5
%24 = load double, double* %23
%25 = fcmp oge double %24, 0.000000e+00
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load double*, double** %5
%28 = load double, double* %27
br label %33
29: ; preds = %21
%30 = load double*, double** %5
%31 = load double, double* %30
%32 = fneg double %31
br label %33
33: ; preds = %29, %26
%34 = phi double [ %28, %26 ], [ %32, %29 ]
store double %34, double* %10
%35 = load double, double* %9
%36 = load double, double* %10
%37 = fadd double %35, %36
store double %37, double* %8
%38 = load double, double* %8
%39 = fmul double %38, 1.000000e+00
store double %39, double* %8
%40 = load double, double* %8
%41 = fcmp oeq double %40, 0.000000e+00
br i1 %41, label %42, label %43
42: ; preds = %33
br label %70
43: ; preds = %33
%44 = load double, double* %9
%45 = load double, double* %10
%46 = fcmp ogt double %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
br label %59
48: ; preds = %43
%49 = load double, double* %9
%50 = load double, double* %10
%51 = fdiv double %49, %50
store double %51, double* %7
%52 = load double, double* %10
%53 = load double, double* %7
%54 = load double, double* %7
%55 = call double @llvm.fmuladd.f64(double %53, double %54, double 1.000000e+00)
%56 = call double @sqrt(double %55)
%57 = fmul double %52, %56
store double %57, double* %6
%58 = load double, double* %6
store double %58, double* %3
br label %72
59: ; preds = %47
%60 = load double, double* %10
%61 = load double, double* %9
%62 = fdiv double %60, %61
store double %62, double* %7
%63 = load double, double* %9
%64 = load double, double* %7
%65 = load double, double* %7
%66 = call double @llvm.fmuladd.f64(double %64, double %65, double 1.000000e+00)
%67 = call double @sqrt(double %66)
%68 = fmul double %63, %67
store double %68, double* %6
%69 = load double, double* %6
store double %69, double* %3
br label %72
70: ; preds = %42
store double 0.000000e+00, double* %6
%71 = load double, double* %6
store double %71, double* %3
br label %72
72: ; preds = %70, %59, %48
%73 = load double, double* %3
ret double %73
}

LLVM IR (-O2):
define double @zabs_(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = fcmp ult double %3, 0.000000e+00
%5 = fneg double %3
%6 = select i1 %4, double %5, double %3
%7 = load double, double* %1
%8 = fcmp ult double %7, 0.000000e+00
%9 = fneg double %7
%10 = select i1 %8, double %9, double %7
%11 = fadd double %6, %10
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %26, label %13
13: ; preds = %2
%14 = fcmp ogt double %6, %10
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = fdiv double %6, %10
%17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double 1.000000e+00)
br label %21
18: ; preds = %13
%19 = fdiv double %10, %6
%20 = tail call double @llvm.fmuladd.f64(double %19, double %19, double 1.000000e+00)
br label %21
21: ; preds = %15, %18
%22 = phi double [ %20, %18 ], [ %17, %15 ]
%23 = phi double [ %6, %18 ], [ %10, %15 ]
%24 = tail call double @sqrt(double %22)
%25 = fmul double %23, %24
br label %26
26: ; preds = %21, %2
%27 = phi double [ 0.000000e+00, %2 ], [ %25, %21 ]
ret double %27
}