#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isspace(char const);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ puts(char *);
char *strchr(char *, char);
char *strstr(char *, char *);
void print_cpu_name(void) {
  char buffer[512];
  FILE *file;
  if ((file = fopen("/proc/cpuinfo", "r")) == NULL) {
    puts("Unknown");
    return;
  };
  while (fgets(buffer, sizeof(buffer), file) != NULL)
    if (strstr(buffer, "model name") == buffer) {
      const char *cptr;
      if ((cptr = strchr(buffer, ':')) != NULL) {
        cptr++;
        while (isspace(cptr[0]))
          cptr++;
        printf("%s", cptr);
        goto complete;
      };
    };
  fclose(file);
  puts("Unknown");
  return;
complete:
  fclose(file);
  return;
}


x86 assembly (clang, -O0):
<print_cpu_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    0xe6e(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x208(%rbp)
cmp    $0x0,%rax
jne    11c0 <print_cpu_name+0x40>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
jmp    12b9 <print_cpu_name+0x139>
jmp    11c5 <print_cpu_name+0x45>
lea    -0x200(%rbp),%rdi
mov    -0x208(%rbp),%rdx
mov    $0x200,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1290 <print_cpu_name+0x110>
lea    -0x200(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   10a0 <strstr@plt>
lea    -0x200(%rbp),%rcx
cmp    %rcx,%rax
jne    128b <print_cpu_name+0x10b>
lea    -0x200(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x210(%rbp)
cmp    $0x0,%rax
je     1286 <print_cpu_name+0x106>
mov    -0x210(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x210(%rbp)
mov    -0x210(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     126e <print_cpu_name+0xee>
mov    -0x210(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x210(%rbp)
jmp    123e <print_cpu_name+0xbe>
mov    -0x210(%rbp),%rsi
lea    0xda7(%rip),%rdi
call   1060 <printf@plt>
jmp    12ad <print_cpu_name+0x12d>
jmp    128b <print_cpu_name+0x10b>
jmp    11c5 <print_cpu_name+0x45>
mov    -0x208(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd6d(%rip),%rdi
call   1030 <puts@plt>
jmp    12b9 <print_cpu_name+0x139>
mov    -0x208(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cpu_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe7b(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     126e <print_cpu_name+0xfe>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     124b <print_cpu_name+0xdb>
movabs $0x616e206c65646f6d,%r12
20 6e 61
mov    %rsp,%r14
jmp    11e5 <print_cpu_name+0x75>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     124b <print_cpu_name+0xdb>
mov    (%rsp),%rax
xor    %r12,%rax
movzwl 0x8(%rsp),%ecx
xor    $0x656d,%rcx
or     %rax,%rcx
jne    11d0 <print_cpu_name+0x60>
mov    %r14,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d0 <print_cpu_name+0x60>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1070 <isspace@plt>
test   %rax,%rax
jne    1220 <print_cpu_name+0xb0>
lea    0xdea(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    125f <print_cpu_name+0xef>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd9b(%rip),%rdi
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.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 = [11 x i8] c"model name\00"
@.str.4 = [3 x i8] c"%s\00"
define void @print_cpu_name() {
%1 = alloca [512 x i8]
%2 = alloca i32*
%3 = alloca i8*
%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** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %47
8: ; preds = %0
br label %9
9: ; preds = %39, %8
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = call i32* @fgets(i8* %10, i32 512, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %40
14: ; preds = %9
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%16 = call i8* @strstr(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %39
19: ; preds = %14
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%21 = call i8* @strchr(i8* %20, i8 signext 58)
store i8* %21, i8** %3
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
br label %26
26: ; preds = %32, %23
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = call i64 @isspace(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %26
35: ; preds = %26
%36 = load i8*, i8** %3
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %36)
br label %44
38: ; preds = %19
br label %39
39: ; preds = %38, %14
br label %9
40: ; preds = %9
%41 = load i32*, i32** %2
%42 = call i32 @fclose(i32* %41)
%43 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %47
44: ; preds = %35
%45 = load i32*, i32** %2
%46 = call i32 @fclose(i32* %45)
br label %47
47: ; preds = %44, %40, %6
ret void
}

LLVM IR (-O2):
@.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 = [11 x i8] c"model name\00"
@.str.4 = [3 x i8] c"%s\00"
define void @print_cpu_name() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 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 %8, label %5
5: ; preds = %0
%6 = call i32* @fgets(i8* %2, i32 512, i32* %3)
%7 = icmp eq i32* %6, null
br i1 %7, label %25, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %31
10: ; preds = %5, %22
%11 = call i32 @bcmp(i8* dereferenceable(10) %2, i8* dereferenceable(10) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i8* @strchr(i8* %2, i8 signext 58)
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13, %16
%17 = phi i8* [ %18, %16 ], [ %14, %13 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = call i64 @isspace(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %16
22: ; preds = %13, %10
%23 = call i32* @fgets(i8* %2, i32 512, i32* %3)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %10
25: ; preds = %22, %5
%26 = call i32 @fclose(i32* %3)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %31
28: ; preds = %16
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%30 = call i32 @fclose(i32* %3)
br label %31
31: ; preds = %28, %25, %8
ret void
}