#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*/ os;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int run_cmd(char *, char *, int);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strncmp(char *, char *, int);
scalar_t__ strstr(char *, char *);
int cpu_type(FILE *fo) {
  int nbr_cpu = 0, phys_cpu_id = -1, nbr_cores = 0;
  char buffer[1024], model[80] = {0};
  FILE *f = fopen("/proc/cpuinfo", "r");
  if (f) {
    while (fgets(buffer, sizeof(buffer), f)) {
      if (!strncmp(buffer, "processor\t:", 11))
        nbr_cpu++;
      else if (!strncmp(buffer, "physical id\t:", 13)) {
        int id = atoi(buffer + 14);
        if (id > phys_cpu_id)
          phys_cpu_id = id;
      } else if (!*model && !strncmp(buffer, "model name\t:", 12)) {
        char *s = buffer + 13, *d = model;
        while (*s) {
          *d++ = *s;
          if (*s++ == ' ') {
            while (*s == ' ')
              s++;
            *d++ = *s++;
          }
        }
      }
      if (!nbr_cores && !strncmp(buffer, "cpu cores\t:", 11))
        nbr_cores = atoi(buffer + 12);
    }
    fclose(f);
  }
  char os[1024];
  int len = run_cmd("uname -a", os, sizeof(os));
  if (len) {
    if (strstr(model, "AMD") && strstr(os, " 3.")) {
      fprintf(stdout,
              "=> Nbr-CPU-Cores x2 for Linux kernel v3+ on AMD platforms\n");
      nbr_cores *= 2;
    }
  }
  if (nbr_cores > 0)
    nbr_cpu = nbr_cores;
  fprintf(stdout, "CPU: %d x %u-Core CPU(s) %s",
          phys_cpu_id >= 0 ? phys_cpu_id + 1 : 1, nbr_cores, model);
  fprintf(fo, "CPU: %d x %u-Core CPU(s) %s",
          phys_cpu_id >= 0 ? phys_cpu_id + 1 : 1, nbr_cores, model);
  return nbr_cpu << 16 | (nbr_cores ? nbr_cores : 1);
}


x86 assembly (clang, -O0):
<cpu_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8c0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x470(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
lea    0xe32(%rip),%rdi
lea    0xe39(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x478(%rbp)
cmpq   $0x0,-0x478(%rbp)
je     13f8 <cpu_type+0x268>
jmp    11f4 <cpu_type+0x64>
lea    -0x420(%rbp),%rdi
mov    -0x478(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     13ec <cpu_type+0x25c>
lea    -0x420(%rbp),%rdi
lea    0xdec(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1245 <cpu_type+0xb5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13a9 <cpu_type+0x219>
lea    -0x420(%rbp),%rdi
lea    0xdc9(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1299 <cpu_type+0x109>
lea    -0x420(%rbp),%rdi
add    $0xe,%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x47c(%rbp)
mov    -0x47c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1294 <cpu_type+0x104>
mov    -0x47c(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    13a4 <cpu_type+0x214>
cmpb   $0x0,-0x470(%rbp)
jne    139f <cpu_type+0x20f>
lea    -0x420(%rbp),%rdi
lea    0xd76(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    139f <cpu_type+0x20f>
lea    -0x420(%rbp),%rax
add    $0xd,%rax
mov    %rax,-0x488(%rbp)
lea    -0x470(%rbp),%rax
mov    %rax,-0x490(%rbp)
mov    -0x488(%rbp),%rax
cmpb   $0x0,(%rax)
je     139a <cpu_type+0x20a>
mov    -0x488(%rbp),%rax
mov    (%rax),%cl
mov    -0x490(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x490(%rbp)
mov    %cl,(%rax)
mov    -0x488(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x488(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1395 <cpu_type+0x205>
jmp    133d <cpu_type+0x1ad>
mov    -0x488(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1367 <cpu_type+0x1d7>
mov    -0x488(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x488(%rbp)
jmp    133d <cpu_type+0x1ad>
mov    -0x488(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x488(%rbp)
mov    (%rax),%cl
mov    -0x490(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x490(%rbp)
mov    %cl,(%rax)
jmp    12e7 <cpu_type+0x157>
jmp    139f <cpu_type+0x20f>
jmp    13a4 <cpu_type+0x214>
jmp    13a9 <cpu_type+0x219>
cmpl   $0x0,-0x14(%rbp)
jne    13e7 <cpu_type+0x257>
lea    -0x420(%rbp),%rdi
lea    0xc76(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    13e7 <cpu_type+0x257>
lea    -0x420(%rbp),%rdi
add    $0xc,%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11f4 <cpu_type+0x64>
mov    -0x478(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x890(%rbp),%rsi
lea    0xc3d(%rip),%rdi
mov    $0x400,%edx
call   1090 <run_cmd@plt>
mov    %eax,-0x894(%rbp)
cmpl   $0x0,-0x894(%rbp)
je     1483 <cpu_type+0x2f3>
lea    -0x470(%rbp),%rdi
lea    0xc1b(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     147e <cpu_type+0x2ee>
lea    -0x890(%rbp),%rdi
lea    0xc02(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     147e <cpu_type+0x2ee>
mov    0x2b7c(%rip),%rax
mov    (%rax),%rdi
lea    0xbe6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1483 <cpu_type+0x2f3>
cmpl   $0x0,-0x14(%rbp)
jle    1493 <cpu_type+0x303>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    0x2b46(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8a0(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     14bf <cpu_type+0x32f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8a4(%rbp)
jmp    14cf <cpu_type+0x33f>
mov    $0x1,%eax
mov    %eax,-0x8a4(%rbp)
jmp    14cf <cpu_type+0x33f>
mov    -0x8a0(%rbp),%rdi
mov    -0x8a4(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    -0x470(%rbp),%r8
lea    0xba2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x8b0(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     151a <cpu_type+0x38a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8b4(%rbp)
jmp    152a <cpu_type+0x39a>
mov    $0x1,%eax
mov    %eax,-0x8b4(%rbp)
jmp    152a <cpu_type+0x39a>
mov    -0x8b0(%rbp),%rdi
mov    -0x8b4(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    -0x470(%rbp),%r8
lea    0xb47(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xc(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x8b8(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1573 <cpu_type+0x3e3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8bc(%rbp)
jmp    1583 <cpu_type+0x3f3>
mov    $0x1,%eax
mov    %eax,-0x8bc(%rbp)
jmp    1583 <cpu_type+0x3f3>
mov    -0x8b8(%rbp),%eax
mov    -0x8bc(%rbp),%ecx
or     %ecx,%eax
add    $0x8c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_type>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x868,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe39(%rip),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
mov    %rbx,0x8(%rsp)
je     133b <cpu_type+0x1ab>
mov    %rax,%rbp
lea    0x60(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    $0xffffffff,%r12d
test   %rax,%rax
je     1348 <cpu_type+0x1b8>
xor    %r15d,%r15d
lea    0xe01(%rip),%r13
lea    0x60(%rsp),%r14
xor    %ebx,%ebx
jmp    1239 <cpu_type+0xa9>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     134d <cpu_type+0x1bd>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     12e0 <cpu_type+0x150>
mov    %r14,%rdi
lea    0xdc1(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1320 <cpu_type+0x190>
cmpb   $0x0,0x10(%rsp)
jne    12e4 <cpu_type+0x154>
mov    %r14,%rdi
lea    0xdac(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12e4 <cpu_type+0x154>
mov    0x6d(%rsp),%dl
test   %dl,%dl
je     12e4 <cpu_type+0x154>
lea    0x10(%rsp),%rax
lea    0x6d(%rsp),%rsi
jmp    12ad <cpu_type+0x11d>
add    $0x1,%rax
mov    (%rcx),%dl
mov    %rcx,%rsi
test   %dl,%dl
je     12e4 <cpu_type+0x154>
mov    %dl,(%rax)
lea    0x1(%rsi),%rcx
cmpb   $0x20,(%rsi)
jne    12a0 <cpu_type+0x110>
nopl   0x0(%rax,%rax,1)
movzbl (%rcx),%edx
add    $0x1,%rcx
cmp    $0x20,%dl
je     12c0 <cpu_type+0x130>
mov    %dl,0x1(%rax)
add    $0x2,%rax
jmp    12a4 <cpu_type+0x114>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15d
test   %ebx,%ebx
jne    1220 <cpu_type+0x90>
mov    %r14,%rdi
lea    0xd41(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1220 <cpu_type+0x90>
lea    0x6c(%rsp),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
jmp    1220 <cpu_type+0x90>
nopl   0x0(%rax,%rax,1)
lea    0x6e(%rsp),%rdi
call   1090 <atoi@plt>
cmp    %r12d,%eax
cmovg  %eax,%r12d
test   %ebx,%ebx
jne    1220 <cpu_type+0x90>
jmp    12ec <cpu_type+0x15c>
mov    $0xffffffff,%r12d
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    1355 <cpu_type+0x1c5>
xor    %ebx,%ebx
xor    %r15d,%r15d
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xce7(%rip),%rdi
lea    0x460(%rsp),%rsi
mov    $0x400,%edx
call   1080 <run_cmd@plt>
test   %eax,%eax
je     13c3 <cpu_type+0x233>
lea    0xcd3(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10b0 <strstr@plt>
test   %rax,%rax
je     13c3 <cpu_type+0x233>
lea    0xcc1(%rip),%rsi
lea    0x460(%rsp),%rdi
call   10b0 <strstr@plt>
test   %rax,%rax
je     13c3 <cpu_type+0x233>
mov    0x2c38(%rip),%rax
mov    (%rax),%rcx
lea    0xca2(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
add    %ebx,%ebx
mov    0x2c16(%rip),%rax
mov    (%rax),%rdi
lea    0x1(%r12),%ebp
test   %r12d,%r12d
mov    $0x1,%r13d
cmovs  %r13d,%ebp
lea    0xca9(%rip),%r14
lea    0x10(%rsp),%r12
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %ebx,%ebx
cmovg  %ebx,%r15d
cmove  %r13d,%ebx
shl    $0x10,%r15d
or     %ebx,%r15d
mov    %r15d,%eax
add    $0x868,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"processor\09:\00"
@.str.3 = [14 x i8] c"physical id\09:\00"
@.str.4 = [13 x i8] c"model name\09:\00"
@.str.5 = [12 x i8] c"cpu cores\09:\00"
@.str.6 = [9 x i8] c"uname -a\00"
@.str.7 = [4 x i8] c"AMD\00"
@.str.8 = [4 x i8] c" 3.\00"
@stdout = global i32* null
@.str.9 = [59 x i8] c"=> Nbr-CPU-Cores x2 for Linux kernel v3+ on AMD platforms\0A\00"
@.str.10 = [28 x i8] c"CPU: %d x %u-Core CPU(s) %s\00"
define i32 @cpu_type(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca [80 x i8]
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [1024 x i8]
%13 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 -1, i32* %4
store i32 0, i32* %5
%14 = bitcast [80 x i8]* %7 to i8*
%15 = 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* %15, i32** %8
%16 = load i32*, i32** %8
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %105
18: ; preds = %1
br label %19
19: ; preds = %101, %18
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%21 = load i32*, i32** %8
%22 = call i64 @fgets(i8* %20, i32 1024, i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %102
24: ; preds = %19
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i32 @strncmp(i8* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 11)
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %90
31: ; preds = %24
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%33 = call i32 @strncmp(i8* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13)
%34 = icmp ne i32 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %31
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%37 = getelementptr inbounds i8, i8* %36, i64 14
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = load i32, i32* %4
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = load i32, i32* %9
store i32 %43, i32* %4
br label %44
44: ; preds = %42, %35
br label %89
45: ; preds = %31
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%47 = load i8, i8* %46
%48 = icmp ne i8 %47, 0
br i1 %48, label %88, label %49
49: ; preds = %45
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%51 = call i32 @strncmp(i8* %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 12)
%52 = icmp ne i32 %51, 0
br i1 %52, label %88, label %53
53: ; preds = %49
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%55 = getelementptr inbounds i8, i8* %54, i64 13
store i8* %55, i8** %10
%56 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
store i8* %56, i8** %11
br label %57
57: ; preds = %86, %53
%58 = load i8*, i8** %10
%59 = load i8, i8* %58
%60 = icmp ne i8 %59, 0
br i1 %60, label %61, label %87
61: ; preds = %57
%62 = load i8*, i8** %10
%63 = load i8, i8* %62
%64 = load i8*, i8** %11
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %11
store i8 %63, i8* %64
%66 = load i8*, i8** %10
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %10
%68 = load i8, i8* %66
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 32
br i1 %70, label %71, label %86
71: ; preds = %61
br label %72
72: ; preds = %77, %71
%73 = load i8*, i8** %10
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 32
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = load i8*, i8** %10
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %10
br label %72
80: ; preds = %72
%81 = load i8*, i8** %10
%82 = getelementptr inbounds i8, i8* %81, i32 1
store i8* %82, i8** %10
%83 = load i8, i8* %81
%84 = load i8*, i8** %11
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %11
store i8 %83, i8* %84
br label %86
86: ; preds = %80, %61
br label %57
87: ; preds = %57
br label %88
88: ; preds = %87, %49, %45
br label %89
89: ; preds = %88, %44
br label %90
90: ; preds = %89, %28
%91 = load i32, i32* %5
%92 = icmp ne i32 %91, 0
br i1 %92, label %101, label %93
93: ; preds = %90
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%95 = call i32 @strncmp(i8* %94, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 11)
%96 = icmp ne i32 %95, 0
br i1 %96, label %101, label %97
97: ; preds = %93
%98 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%99 = getelementptr inbounds i8, i8* %98, i64 12
%100 = call i32 @atoi(i8* %99)
store i32 %100, i32* %5
br label %101
101: ; preds = %97, %93, %90
br label %19
102: ; preds = %19
%103 = load i32*, i32** %8
%104 = call i32 @fclose(i32* %103)
br label %105
105: ; preds = %102, %1
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%107 = call i32 @run_cmd(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %106, i32 1024)
store i32 %107, i32* %13
%108 = load i32, i32* %13
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %124
110: ; preds = %105
%111 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%112 = call i64 @strstr(i8* %111, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %123
114: ; preds = %110
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%116 = call i64 @strstr(i8* %115, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %123
118: ; preds = %114
%119 = load i32*, i32** @stdout
%120 = call i32 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0))
%121 = load i32, i32* %5
%122 = mul nsw i32 %121, 2
store i32 %122, i32* %5
br label %123
123: ; preds = %118, %114, %110
br label %124
124: ; preds = %123, %105
%125 = load i32, i32* %5
%126 = icmp sgt i32 %125, 0
br i1 %126, label %127, label %129
127: ; preds = %124
%128 = load i32, i32* %5
store i32 %128, i32* %3
br label %129
129: ; preds = %127, %124
%130 = load i32*, i32** @stdout
%131 = load i32, i32* %4
%132 = icmp sge i32 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %129
%134 = load i32, i32* %4
%135 = add nsw i32 %134, 1
br label %137
136: ; preds = %129
br label %137
137: ; preds = %136, %133
%138 = phi i32 [ %135, %133 ], [ 1, %136 ]
%139 = load i32, i32* %5
%140 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%141 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %138, i32 %139, i8* %140)
%142 = load i32*, i32** %2
%143 = load i32, i32* %4
%144 = icmp sge i32 %143, 0
br i1 %144, label %145, label %148
145: ; preds = %137
%146 = load i32, i32* %4
%147 = add nsw i32 %146, 1
br label %149
148: ; preds = %137
br label %149
149: ; preds = %148, %145
%150 = phi i32 [ %147, %145 ], [ 1, %148 ]
%151 = load i32, i32* %5
%152 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%153 = call i32 (i32*, i8*, ...) @fprintf(i32* %142, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %150, i32 %151, i8* %152)
%154 = load i32, i32* %3
%155 = shl i32 %154, 16
%156 = load i32, i32* %5
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %160
158: ; preds = %149
%159 = load i32, i32* %5
br label %161
160: ; preds = %149
br label %161
161: ; preds = %160, %158
%162 = phi i32 [ %159, %158 ], [ 1, %160 ]
%163 = or i32 %155, %162
ret i32 %163
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"processor\09:\00"
@.str.3 = [14 x i8] c"physical id\09:\00"
@.str.4 = [13 x i8] c"model name\09:\00"
@.str.5 = [12 x i8] c"cpu cores\09:\00"
@.str.6 = [9 x i8] c"uname -a\00"
@.str.7 = [4 x i8] c"AMD\00"
@.str.8 = [4 x i8] c" 3.\00"
@stdout = global i32* null
@.str.9 = [59 x i8] c"=> Nbr-CPU-Cores x2 for Linux kernel v3+ on AMD platforms\0A\00"
@.str.10 = [28 x i8] c"CPU: %d x %u-Core CPU(s) %s\00"
define i32 @cpu_type(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca [80 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%7 = 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))
%8 = icmp eq i32* %7, null
br i1 %8, label %78, label %9
9: ; preds = %1
%10 = call i64 @fgets(i8* %5, i32 1024, i32* %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %73, label %12
12: ; preds = %9
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 13
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 14
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 12
br label %16
16: ; preds = %12, %69
%17 = phi i32 [ 0, %12 ], [ %62, %69 ]
%18 = phi i32 [ -1, %12 ], [ %61, %69 ]
%19 = phi i32 [ 0, %12 ], [ %70, %69 ]
%20 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 11)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = add nsw i32 %17, 1
br label %60
24: ; preds = %16
%25 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = call i32 @atoi(i8* %14)
%29 = icmp sgt i32 %28, %18
%30 = select i1 %29, i32 %28, i32 %18
br label %60
31: ; preds = %24
%32 = load i8, i8* %6
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %60
34: ; preds = %31
%35 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 12)
%36 = icmp ne i32 %35, 0
%37 = load i8, i8* %13
%38 = icmp eq i8 %37, 0
%39 = select i1 %36, i1 true, i1 %38
br i1 %39, label %60, label %40
40: ; preds = %34, %55
%41 = phi i8 [ %58, %55 ], [ %37, %34 ]
%42 = phi i8* [ %57, %55 ], [ %6, %34 ]
%43 = phi i8* [ %56, %55 ], [ %13, %34 ]
%44 = getelementptr inbounds i8, i8* %42, i64 1
store i8 %41, i8* %42
%45 = getelementptr inbounds i8, i8* %43, i64 1
%46 = load i8, i8* %43
%47 = icmp eq i8 %46, 32
br i1 %47, label %48, label %55
48: ; preds = %40, %48
%49 = phi i8* [ %52, %48 ], [ %45, %40 ]
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 32
%52 = getelementptr inbounds i8, i8* %49, i64 1
br i1 %51, label %48, label %53
53: ; preds = %48
%54 = getelementptr inbounds i8, i8* %42, i64 2
store i8 %50, i8* %44
br label %55
55: ; preds = %53, %40
%56 = phi i8* [ %52, %53 ], [ %45, %40 ]
%57 = phi i8* [ %54, %53 ], [ %44, %40 ]
%58 = load i8, i8* %56
%59 = icmp eq i8 %58, 0
br i1 %59, label %60, label %40
60: ; preds = %55, %27, %34, %31, %22
%61 = phi i32 [ %18, %31 ], [ %18, %34 ], [ %30, %27 ], [ %18, %22 ], [ %18, %55 ]
%62 = phi i32 [ %17, %31 ], [ %17, %34 ], [ %17, %27 ], [ %23, %22 ], [ %17, %55 ]
%63 = icmp eq i32 %19, 0
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 11)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 @atoi(i8* %15)
br label %69
69: ; preds = %67, %64, %60
%70 = phi i32 [ %19, %60 ], [ 0, %64 ], [ %68, %67 ]
%71 = call i64 @fgets(i8* %5, i32 1024, i32* %7)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %16
73: ; preds = %69, %9
%74 = phi i32 [ 0, %9 ], [ %70, %69 ]
%75 = phi i32 [ -1, %9 ], [ %61, %69 ]
%76 = phi i32 [ 0, %9 ], [ %62, %69 ]
%77 = call i32 @fclose(i32* %7)
br label %78
78: ; preds = %73, %1
%79 = phi i32 [ %74, %73 ], [ 0, %1 ]
%80 = phi i32 [ %75, %73 ], [ -1, %1 ]
%81 = phi i32 [ %76, %73 ], [ 0, %1 ]
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%83 = call i32 @run_cmd(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %82, i32 1024)
%84 = icmp eq i32 %83, 0
br i1 %84, label %95, label %85
85: ; preds = %78
%86 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %95, label %88
88: ; preds = %85
%89 = call i64 @strstr(i8* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%90 = icmp eq i64 %89, 0
br i1 %90, label %95, label %91
91: ; preds = %88
%92 = load i32*, i32** @stdout
%93 = call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i64 58, i64 1, i32* %92)
%94 = shl nsw i32 %79, 1
br label %95
95: ; preds = %85, %88, %91, %78
%96 = phi i32 [ %94, %91 ], [ %79, %88 ], [ %79, %85 ], [ %79, %78 ]
%97 = icmp sgt i32 %96, 0
%98 = select i1 %97, i32 %96, i32 %81
%99 = load i32*, i32** @stdout
%100 = icmp sgt i32 %80, -1
%101 = add nsw i32 %80, 1
%102 = select i1 %100, i32 %101, i32 1
%103 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %102, i32 %96, i8* %6)
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %102, i32 %96, i8* %6)
%105 = shl i32 %98, 16
%106 = icmp eq i32 %96, 0
%107 = select i1 %106, i32 1, i32 %96
%108 = or i32 %105, %107
ret i32 %108
}