#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*/ buildpacket(unsigned char *, int *, int,
                               int /*<<< orphan*/ *, int /*<<< orphan*/);
int listen(int, unsigned char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ processcpuinfo(unsigned char *, int);
int /*<<< orphan*/ write(int, unsigned char *, int);
void getcpuinfo(int fd) {
  unsigned char pak[1024];
  unsigned char buf[1024];
  int len, res;
  buildpacket(pak, &len, 0x25, NULL, 0);
  write(fd, pak, len);
  res = listen(fd, buf);
  if (res > 1)
    processcpuinfo(buf, res);
  else
    printf("No response from CPU to get_cpu_info.\n");
}


x86 assembly (clang, -O0):
<getcpuinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
lea    -0x814(%rbp),%rsi
mov    $0x25,%edx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
call   1050 <buildpacket@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x814(%rbp),%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
call   1060 <listen@plt>
mov    %eax,-0x818(%rbp)
cmpl   $0x1,-0x818(%rbp)
jle    11cb <getcpuinfo+0x7b>
lea    -0x810(%rbp),%rdi
mov    -0x818(%rbp),%esi
call   1070 <processcpuinfo@plt>
jmp    11d7 <getcpuinfo+0x87>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getcpuinfo>:
push   %r14
push   %rbx
sub    $0x818,%rsp
mov    %edi,%ebx
lea    0x410(%rsp),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
mov    $0x25,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <buildpacket@plt>
mov    0xc(%rsp),%edx
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <write@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
call   1060 <listen@plt>
cmp    $0x2,%eax
jl     11a8 <getcpuinfo+0x58>
lea    0x10(%rsp),%rdi
mov    %eax,%esi
call   1070 <processcpuinfo@plt>
jmp    11b4 <getcpuinfo+0x64>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [39 x i8] c"No response from CPU to get_cpu_info.\0A\00"
define void @getcpuinfo(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = call i32 @buildpacket(i8* %7, i32* %5, i32 37, i32* null, i32 0)
%9 = load i32, i32* %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* %5
%12 = call i32 @write(i32 %9, i8* %10, i32 %11)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = call i32 @listen(i32 %13, i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %1
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = load i32, i32* %6
%21 = call i32 @processcpuinfo(i8* %19, i32 %20)
br label %24
22: ; preds = %1
%23 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
ret void
}

LLVM IR (-O2):
@str = [38 x i8] c"No response from CPU to get_cpu_info.\00"
define void @getcpuinfo(i32 %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = call i32 @buildpacket(i8* %5, i32* %4, i32 37, i32* null, i32 0)
%9 = load i32, i32* %4
%10 = call i32 @write(i32 %0, i8* %5, i32 %9)
%11 = call i32 @listen(i32 %0, i8* %6)
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @processcpuinfo(i8* %6, i32 %11)
br label %17
15: ; preds = %1
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
ret void
}