#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*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strstr(char *, char *);
int show_revision_and_hardware(void) {
  FILE *fp = NULL;
  char buffer[256];
  char *pbuf = NULL;
  fp = fopen("/proc/cpuinfo", "r");
  if (fp != NULL) {
    while (!feof(fp)) {
      memset(buffer, 0x00, sizeof(buffer));
      pbuf = fgets(buffer, sizeof(buffer), fp);
      if (pbuf != NULL) {
        if (strstr(pbuf, "Hardware")) {
          printf("%s", pbuf);
        }
        if (strstr(pbuf, "Revision")) {
          printf("%s", pbuf);
        }
      }
    }
    fclose(fp);
    fp = NULL;
  }
  return 0;
}


x86 assembly (clang, -O0):
<show_revision_and_hardware>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x118(%rbp)
lea    0xe6b(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     128b <show_revision_and_hardware+0x11b>
jmp    11b5 <show_revision_and_hardware+0x45>
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d3 <show_revision_and_hardware+0x63>
jmp    127a <show_revision_and_hardware+0x10a>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
je     1275 <show_revision_and_hardware+0x105>
mov    -0x118(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     1240 <show_revision_and_hardware+0xd0>
mov    -0x118(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
mov    -0x118(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     1270 <show_revision_and_hardware+0x100>
mov    -0x118(%rbp),%rsi
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
jmp    1275 <show_revision_and_hardware+0x105>
jmp    11b5 <show_revision_and_hardware+0x45>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x8(%rbp)
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_revision_and_hardware>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe78(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11b0 <show_revision_and_hardware+0x40>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11c4 <show_revision_and_hardware+0x54>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r14
lea    0xe42(%rip),%r15
lea    0xe47(%rip),%r12
lea    0xe3d(%rip),%r13
jmp    11ec <show_revision_and_hardware+0x7c>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11a8 <show_revision_and_hardware+0x38>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e0 <show_revision_and_hardware+0x70>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     122e <show_revision_and_hardware+0xbe>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11e0 <show_revision_and_hardware+0x70>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
jmp    11e0 <show_revision_and_hardware+0x70>

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"Hardware\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [9 x i8] c"Revision\00"
define i32 @show_revision_and_hardware() {
%1 = alloca i32*
%2 = alloca [256 x i8]
%3 = alloca i8*
store i32* null, i32** %1
store i8* null, i8** %3
%4 = 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* %4, i32** %1
%5 = load i32*, i32** %1
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %40
7: ; preds = %0
br label %8
8: ; preds = %36, %7
%9 = load i32*, i32** %1
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %37
13: ; preds = %8
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 256)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = load i32*, i32** %1
%18 = call i8* @fgets(i8* %16, i32 256, i32* %17)
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %36
21: ; preds = %13
%22 = load i8*, i8** %3
%23 = call i64 @strstr(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %21
%29 = load i8*, i8** %3
%30 = call i64 @strstr(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %32, %28
br label %36
36: ; preds = %35, %13
br label %8
37: ; preds = %8
%38 = load i32*, i32** %1
%39 = call i32 @fclose(i32* %38)
store i32* null, i32** %1
br label %40
40: ; preds = %37, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"Hardware\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [9 x i8] c"Revision\00"
define i32 @show_revision_and_hardware() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %27, label %5
5: ; preds = %0
%6 = call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %5, %22
%9 = call i32 @memset(i8* %2, i32 0, i32 256)
%10 = call i8* @fgets(i8* %2, i32 256, i32* %3)
%11 = icmp eq i8* %10, null
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = call i64 @strstr(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %17
17: ; preds = %15, %12
%18 = call i64 @strstr(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %22
22: ; preds = %17, %20, %8
%23 = call i32 @feof(i32* %3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %8, label %25
25: ; preds = %22, %5
%26 = call i32 @fclose(i32* %3)
br label %27
27: ; preds = %25, %0
ret i32 0
}