#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 */
scalar_t__ isnan(float);
void switch_nan_(float *bad, float *missing, float *bad_val) {
  if (isnan(*bad) || isnan(*missing)) {
    if (isnan(*bad)) {
      *missing = *bad;
      *bad = *bad_val;
    }
  }
}


x86 assembly (clang, -O0):
<switch_nan_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
jne    1152 <switch_nan_+0x42>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     118e <switch_nan_+0x7e>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1189 <switch_nan_+0x79>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
jmp    118e <switch_nan_+0x7e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<switch_nan_>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  (%rdi),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
jne    113b <switch_nan_+0x2b>
movss  (%r15),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
je     115b <switch_nan_+0x4b>
movss  (%rbx),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
je     115b <switch_nan_+0x4b>
movss  (%rbx),%xmm0
movss  %xmm0,(%r15)
movss  (%r14),%xmm0
movss  %xmm0,(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @switch_nan_(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%7 = load float*, float** %4
%8 = load float, float* %7
%9 = call i64 @isnan(float %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %3
%12 = load float*, float** %5
%13 = load float, float* %12
%14 = call i64 @isnan(float %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %11, %3
%17 = load float*, float** %4
%18 = load float, float* %17
%19 = call i64 @isnan(float %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load float*, float** %4
%23 = load float, float* %22
%24 = load float*, float** %5
store float %23, float* %24
%25 = load float*, float** %6
%26 = load float, float* %25
%27 = load float*, float** %4
store float %26, float* %27
br label %28
28: ; preds = %21, %16
br label %29
29: ; preds = %28, %11
ret void
}

LLVM IR (-O2):
define void @switch_nan_(float* nocapture %0, float* nocapture %1, float* nocapture %2) {
%4 = load float, float* %0
%5 = tail call i64 @isnan(float %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load float, float* %1
%9 = tail call i64 @isnan(float %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %7, %3
%12 = load float, float* %0
%13 = tail call i64 @isnan(float %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load float, float* %0
store float %16, float* %1
%17 = load float, float* %2
store float %17, float* %0
br label %18
18: ; preds = %11, %15, %7
ret void
}