#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*/ FILE;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void get_cpuinfo_arm(char *cpuinfo) {
  FILE *fff;
  char *result;
  char temp_string[BUFSIZ];
  int architecture, implementer, variant, part, revision;
  fff = fopen("/proc/cpuinfo", "r");
  if (fff == NULL) {
    strcpy(cpuinfo, "UNKNOWN");
    return;
  }
  while (1) {
    result = fgets(temp_string, BUFSIZ, fff);
    if (result == NULL)
      break;
    if (!strncmp(temp_string, "CPU implementer", 15)) {
      sscanf(temp_string, "%*s%*s%*s %x", &implementer);
    }
    if (!strncmp(temp_string, "CPU architecture", 16)) {
      sscanf(temp_string, "%*s%*s %x", &architecture);
    }
    if (!strncmp(temp_string, "CPU variant", 11)) {
      sscanf(temp_string, "%*s%*s%*s %x", &variant);
    }
    if (!strncmp(temp_string, "CPU revision", 12)) {
      sscanf(temp_string, "%*s%*s%*s %x", &revision);
    }
    if (!strncmp(temp_string, "CPU part", 8)) {
      sscanf(temp_string, "%*s%*s%*s %x", &part);
    }
  }
  fclose(fff);
  sprintf(cpuinfo, "ARMv%d %x %x %x %x\n", architecture, implementer, variant,
          part, revision);
}


x86 assembly (clang, -O0):
<get_cpuinfo_arm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    0xe51(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e6 <get_cpuinfo_arm+0x76>
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x40(%rbp)
jmp    1355 <get_cpuinfo_arm+0x1e5>
jmp    11eb <get_cpuinfo_arm+0x7b>
jmp    11f0 <get_cpuinfo_arm+0x80>
mov    -0x48(%rbp),%rdi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1060 <fgets@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121a <get_cpuinfo_arm+0xaa>
jmp    1319 <get_cpuinfo_arm+0x1a9>
mov    -0x48(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    124c <get_cpuinfo_arm+0xdc>
mov    -0x48(%rbp),%rdi
lea    0xde3(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x48(%rbp),%rdi
lea    0xddc(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    127e <get_cpuinfo_arm+0x10e>
mov    -0x48(%rbp),%rdi
lea    0xdb4(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x48(%rbp),%rdi
lea    0xdbb(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12b0 <get_cpuinfo_arm+0x140>
mov    -0x48(%rbp),%rdi
lea    0xd7f(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x48(%rbp),%rdi
lea    0xd95(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12e2 <get_cpuinfo_arm+0x172>
mov    -0x48(%rbp),%rdi
lea    0xd4d(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x48(%rbp),%rdi
lea    0xd70(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1314 <get_cpuinfo_arm+0x1a4>
mov    -0x48(%rbp),%rdi
lea    0xd1b(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <sscanf@plt>
jmp    11eb <get_cpuinfo_arm+0x7b>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%eax
lea    0xd28(%rip),%rsi
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1090 <sprintf@plt>
add    $0x10,%rsp
movl   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cpuinfo_arm>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
mov    0x2e55(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe59(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1322 <get_cpuinfo_arm+0x1b2>
mov    %rax,%r15
mov    %r14,-0x48(%rbp)
mov    (%r12),%esi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12e5 <get_cpuinfo_arm+0x175>
lea    0xe44(%rip),%r13
lea    0xe67(%rip),%r14
lea    0xe6d(%rip),%r12
jmp    121d <get_cpuinfo_arm+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12e5 <get_cpuinfo_arm+0x175>
mov    %rbx,%rdi
lea    0xdef(%rip),%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1244 <get_cpuinfo_arm+0xd4>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    -0x38(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %rbx,%rdi
lea    0xde5(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    126f <get_cpuinfo_arm+0xff>
mov    %rbx,%rdi
lea    0xdc3(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %rbx,%rdi
lea    0xdcb(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1296 <get_cpuinfo_arm+0x126>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    -0x34(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12b9 <get_cpuinfo_arm+0x149>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1200 <get_cpuinfo_arm+0x90>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    -0x30(%rbp),%rdx
call   1070 <sscanf@plt>
jmp    1200 <get_cpuinfo_arm+0x90>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%eax
sub    $0x8,%rsp
lea    0xd5d(%rip),%rsi
mov    -0x48(%rbp),%rdi
push   %rax
call   1090 <sprintf@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce5(%rip),%rsi
mov    %r14,%rdi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcpy@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"UNKNOWN\00"
@.str.3 = [16 x i8] c"CPU implementer\00"
@.str.4 = [13 x i8] c"%*s%*s%*s %x\00"
@.str.5 = [17 x i8] c"CPU architecture\00"
@.str.6 = [10 x i8] c"%*s%*s %x\00"
@.str.7 = [12 x i8] c"CPU variant\00"
@.str.8 = [13 x i8] c"CPU revision\00"
@.str.9 = [9 x i8] c"CPU part\00"
@.str.10 = [20 x i8] c"ARMv%d %x %x %x %x\0A\00"
define void @get_cpuinfo_arm(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %2
%13 = load i32, i32* @BUFSIZ
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %5
%16 = alloca i8, i64 %14
store i64 %14, i64* %6
%17 = 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* %17, i32** %3
%18 = load i32*, i32** %3
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %1
%21 = load i8*, i8** %2
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %12
br label %68
23: ; preds = %1
br label %24
24: ; preds = %57, %23
br label %25
25: ; preds = %24
%26 = load i32, i32* @BUFSIZ
%27 = load i32*, i32** %3
%28 = call i8* @fgets(i8* %16, i32 %26, i32* %27)
store i8* %28, i8** %4
%29 = load i8*, i8** %4
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %25
br label %58
32: ; preds = %25
%33 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 15)
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %8)
br label %37
37: ; preds = %35, %32
%38 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 16)
%39 = icmp ne i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32* %7)
br label %42
42: ; preds = %40, %37
%43 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 11)
%44 = icmp ne i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %9)
br label %47
47: ; preds = %45, %42
%48 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 12)
%49 = icmp ne i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %11)
br label %52
52: ; preds = %50, %47
%53 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 8)
%54 = icmp ne i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %52
%56 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %10)
br label %57
57: ; preds = %55, %52
br label %24
58: ; preds = %31
%59 = load i32*, i32** %3
%60 = call i32 @fclose(i32* %59)
%61 = load i8*, i8** %2
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = load i32, i32* %9
%65 = load i32, i32* %10
%66 = load i32, i32* %11
%67 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %62, i32 %63, i32 %64, i32 %65, i32 %66)
store i32 0, i32* %12
br label %68
68: ; preds = %58, %20
%69 = load i8*, i8** %5
%70 = load i32, i32* %12
switch i32 %70, label %72 [
i32 0, label %71
i32 1, label %71
]
71: ; preds = %68, %68
ret void
72: ; preds = %68
unreachable
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"UNKNOWN\00"
@.str.3 = [16 x i8] c"CPU implementer\00"
@.str.4 = [13 x i8] c"%*s%*s%*s %x\00"
@.str.5 = [17 x i8] c"CPU architecture\00"
@.str.6 = [10 x i8] c"%*s%*s %x\00"
@.str.7 = [12 x i8] c"CPU variant\00"
@.str.8 = [13 x i8] c"CPU revision\00"
@.str.9 = [9 x i8] c"CPU part\00"
@.str.10 = [20 x i8] c"ARMv%d %x %x %x %x\0A\00"
define void @get_cpuinfo_arm(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = 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))
%16 = icmp eq i32* %15, null
br i1 %16, label %21, label %17
17: ; preds = %1
%18 = load i32, i32* @BUFSIZ
%19 = call i8* @fgets(i8* %9, i32 %18, i32* %15)
%20 = icmp eq i8* %19, null
br i1 %20, label %52, label %23
21: ; preds = %1
%22 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %60
23: ; preds = %17, %48
%24 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 15)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %3)
br label %28
28: ; preds = %26, %23
%29 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 16)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32* %2)
br label %33
33: ; preds = %31, %28
%34 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 11)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %38
38: ; preds = %36, %33
%39 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 12)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %6)
br label %43
43: ; preds = %41, %38
%44 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 8)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32* %5)
br label %48
48: ; preds = %46, %43
%49 = load i32, i32* @BUFSIZ
%50 = call i8* @fgets(i8* %9, i32 %49, i32* %15)
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %23
52: ; preds = %48, %17
%53 = call i32 @fclose(i32* %15)
%54 = load i32, i32* %2
%55 = load i32, i32* %3
%56 = load i32, i32* %4
%57 = load i32, i32* %5
%58 = load i32, i32* %6
%59 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %54, i32 %55, i32 %56, i32 %57, i32 %58)
br label %60
60: ; preds = %52, %21
ret void
}