#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_cpuinfo_file();
int /*<<< orphan*/ parse_line(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
int get_hardware(char *hardware_string) {
  char temp_string[BUFSIZ];
  FILE *fff;
  if ((fff = fopen(get_cpuinfo_file(), "r")) != NULL) {
    while ((fgets(temp_string, BUFSIZ, fff) != NULL)) {
      if (!(strncmp(temp_string, "platform string", 15))) {
        strncpy(hardware_string, parse_line(temp_string), 64);
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<get_hardware>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <get_cpuinfo_file@plt>
mov    %eax,%edi
lea    0xe58(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1229 <get_hardware+0xc9>
jmp    11c0 <get_hardware+0x60>
mov    -0x28(%rbp),%rdi
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1224 <get_hardware+0xc4>
mov    -0x28(%rbp),%rdi
lea    0xe17(%rip),%rsi
mov    $0xf,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    121f <get_hardware+0xbf>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
call   1070 <parse_line@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1030 <strncpy@plt>
jmp    11c0 <get_hardware+0x60>
jmp    1229 <get_hardware+0xc9>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    $0x1,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_hardware>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e68(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %eax,%eax
call   1050 <get_cpuinfo_file@plt>
lea    0xe65(%rip),%rsi
mov    %eax,%edi
call   1080 <fopen@plt>
test   %rax,%rax
je     1211 <get_hardware+0xb1>
mov    %rax,%r15
mov    0x0(%r13),%esi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1211 <get_hardware+0xb1>
lea    0xe3d(%rip),%r12
jmp    11e4 <get_hardware+0x84>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1211 <get_hardware+0xb1>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xf,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    11d0 <get_hardware+0x70>
mov    %rbx,%rdi
call   1070 <parse_line@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1030 <strncpy@plt>
jmp    11d0 <get_hardware+0x70>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"platform string\00"
define i32 @get_hardware(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
store i8* %0, i8** %2
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
%10 = call i32 (...) @get_cpuinfo_file()
%11 = call i32* @fopen(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %28
13: ; preds = %1
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* @BUFSIZ
%16 = load i32*, i32** %5
%17 = call i32* @fgets(i8* %9, i32 %15, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 15)
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i8*, i8** %2
%24 = call i32 @parse_line(i8* %9)
%25 = call i32 @strncpy(i8* %23, i32 %24, i32 64)
br label %26
26: ; preds = %22, %19
br label %14
27: ; preds = %14
br label %28
28: ; preds = %27, %1
%29 = load i8*, i8** %3
ret i32 1
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"platform string\00"
define i32 @get_hardware(i8* %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i32 (...) @get_cpuinfo_file()
%6 = tail call i32* @fopen(i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %22, label %8
8: ; preds = %1
%9 = load i32, i32* @BUFSIZ
%10 = call i32* @fgets(i8* %4, i32 %9, i32* %6)
%11 = icmp eq i32* %10, null
br i1 %11, label %22, label %12
12: ; preds = %8, %18
%13 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 15)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @parse_line(i8* %4)
%17 = call i32 @strncpy(i8* %0, i32 %16, i32 64)
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* @BUFSIZ
%20 = call i32* @fgets(i8* %4, i32 %19, i32* %6)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %12
22: ; preds = %18, %8, %1
ret i32 1
}