// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
// RUN: %clang_cc1 -std=c2y -O0 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
// This tests the codegen for the same test cases as in n3460.c.

// CHECK-LABEL: define dso_local void @test(
// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
// CHECK-NEXT:  [[ENTRY:.*]]:
// CHECK-NEXT:    [[A:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[B:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[C:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[D:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[E:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[F:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[G:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[H:%.*]] = alloca { double, double }, align 8
// CHECK-NEXT:    [[A_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 0
// CHECK-NEXT:    [[A_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 1
// CHECK-NEXT:    store double 0.000000e+00, ptr [[A_REALP]], align 8
// CHECK-NEXT:    store double 0x7FF0000000000000, ptr [[A_IMAGP]], align 8
// CHECK-NEXT:    [[B_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 0
// CHECK-NEXT:    [[B_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 1
// CHECK-NEXT:    store double -0.000000e+00, ptr [[B_REALP]], align 8
// CHECK-NEXT:    store double -0.000000e+00, ptr [[B_IMAGP]], align 8
// CHECK-NEXT:    [[C_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[C]], i32 0, i32 0
// CHECK-NEXT:    [[C_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[C]], i32 0, i32 1
// CHECK-NEXT:    store double 0.000000e+00, ptr [[C_REALP]], align 8
// CHECK-NEXT:    store double 0x7FF0000000000000, ptr [[C_IMAGP]], align 8
// CHECK-NEXT:    [[D_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[D]], i32 0, i32 0
// CHECK-NEXT:    [[D_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[D]], i32 0, i32 1
// CHECK-NEXT:    store double 4.000000e+00, ptr [[D_REALP]], align 8
// CHECK-NEXT:    store double 6.000000e+00, ptr [[D_IMAGP]], align 8
// CHECK-NEXT:    [[E_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[E]], i32 0, i32 0
// CHECK-NEXT:    [[E_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[E]], i32 0, i32 1
// CHECK-NEXT:    store double 1.000000e+00, ptr [[E_REALP]], align 8
// CHECK-NEXT:    store double 2.000000e+00, ptr [[E_IMAGP]], align 8
// CHECK-NEXT:    br i1 false, label %[[COMPLEX_MUL_IMAG_NAN:.*]], label %[[COMPLEX_MUL_CONT:.*]], !prof [[PROF2:![0-9]+]]
// CHECK:       [[COMPLEX_MUL_IMAG_NAN]]:
// CHECK-NEXT:    br i1 false, label %[[COMPLEX_MUL_LIBCALL:.*]], label %[[COMPLEX_MUL_CONT]], !prof [[PROF2]]
// CHECK:       [[COMPLEX_MUL_LIBCALL]]:
// CHECK-NEXT:    [[CALL:%.*]] = call { double, double } @__muldc3(double noundef 2.000000e+00, double noundef 3.000000e+00, double noundef 4.000000e+00, double noundef 5.000000e+00) #[[ATTR1:[0-9]+]]
// CHECK-NEXT:    [[TMP0:%.*]] = extractvalue { double, double } [[CALL]], 0
// CHECK-NEXT:    [[TMP1:%.*]] = extractvalue { double, double } [[CALL]], 1
// CHECK-NEXT:    br label %[[COMPLEX_MUL_CONT]]
// CHECK:       [[COMPLEX_MUL_CONT]]:
// CHECK-NEXT:    [[REAL_MUL_PHI:%.*]] = phi double [ -7.000000e+00, %[[ENTRY]] ], [ -7.000000e+00, %[[COMPLEX_MUL_IMAG_NAN]] ], [ [[TMP0]], %[[COMPLEX_MUL_LIBCALL]] ]
// CHECK-NEXT:    [[IMAG_MUL_PHI:%.*]] = phi double [ 2.200000e+01, %[[ENTRY]] ], [ 2.200000e+01, %[[COMPLEX_MUL_IMAG_NAN]] ], [ [[TMP1]], %[[COMPLEX_MUL_LIBCALL]] ]
// CHECK-NEXT:    [[F_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[F]], i32 0, i32 0
// CHECK-NEXT:    [[F_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[F]], i32 0, i32 1
// CHECK-NEXT:    store double [[REAL_MUL_PHI]], ptr [[F_REALP]], align 8
// CHECK-NEXT:    store double [[IMAG_MUL_PHI]], ptr [[F_IMAGP]], align 8
// CHECK-NEXT:    [[CALL1:%.*]] = call { double, double } @__divdc3(double noundef 2.000000e+00, double noundef 3.000000e+00, double noundef 4.000000e+00, double noundef 5.000000e+00) #[[ATTR1]]
// CHECK-NEXT:    [[TMP2:%.*]] = extractvalue { double, double } [[CALL1]], 0
// CHECK-NEXT:    [[TMP3:%.*]] = extractvalue { double, double } [[CALL1]], 1
// CHECK-NEXT:    [[G_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[G]], i32 0, i32 0
// CHECK-NEXT:    [[G_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[G]], i32 0, i32 1
// CHECK-NEXT:    store double [[TMP2]], ptr [[G_REALP]], align 8
// CHECK-NEXT:    store double [[TMP3]], ptr [[G_IMAGP]], align 8
// CHECK-NEXT:    [[CALL2:%.*]] = call { double, double } @__divdc3(double noundef 2.000000e+00, double noundef 0.000000e+00, double noundef 2.000000e+00, double noundef 4.000000e+00) #[[ATTR1]]
// CHECK-NEXT:    [[TMP4:%.*]] = extractvalue { double, double } [[CALL2]], 0
// CHECK-NEXT:    [[TMP5:%.*]] = extractvalue { double, double } [[CALL2]], 1
// CHECK-NEXT:    [[H_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[H]], i32 0, i32 0
// CHECK-NEXT:    [[H_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[H]], i32 0, i32 1
// CHECK-NEXT:    store double [[TMP4]], ptr [[H_REALP]], align 8
// CHECK-NEXT:    store double [[TMP5]], ptr [[H_IMAGP]], align 8
// CHECK-NEXT:    ret void
//
void test() {
  _Complex double a  = __builtin_complex(0.0, __builtin_inf()) * 2.0;
  _Complex double b = __builtin_complex(0.0, 1.0) * -0.0;
  _Complex double c = __builtin_complex(0.0, __builtin_inf()) / 2.0;
  _Complex double d = __builtin_complex(2.0, 3.0) * 2.0;
  _Complex double e = __builtin_complex(2.0, 4.0) / 2.0;
  _Complex double f = __builtin_complex(2.0, 3.0) * __builtin_complex(4.0, 5.0);
  _Complex double g = __builtin_complex(2.0, 3.0) / __builtin_complex(4.0, 5.0);
  _Complex double h = 2.0 / __builtin_complex(2.0, 4.0);
}

//.
// CHECK: [[PROF2]] = !{!"branch_weights", i32 1, i32 1048575}
//.
