#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__ check_cpuid_1_ecx(int);
int /*<<< orphan*/ printf(char *);
int report_summary();
int /*<<< orphan*/ setup_idt();
int /*<<< orphan*/ test_no_xsave();
int /*<<< orphan*/ test_xsave();
int main(void) {
  setup_idt();
  if (check_cpuid_1_ecx((1 << 26))) {
    printf("CPU has XSAVE feature\n");
    test_xsave();
  } else {
    printf("CPU don't has XSAVE feature\n");
    test_no_xsave();
  }
  return report_summary();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <setup_idt@plt>
mov    $0x4000000,%edi
call   1050 <check_cpuid_1_ecx@plt>
cmp    $0x0,%rax
je     11a2 <main+0x42>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <test_xsave@plt>
jmp    11b5 <main+0x55>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <test_no_xsave@plt>
mov    $0x0,%al
call   1070 <report_summary@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <setup_idt@plt>
mov    $0x4000000,%edi
call   1050 <check_cpuid_1_ecx@plt>
test   %rax,%rax
je     118c <main+0x2c>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <test_xsave@plt>
jmp    119f <main+0x3f>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <test_no_xsave@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <report_summary@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"CPU has XSAVE feature\0A\00"
@.str.1 = [29 x i8] c"CPU don't has XSAVE feature\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @setup_idt()
%3 = call i64 @check_cpuid_1_ecx(i32 67108864)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @test_xsave()
br label %11
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @test_no_xsave()
br label %11
11: ; preds = %8, %5
%12 = call i32 (...) @report_summary()
ret i32 %12
}

LLVM IR (-O2):
@str = [28 x i8] c"CPU don't has XSAVE feature\00"
@str.2 = [22 x i8] c"CPU has XSAVE feature\00"
define i32 @main() {
%1 = tail call i32 (...) @setup_idt()
%2 = tail call i64 @check_cpuid_1_ecx(i32 67108864)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 (...) @test_xsave()
br label %10
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (...) @test_no_xsave()
br label %10
10: ; preds = %7, %4
%11 = tail call i32 (...) @report_summary()
ret i32 %11
}