#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 /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ *fdgets(char *, int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int *strchr(unsigned char *, char);
int /*<<< orphan*/ strcpy(unsigned char *, unsigned char *);
int strlen(unsigned char *);
char *strstr(char *, char *);
int /*<<< orphan*/ uppercase(char *);
int getBogos(unsigned char *bogomips) {
  int cmdline = open("/proc/cpuinfo", O_RDONLY);
  char linebuf[4096];
  while (fdgets(linebuf, 4096, cmdline) != NULL) {
    uppercase(linebuf);
    if (strstr(linebuf, "BOGOMIPS") == linebuf) {
      unsigned char *pos = linebuf + 8;
      while (*pos == ' ' || *pos == '\t' || *pos == ':')
        pos++;
      while (pos[strlen(pos) - 1] == '\r' || pos[strlen(pos) - 1] == '\n')
        pos[strlen(pos) - 1] = 0;
      if (strchr(pos, '.') != NULL)
        *strchr(pos, '.') = 0x00;
      strcpy(bogomips, pos);
      close(cmdline);
      return 0;
    }
    memset(linebuf, 0, 4096);
  }
  close(cmdline);
  return 1;
}


x86 assembly (clang, -O0):
<getBogos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe51(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x1000,%esi
call   1070 <fdgets@plt>
cmp    $0x0,%rax
je     13bb <getBogos+0x22b>
lea    -0x1020(%rbp),%rdi
call   1090 <uppercase@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   10b0 <strstr@plt>
lea    -0x1020(%rbp),%rcx
cmp    %rcx,%rax
jne    13a3 <getBogos+0x213>
lea    -0x1020(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x1028(%rbp)
mov    -0x1028(%rbp),%rax
movzbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1029(%rbp)
je     1262 <getBogos+0xd2>
mov    -0x1028(%rbp),%rax
movzbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x1029(%rbp)
je     1262 <getBogos+0xd2>
mov    -0x1028(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x3a,%eax
sete   %al
mov    %al,-0x1029(%rbp)
mov    -0x1029(%rbp),%al
test   $0x1,%al
jne    1275 <getBogos+0xe5>
jmp    128c <getBogos+0xfc>
mov    -0x1028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1028(%rbp)
jmp    1216 <getBogos+0x86>
jmp    1291 <getBogos+0x101>
mov    -0x1028(%rbp),%rax
mov    %rax,-0x1038(%rbp)
mov    -0x1028(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1038(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x102a(%rbp)
je     1308 <getBogos+0x178>
mov    -0x1028(%rbp),%rax
mov    %rax,-0x1040(%rbp)
mov    -0x1028(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1040(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x102a(%rbp)
mov    -0x102a(%rbp),%al
test   $0x1,%al
jne    131b <getBogos+0x18b>
jmp    134d <getBogos+0x1bd>
mov    -0x1028(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1028(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1048(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1291 <getBogos+0x101>
mov    -0x1028(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     137f <getBogos+0x1ef>
mov    -0x1028(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x1028(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    13ca <getBogos+0x23a>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
jmp    11b7 <getBogos+0x27>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBogos>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rdi,%r14
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
lea    0xe4e(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%r12d
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    %eax,%edx
call   1080 <fdgets@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     12d4 <getBogos+0x144>
mov    %rsp,%rbx
lea    0xe2c(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   10a0 <uppercase@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     123b <getBogos+0xab>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r12d,%edx
call   1080 <fdgets@plt>
test   %rax,%rax
jne    11f0 <getBogos+0x60>
jmp    12d4 <getBogos+0x144>
lea    0x8(%rsp),%rbx
movabs $0x400000100000200,%rax
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%ecx
cmp    $0x3a,%rcx
ja     127f <getBogos+0xef>
bt     %rcx,%rax
jae    127f <getBogos+0xef>
add    $0x1,%rbx
jmp    1250 <getBogos+0xc0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xd,-0x1(%rax,%rbx,1)
je     1270 <getBogos+0xe0>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1270 <getBogos+0xe0>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12c6 <getBogos+0x136>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
movl   $0x0,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
xor    %r15d,%r15d
mov    %r12d,%edi
call   1090 <close@plt>
mov    %r15d,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@O_RDONLY = global i32 0
@.str.1 = [9 x i8] c"BOGOMIPS\00"
define i32 @getBogos(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [4096 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i32, i32* @O_RDONLY
%8 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 %8, i32* %4
br label %9
9: ; preds = %87, %1
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%11 = load i32, i32* %4
%12 = call i32* @fdgets(i8* %10, i32 4096, i32 %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %90
14: ; preds = %9
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%16 = call i32 @uppercase(i8* %15)
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%18 = call i8* @strstr(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%20 = icmp eq i8* %18, %19
br i1 %20, label %21, label %87
21: ; preds = %14
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds i8, i8* %22, i64 8
store i8* %23, i8** %6
br label %24
24: ; preds = %41, %21
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = icmp eq i32 %27, 32
br i1 %28, label %39, label %29
29: ; preds = %24
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp eq i32 %32, 9
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp eq i32 %37, 58
br label %39
39: ; preds = %34, %29, %24
%40 = phi i1 [ true, %29 ], [ true, %24 ], [ %38, %34 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %6
br label %24
44: ; preds = %39
br label %45
45: ; preds = %67, %44
%46 = load i8*, i8** %6
%47 = load i8*, i8** %6
%48 = call i32 @strlen(i8* %47)
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %46, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = icmp eq i32 %53, 13
br i1 %54, label %65, label %55
55: ; preds = %45
%56 = load i8*, i8** %6
%57 = load i8*, i8** %6
%58 = call i32 @strlen(i8* %57)
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %56, i64 %60
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = icmp eq i32 %63, 10
br label %65
65: ; preds = %55, %45
%66 = phi i1 [ true, %45 ], [ %64, %55 ]
br i1 %66, label %67, label %74
67: ; preds = %65
%68 = load i8*, i8** %6
%69 = load i8*, i8** %6
%70 = call i32 @strlen(i8* %69)
%71 = sub nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %68, i64 %72
store i8 0, i8* %73
br label %45
74: ; preds = %65
%75 = load i8*, i8** %6
%76 = call i32* @strchr(i8* %75, i8 signext 46)
%77 = icmp ne i32* %76, null
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = load i8*, i8** %6
%80 = call i32* @strchr(i8* %79, i8 signext 46)
store i32 0, i32* %80
br label %81
81: ; preds = %78, %74
%82 = load i8*, i8** %3
%83 = load i8*, i8** %6
%84 = call i32 @strcpy(i8* %82, i8* %83)
%85 = load i32, i32* %4
%86 = call i32 @close(i32 %85)
store i32 0, i32* %2
br label %93
87: ; preds = %14
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%89 = call i32 @memset(i8* %88, i32 0, i32 4096)
br label %9
90: ; preds = %9
%91 = load i32, i32* %4
%92 = call i32 @close(i32 %91)
store i32 1, i32* %2
br label %93
93: ; preds = %90, %81
%94 = load i32, i32* %2
ret i32 %94
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@O_RDONLY = global i32 0
@.str.1 = [9 x i8] c"BOGOMIPS\00"
define i32 @getBogos(i8* %0) {
%2 = alloca [4096 x i8]
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%6 = call i32* @fdgets(i8* %5, i32 4096, i32 %4)
%7 = icmp eq i32* %6, null
br i1 %7, label %50, label %8
8: ; preds = %1, %46
%9 = call i32 @uppercase(i8* %5)
%10 = call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %46
13: ; preds = %8
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 8
br label %15
15: ; preds = %18, %13
%16 = phi i8* [ %14, %13 ], [ %19, %18 ]
%17 = load i8, i8* %16
switch i8 %17, label %20 [
i8 32, label %18
i8 9, label %18
i8 58, label %18
]
18: ; preds = %15, %15, %15
%19 = getelementptr inbounds i8, i8* %16, i64 1
br label %15
20: ; preds = %15, %34
%21 = call i32 @strlen(i8* %16)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %16, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 13
br i1 %26, label %34, label %27
27: ; preds = %20
%28 = call i32 @strlen(i8* %16)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %16, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 10
br i1 %33, label %34, label %39
34: ; preds = %20, %27
%35 = call i32 @strlen(i8* %16)
%36 = add nsw i32 %35, -1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %16, i64 %37
store i8 0, i8* %38
br label %20
39: ; preds = %27
%40 = call i32* @strchr(i8* %16, i8 signext 46)
%41 = icmp eq i32* %40, null
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32* @strchr(i8* %16, i8 signext 46)
store i32 0, i32* %43
br label %44
44: ; preds = %42, %39
%45 = call i32 @strcpy(i8* %0, i8* %16)
br label %50
46: ; preds = %8
%47 = call i32 @memset(i8* %5, i32 0, i32 4096)
%48 = call i32* @fdgets(i8* %5, i32 4096, i32 %4)
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %8
50: ; preds = %46, %1, %44
%51 = phi i32 [ 0, %44 ], [ 1, %1 ], [ 1, %46 ]
%52 = call i32 @close(i32 %4)
ret i32 %51
}