#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 /*<<< orphan*/ abort();
double fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double, double, double);
scalar_t__ isinf(double);
double pow(double, int);
int /*<<< orphan*/ stderr;
double p_norm(double x, double y, double p) {
  if (isinf(x) || isinf(y) || p == 0) {
    fprintf(stderr, "Illegal arguments in p_norm: x = %f, y = %f, p = %f\n", x,
            y, p);
    abort();
  }
  double t1 = fabs(x);
  double t2 = fabs(y);
  return pow(pow(t1, p) + pow(t2, p), 1 / p);
}


x86 assembly (clang, -O0):
<p_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1060 <isinf@plt>
cmp    $0x0,%rax
jne    1197 <p_norm+0x57>
movsd  -0x10(%rbp),%xmm0
call   1060 <isinf@plt>
cmp    $0x0,%rax
jne    1197 <p_norm+0x57>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c2 <p_norm+0x82>
jp     11c2 <p_norm+0x82>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
movsd  -0x8(%rbp),%xmm0
movaps 0xe42(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe2d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
cvttsd2si -0x18(%rbp),%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
cvttsd2si -0x18(%rbp),%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xddd(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <pow@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p_norm>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,0x10(%rsp)
movapd %xmm0,0x20(%rsp)
call   1060 <isinf@plt>
test   %rax,%rax
jne    11e5 <p_norm+0xa5>
movapd 0x10(%rsp),%xmm0
call   1060 <isinf@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1182 <p_norm+0x42>
jnp    11e5 <p_norm+0xa5>
test   %rax,%rax
jne    11e5 <p_norm+0xa5>
movaps 0xe72(%rip),%xmm1
movaps 0x20(%rsp),%xmm0
andps  %xmm1,%xmm0
movaps 0x10(%rsp),%xmm2
andps  %xmm1,%xmm2
movaps %xmm2,0x10(%rsp)
cvttsd2si 0x8(%rsp),%ebx
mov    %ebx,%edi
call   1050 <pow@plt>
movsd  %xmm0,0x20(%rsp)
movapd 0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1050 <pow@plt>
addsd  0x20(%rsp),%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%edi
add    $0x30,%rsp
pop    %rbx
jmp    1050 <pow@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
movaps 0x20(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"Illegal arguments in p_norm: x = %f, y = %f, p = %f\0A\00"
define double @p_norm(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %4
%10 = call i64 @isinf(double %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %3
%13 = load double, double* %5
%14 = call i64 @isinf(double %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load double, double* %6
%18 = fcmp oeq double %17, 0.000000e+00
br i1 %18, label %19, label %26
19: ; preds = %16, %12, %3
%20 = load i32, i32* @stderr
%21 = load double, double* %4
%22 = load double, double* %5
%23 = load double, double* %6
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %21, double %22, double %23)
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %16
%27 = load double, double* %4
%28 = call double @llvm.fabs.f64(double %27)
store double %28, double* %7
%29 = load double, double* %5
%30 = call double @llvm.fabs.f64(double %29)
store double %30, double* %8
%31 = load double, double* %7
%32 = load double, double* %6
%33 = fptosi double %32 to i32
%34 = call double @pow(double %31, i32 %33)
%35 = load double, double* %8
%36 = load double, double* %6
%37 = fptosi double %36 to i32
%38 = call double @pow(double %35, i32 %37)
%39 = fadd double %34, %38
%40 = load double, double* %6
%41 = fdiv double 1.000000e+00, %40
%42 = fptosi double %41 to i32
%43 = call double @pow(double %39, i32 %42)
ret double %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"Illegal arguments in p_norm: x = %f, y = %f, p = %f\0A\00"
define double @p_norm(double %0, double %1, double %2) {
%4 = tail call i64 @isinf(double %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i64 @isinf(double %1)
%8 = icmp ne i64 %7, 0
%9 = fcmp oeq double %2, 0.000000e+00
%10 = or i1 %9, %8
br i1 %10, label %11, label %15
11: ; preds = %6, %3
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %2)
%14 = tail call i32 (...) @abort()
unreachable
15: ; preds = %6
%16 = tail call double @llvm.fabs.f64(double %0)
%17 = tail call double @llvm.fabs.f64(double %1)
%18 = fptosi double %2 to i32
%19 = tail call double @pow(double %16, i32 %18)
%20 = tail call double @pow(double %17, i32 %18)
%21 = fadd double %19, %20
%22 = fdiv double 1.000000e+00, %2
%23 = fptosi double %22 to i32
%24 = tail call double @pow(double %21, i32 %23)
ret double %24
}