// Test instrumentation of general constructs in C.
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOGEN %s
// RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v5 | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v3 | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
// Also check compatibility with older profiles.
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v1 | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
// PGOGEN: @[[SLC:__profc_simple_loops]] = private global [4 x i64] zeroinitializer
// PGOGEN: @[[IFC:__profc_conditionals]] = private global [13 x i64] zeroinitializer
// PGOGEN: @[[EEC:__profc_early_exits]] = private global [9 x i64] zeroinitializer
// PGOGEN: @[[JMC:__profc_jumps]] = private global [22 x i64] zeroinitializer
// PGOGEN: @[[SWC:__profc_switches]] = private global [19 x i64] zeroinitializer
// PGOGEN: @[[BSC:__profc_big_switch]] = private global [17 x i64] zeroinitializer
// PGOGEN: @[[BOC:__profc_boolean_operators]] = private global [14 x i64] zeroinitializer
// PGOGEN: @[[BLC:__profc_boolop_loops]] = private global [13 x i64] zeroinitializer
// PGOGEN: @[[COC:__profc_conditional_operator]] = private global [3 x i64] zeroinitializer
// PGOGEN: @[[DFC:__profc_do_fallthrough]] = private global [4 x i64] zeroinitializer
// PGOGEN: @[[MAC:__profc_main]] = private global [1 x i64] zeroinitializer
// PGOGEN: @[[STC:__profc_c_general.c_static_func]] = private global [2 x i64] zeroinitializer
// PGOGEN-LABEL: @simple_loops()
// PGOUSE-LABEL: @simple_loops()
// PGOGEN: store {{.*}} @[[SLC]], i32 0, i32 0
void
// PGOGEN-LABEL: @conditionals()
// PGOUSE-LABEL: @conditionals()
// PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 0
void
// PGOGEN-LABEL: @early_exits()
// PGOUSE-LABEL: @early_exits()
// PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 0
void
// PGOGEN-LABEL: @jumps()
// PGOUSE-LABEL: @jumps()
// PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 0
void
// PGOGEN-LABEL: @switches()
// PGOUSE-LABEL: @switches()
// PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 0
void
// PGOGEN-LABEL: @big_switch()
// PGOUSE-LABEL: @big_switch()
// PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 0
void
// PGOGEN-LABEL: @boolean_operators()
// PGOUSE-LABEL: @boolean_operators()
// PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 0
void
// PGOGEN-LABEL: @boolop_loops()
// PGOUSE-LABEL: @boolop_loops()
// PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 0
void
// PGOGEN-LABEL: @conditional_operator()
// PGOUSE-LABEL: @conditional_operator()
// PGOGEN: store {{.*}} @[[COC]], i32 0, i32 0
void
// PGOGEN-LABEL: @do_fallthrough()
// PGOUSE-LABEL: @do_fallthrough()
// PGOGEN: store {{.*}} @[[DFC]], i32 0, i32 0
void
// PGOGEN-LABEL: @static_func()
// PGOUSE-LABEL: @static_func()
// PGOGEN: store {{.*}} @[[STC]], i32 0, i32 0
static void
// PGOUSE-DAG: ![[SL1]] = !{!"branch_weights", i32 101, i32 2}
// PGOUSE-DAG: ![[SL2]] = !{!"branch_weights", i32 101, i32 2}
// PGOUSE-DAG: ![[SL3]] = !{!"branch_weights", i32 76, i32 2}
// PGOUSE-DAG: ![[EE1]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[EE2]] = !{!"branch_weights", i32 52, i32 1}
// PGOUSE-DAG: ![[EE3]] = !{!"branch_weights", i32 2, i32 51}
// PGOUSE-DAG: ![[EE4]] = !{!"branch_weights", i32 26, i32 26}
// PGOUSE-DAG: ![[EE5]] = !{!"branch_weights", i32 2, i32 1}
// PGOUSE-DAG: ![[EE6]] = !{!"branch_weights", i32 2, i32 26}
// PGOUSE-DAG: ![[EE7]] = !{!"branch_weights", i32 26, i32 1}
// PGOUSE-DAG: ![[IF1]] = !{!"branch_weights", i32 101, i32 2}
// PGOUSE-DAG: ![[IF2]] = !{!"branch_weights", i32 51, i32 51}
// PGOUSE-DAG: ![[IF3]] = !{!"branch_weights", i32 51, i32 1}
// PGOUSE-DAG: ![[IF4]] = !{!"branch_weights", i32 34, i32 18}
// PGOUSE-DAG: ![[IF5]] = !{!"branch_weights", i32 34, i32 1}
// PGOUSE-DAG: ![[IF6]] = !{!"branch_weights", i32 17, i32 2}
// PGOUSE-DAG: ![[IF7]] = !{!"branch_weights", i32 100, i32 2}
// PGOUSE-DAG: ![[IF8]] = !{!"branch_weights", i32 100, i32 2}
// PGOUSE-DAG: ![[JM1]] = !{!"branch_weights", i32 2, i32 1}
// PGOUSE-DAG: ![[JM2]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[JM3]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[JM4]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[JM5]] = !{!"branch_weights", i32 3, i32 2}
// PGOUSE-DAG: ![[JM6]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[JM7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2}
// PGOUSE-DAG: ![[JM8]] = !{!"branch_weights", i32 11, i32 2}
// PGOUSE-DAG: ![[JM9]] = !{!"branch_weights", i32 10, i32 2}
// PGOUSE-DAG: ![[SW1]] = !{!"branch_weights", i32 16, i32 1}
// PGOUSE-DAG: ![[SW2]] = !{!"branch_weights", i32 6, i32 2, i32 3, i32 4, i32 5}
// PGOUSE-DAG: ![[SW3]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[SW4]] = !{!"branch_weights", i32 3, i32 2}
// PGOUSE-DAG: ![[SW5]] = !{!"branch_weights", i32 4, i32 1}
// PGOUSE-DAG: ![[SW6]] = !{!"branch_weights", i32 5, i32 1}
// PGOUSE-DAG: ![[SW7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2, i32 2}
// PGOUSE-DAG: ![[SW8]] = !{!"branch_weights", i32 5, i32 1}
// PGOUSE-DAG: ![[SW9]] = !{!"branch_weights", i32 2, i32 5}
// PGOUSE-DAG: ![[BS1]] = !{!"branch_weights", i32 33, i32 2}
// PGOUSE-DAG: ![[BS2]] = !{!"branch_weights", i32 29, i32 2, i32 2, i32 2, i32 2, i32 1}
// PGOUSE-DAG: ![[BS3]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[BS4]] = !{!"branch_weights", i32 2, i32 2}
// PGOUSE-DAG: ![[BS5]] = !{!"branch_weights", i32 12, i32 1}
// PGOUSE-DAG: ![[BS6]] = !{!"branch_weights", i32 12, i32 3}
// PGOUSE-DAG: ![[BS7]] = !{!"branch_weights", i32 2, i32 1}
// PGOUSE-DAG: ![[BS8]] = !{!"branch_weights", i32 16, i32 1}
// PGOUSE-DAG: ![[BS9]] = !{!"branch_weights", i32 16, i32 14}
// PGOUSE-DAG: ![[BS10]] = !{!"branch_weights", i32 2, i32 1}
// PGOUSE-DAG: ![[BS11]] = !{!"branch_weights", i32 3, i32 1}
// PGOUSE-DAG: ![[BO1]] = !{!"branch_weights", i32 101, i32 2}
// PGOUSE-DAG: ![[BO2]] = !{!"branch_weights", i32 67, i32 35}
// PGOUSE-DAG: ![[BO3]] = !{!"branch_weights", i32 67, i32 35}
// PGOUSE-DAG: ![[BO4]] = !{!"branch_weights", i32 67, i32 35}
// PGOUSE-DAG: ![[BO5]] = !{!"branch_weights", i32 18, i32 18}
// PGOUSE-DAG: ![[BO6]] = !{!"branch_weights", i32 51, i32 51}
// PGOUSE-DAG: ![[BO7]] = !{!"branch_weights", i32 34, i32 18}
// PGOUSE-DAG: ![[BL1]] = !{!"branch_weights", i32 52, i32 1}
// PGOUSE-DAG: ![[BL2]] = !{!"branch_weights", i32 51, i32 2}
// PGOUSE-DAG: ![[BL3]] = !{!"branch_weights", i32 26, i32 27}
// PGOUSE-DAG: ![[BL4]] = !{!"branch_weights", i32 51, i32 2}
// PGOUSE-DAG: ![[BL5]] = !{!"branch_weights", i32 52, i32 1}
// PGOUSE-DAG: ![[BL6]] = !{!"branch_weights", i32 51, i32 2}
// PGOUSE-DAG: ![[BL7]] = !{!"branch_weights", i32 26, i32 27}
// PGOUSE-DAG: ![[BL8]] = !{!"branch_weights", i32 51, i32 2}
// PGOUSE-DAG: ![[CO1]] = !{!"branch_weights", i32 1, i32 2}
// PGOUSE-DAG: ![[CO2]] = !{!"branch_weights", i32 2, i32 1}
// PGOUSE-DAG: ![[DF1]] = !{!"branch_weights", i32 11, i32 2}
// PGOUSE-DAG: ![[DF2]] = !{!"branch_weights", i32 3, i32 3}
// PGOUSE-DAG: ![[DF3]] = !{!"branch_weights", i32 9, i32 5}
// PGOUSE-DAG: ![[ST1]] = !{!"branch_weights", i32 11, i32 2}
int