#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 */
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int get_CPU_info() {
  FILE *fp;
  char buffer[1024];
  char hardware[1024];
  if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
    return -1;
  while (!feof(fp)) {
    fgets(buffer, sizeof(buffer), fp);
    sscanf(buffer, "Hardware	: %s", hardware);
    if (strcmp(hardware, "BCM2709") == 0) {
      return 2;
    }
  }
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<get_CPU_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1198 <get_CPU_info+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <get_CPU_info+0xc8>
jmp    119d <get_CPU_info+0x3d>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11bb <get_CPU_info+0x5b>
jmp    1218 <get_CPU_info+0xb8>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe2b(%rip),%rsi
call   1070 <sscanf@plt>
lea    -0x810(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1213 <get_CPU_info+0xb3>
movl   $0x2,-0x4(%rbp)
jmp    1228 <get_CPU_info+0xc8>
jmp    119d <get_CPU_info+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_CPU_info>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x800,%rsp
lea    0xe89(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f1 <get_CPU_info+0x91>
mov    %rax,%rbx
lea    0x400(%rsp),%r14
lea    0xe76(%rip),%r15
mov    %rsp,%r12
lea    0xe7a(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11f8 <get_CPU_info+0x98>
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <sscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11b0 <get_CPU_info+0x50>
mov    $0x2,%eax
jmp    1205 <get_CPU_info+0xa5>
mov    $0xffffffff,%eax
jmp    1205 <get_CPU_info+0xa5>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"Hardware\09: %s\00"
@.str.3 = [8 x i8] c"BCM2709\00"
define i32 @get_CPU_info() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %29
8: ; preds = %0
br label %9
9: ; preds = %25, %8
%10 = load i32*, i32** %2
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%16 = load i32*, i32** %2
%17 = call i32 @fgets(i8* %15, i32 1024, i32* %16)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %14
store i32 2, i32* %1
br label %29
25: ; preds = %14
br label %9
26: ; preds = %9
%27 = load i32*, i32** %2
%28 = call i32 @fclose(i32* %27)
store i32 1, i32* %1
br label %29
29: ; preds = %26, %24, %7
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"Hardware\09: %s\00"
@.str.3 = [8 x i8] c"BCM2709\00"
define i32 @get_CPU_info() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %17, label %7
7: ; preds = %0, %10
%8 = call i32 @feof(i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = call i32 @fgets(i8* %3, i32 1024, i32* %5)
%12 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%13 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %7
15: ; preds = %7
%16 = call i32 @fclose(i32* %5)
br label %17
17: ; preds = %10, %0, %15
%18 = phi i32 [ 1, %15 ], [ -1, %0 ], [ 2, %10 ]
ret i32 %18
}