#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 */
int parse_proc_cpuinfo(int, char const *);
int check_cpu_feature(const char *feature) {
  int bufsize = 1024;
  int result;
  while ((result = parse_proc_cpuinfo(bufsize, feature)) == -1) {
    bufsize *= 2;
    if (bufsize > (1024 * 1024))
      return 0;
  }
  return result;
}


x86 assembly (clang, -O0):
<check_cpu_feature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x400,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <parse_proc_cpuinfo@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1162 <check_cpu_feature+0x52>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x100000,-0x14(%rbp)
jle    115d <check_cpu_feature+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    1168 <check_cpu_feature+0x58>
jmp    1123 <check_cpu_feature+0x13>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_cpu_feature>:
push   %rbx
mov    %rdi,%rbx
mov    $0x400,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
je     1128 <check_cpu_feature+0x18>
pop    %rbx
ret
mov    $0x800,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x1000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x2000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x4000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x8000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x10000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x20000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x40000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x80000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
cmp    $0xffffffff,%eax
jne    1126 <check_cpu_feature+0x16>
mov    $0x100000,%edi
mov    %rbx,%rsi
call   1030 <parse_proc_cpuinfo@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
cmovne %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @check_cpu_feature(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 1024, i32* %4
br label %6
6: ; preds = %17, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @parse_proc_cpuinfo(i32 %7, i8* %8)
store i32 %9, i32* %5
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 2
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1048576
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 0, i32* %2
br label %20
17: ; preds = %11
br label %6
18: ; preds = %6
%19 = load i32, i32* %5
store i32 %19, i32* %2
br label %20
20: ; preds = %18, %16
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @check_cpu_feature(i8* %0) {
%2 = tail call i32 @parse_proc_cpuinfo(i32 1024, i8* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %35
4: ; preds = %1
%5 = tail call i32 @parse_proc_cpuinfo(i32 2048, i8* %0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %35
7: ; preds = %4
%8 = tail call i32 @parse_proc_cpuinfo(i32 4096, i8* %0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = tail call i32 @parse_proc_cpuinfo(i32 8192, i8* %0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %35
13: ; preds = %10
%14 = tail call i32 @parse_proc_cpuinfo(i32 16384, i8* %0)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %35
16: ; preds = %13
%17 = tail call i32 @parse_proc_cpuinfo(i32 32768, i8* %0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = tail call i32 @parse_proc_cpuinfo(i32 65536, i8* %0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = tail call i32 @parse_proc_cpuinfo(i32 131072, i8* %0)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = tail call i32 @parse_proc_cpuinfo(i32 262144, i8* %0)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = tail call i32 @parse_proc_cpuinfo(i32 524288, i8* %0)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = tail call i32 @parse_proc_cpuinfo(i32 1048576, i8* %0)
%33 = icmp eq i32 %32, -1
%34 = select i1 %33, i32 0, i32 %32
br label %35
35: ; preds = %31, %28, %25, %22, %19, %16, %13, %10, %7, %4, %1
%36 = phi i32 [ %2, %1 ], [ %5, %4 ], [ %8, %7 ], [ %11, %10 ], [ %14, %13 ], [ %17, %16 ], [ %20, %19 ], [ %23, %22 ], [ %26, %25 ], [ %29, %28 ], [ %34, %31 ]
ret i32 %36
}