#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 */
float __nvvm_add_rn_f(float, float);
int /*<<< orphan*/ __nvvm_bar0();
double __nvvm_fmax_d(double, double);
float __nvvm_fmax_f(float, float);
double __nvvm_fmin_d(double, double);
float __nvvm_fmin_f(float, float);
int /*<<< orphan*/ __nvvm_membar_cta();
int /*<<< orphan*/ __nvvm_membar_gl();
int /*<<< orphan*/ __nvvm_membar_sys();
double __nvvm_rcp_rn_d(double);
float __nvvm_rcp_rn_f(float);
double __nvvm_sqrt_rn_d(double);
float __nvvm_sqrt_rn_f(float);
__attribute__((device)) void nvvm_math(float f1, float f2, double d1,
                                       double d2) {
  float t1 = __nvvm_fmax_f(f1, f2);
  float t2 = __nvvm_fmin_f(f1, f2);
  float t3 = __nvvm_sqrt_rn_f(f1);
  float t4 = __nvvm_rcp_rn_f(f2);
  float t5 = __nvvm_add_rn_f(f1, f2);
  double td1 = __nvvm_fmax_d(d1, d2);
  double td2 = __nvvm_fmin_d(d1, d2);
  double td3 = __nvvm_sqrt_rn_d(d1);
  double td4 = __nvvm_rcp_rn_d(d2);
  __nvvm_membar_cta();
  __nvvm_membar_gl();
  __nvvm_membar_sys();
  __nvvm_bar0();
}


x86 assembly (clang, -O0):
<nvvm_math>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movsd  %xmm2,-0x10(%rbp)
movsd  %xmm3,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1070 <__nvvm_fmax_f@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <__nvvm_fmin_f@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
call   1050 <__nvvm_sqrt_rn_f@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
call   10e0 <__nvvm_rcp_rn_f@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1090 <__nvvm_add_rn_f@plt>
movss  %xmm0,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   10b0 <__nvvm_fmax_d@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <__nvvm_fmin_d@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <__nvvm_sqrt_rn_d@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   10d0 <__nvvm_rcp_rn_d@plt>
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1080 <__nvvm_membar_cta@plt>
mov    $0x0,%al
call   10a0 <__nvvm_membar_gl@plt>
mov    $0x0,%al
call   10c0 <__nvvm_membar_sys@plt>
mov    $0x0,%al
call   10f0 <__nvvm_bar0@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nvvm_math>:
sub    $0x18,%rsp
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
call   1070 <__nvvm_fmax_f@plt>
movss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
call   1030 <__nvvm_fmin_f@plt>
movss  (%rsp),%xmm0
call   1050 <__nvvm_sqrt_rn_f@plt>
movss  0x4(%rsp),%xmm0
call   10e0 <__nvvm_rcp_rn_f@plt>
movss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
call   1090 <__nvvm_add_rn_f@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   10b0 <__nvvm_fmax_d@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <__nvvm_fmin_d@plt>
movsd  0x8(%rsp),%xmm0
call   1060 <__nvvm_sqrt_rn_d@plt>
movsd  0x10(%rsp),%xmm0
call   10d0 <__nvvm_rcp_rn_d@plt>
xor    %eax,%eax
call   1080 <__nvvm_membar_cta@plt>
xor    %eax,%eax
call   10a0 <__nvvm_membar_gl@plt>
xor    %eax,%eax
call   10c0 <__nvvm_membar_sys@plt>
xor    %eax,%eax
add    $0x18,%rsp
jmp    10f0 <__nvvm_bar0@plt>

LLVM IR (-O0):
define void @nvvm_math(float %0, float %1, double %2, double %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca double
%8 = alloca double
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store float %0, float* %5
store float %1, float* %6
store double %2, double* %7
store double %3, double* %8
%18 = load float, float* %5
%19 = load float, float* %6
%20 = call float @__nvvm_fmax_f(float %18, float %19)
store float %20, float* %9
%21 = load float, float* %5
%22 = load float, float* %6
%23 = call float @__nvvm_fmin_f(float %21, float %22)
store float %23, float* %10
%24 = load float, float* %5
%25 = call float @__nvvm_sqrt_rn_f(float %24)
store float %25, float* %11
%26 = load float, float* %6
%27 = call float @__nvvm_rcp_rn_f(float %26)
store float %27, float* %12
%28 = load float, float* %5
%29 = load float, float* %6
%30 = call float @__nvvm_add_rn_f(float %28, float %29)
store float %30, float* %13
%31 = load double, double* %7
%32 = load double, double* %8
%33 = call double @__nvvm_fmax_d(double %31, double %32)
store double %33, double* %14
%34 = load double, double* %7
%35 = load double, double* %8
%36 = call double @__nvvm_fmin_d(double %34, double %35)
store double %36, double* %15
%37 = load double, double* %7
%38 = call double @__nvvm_sqrt_rn_d(double %37)
store double %38, double* %16
%39 = load double, double* %8
%40 = call double @__nvvm_rcp_rn_d(double %39)
store double %40, double* %17
%41 = call i32 (...) @__nvvm_membar_cta()
%42 = call i32 (...) @__nvvm_membar_gl()
%43 = call i32 (...) @__nvvm_membar_sys()
%44 = call i32 (...) @__nvvm_bar0()
ret void
}

LLVM IR (-O2):
define void @nvvm_math(float %0, float %1, double %2, double %3) {
%5 = tail call float @__nvvm_fmax_f(float %0, float %1)
%6 = tail call float @__nvvm_fmin_f(float %0, float %1)
%7 = tail call float @__nvvm_sqrt_rn_f(float %0)
%8 = tail call float @__nvvm_rcp_rn_f(float %1)
%9 = tail call float @__nvvm_add_rn_f(float %0, float %1)
%10 = tail call double @__nvvm_fmax_d(double %2, double %3)
%11 = tail call double @__nvvm_fmin_d(double %2, double %3)
%12 = tail call double @__nvvm_sqrt_rn_d(double %2)
%13 = tail call double @__nvvm_rcp_rn_d(double %3)
%14 = tail call i32 (...) @__nvvm_membar_cta()
%15 = tail call i32 (...) @__nvvm_membar_gl()
%16 = tail call i32 (...) @__nvvm_membar_sys()
%17 = tail call i32 (...) @__nvvm_bar0()
ret void
}