#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 sqrt(int);
double zabs(double *x) {
  double v;
  if (fabs(x[0]) > fabs(x[1])) {
    v = fabs(x[1]) / fabs(x[0]);
    return (fabs(x[0]) * sqrt(1. + v * v));
  } else {
    if (x[1] == 0.)
      return (fabs(x[0]));
    else {
      v = fabs(x[0]) / fabs(x[1]);
      return (fabs(x[1]) * sqrt(1. + v * v));
    }
  }
}


x86 assembly (clang, -O0):
<zabs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xed5(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movaps 0xec1(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ce <zabs+0xbe>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movaps 0xea3(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xe90(%rip),%xmm2
pand   %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe74(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe65(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1284 <zabs+0x174>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1207 <zabs+0xf7>
jp     1207 <zabs+0xf7>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe07(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1284 <zabs+0x174>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xdea(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movaps 0xdd6(%rip),%xmm2
pand   %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movaps 0xdb9(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdaa(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zabs>:
sub    $0x18,%rsp
movdqu (%rdi),%xmm1
movdqa 0xee0(%rip),%xmm0
pand   %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm3
ucomisd %xmm3,%xmm0
jbe    1145 <zabs+0x35>
divsd  %xmm0,%xmm3
mulsd  %xmm3,%xmm3
addsd  0xed1(%rip),%xmm3
movaps %xmm0,(%rsp)
jmp    1177 <zabs+0x67>
punpckhqdq %xmm1,%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    115a <zabs+0x4a>
jp     115a <zabs+0x4a>
add    $0x18,%rsp
ret
movdqa %xmm3,%xmm1
divsd  %xmm3,%xmm0
mulsd  %xmm0,%xmm0
addsd  0xea2(%rip),%xmm0
movapd %xmm0,%xmm3
movdqa %xmm1,(%rsp)
cvttsd2si %xmm3,%edi
call   1030 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @zabs(double* nocapture %0) {
%2 = bitcast double* %0 to <2 x double>*
%3 = load <2 x double>, <2 x double>* %2
%4 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %3)
%5 = extractelement <2 x double> %4, i64 0
%6 = extractelement <2 x double> %4, i64 1
%7 = fcmp ogt double %5, %6
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = fdiv double %6, %5
%10 = tail call double @llvm.fmuladd.f64(double %9, double %9, double 1.000000e+00)
br label %17
11: ; preds = %1
%12 = extractelement <2 x double> %3, i64 1
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = fdiv double %5, %6
%16 = tail call double @llvm.fmuladd.f64(double %15, double %15, double 1.000000e+00)
br label %17
17: ; preds = %8, %14
%18 = phi double [ %16, %14 ], [ %10, %8 ]
%19 = phi double [ %6, %14 ], [ %5, %8 ]
%20 = fptosi double %18 to i32
%21 = tail call double @sqrt(i32 %20)
%22 = fmul double %19, %21
br label %23
23: ; preds = %17, %11
%24 = phi double [ %5, %11 ], [ %22, %17 ]
ret double %24
}