#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*/ O_RDONLY;
scalar_t__ atof(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, float);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ stdout;
void cpu_temp(void) {
  int fd;
  char *tmp;
  float raltmp;
  fd = open("/sys/class/thermal/thermal_zone0/temp", O_RDONLY);
  tmp = malloc((size_t)1024);
  read(fd, tmp, 1024);
  raltmp = (float)atof(tmp);
  raltmp /= 1000;
  fprintf(stdout, "CPU temp=%.1f'C\n", raltmp);
  free(tmp);
}


x86 assembly (clang, -O0):
<cpu_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xe8c(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x4(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    -0x10(%rbp),%rdi
call   1040 <atof@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe41(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
movss  -0x14(%rbp),%xmm0
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_temp>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1080 <open@plt>
mov    %eax,%ebp
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %rbx,%rdi
call   1040 <atof@plt>
cvtsi2ss %rax,%xmm0
divss  0xe55(%rip),%xmm0
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1060 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"/sys/class/thermal/thermal_zone0/temp\00"
@O_RDONLY = global i32 0
@stdout = global i32 0
@.str.1 = [17 x i8] c"CPU temp=%.1f'C\0A\00"
define void @cpu_temp() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca float
%4 = load i32, i32* @O_RDONLY
%5 = call i32 @open(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %1
%6 = call i8* @malloc(i64 1024)
store i8* %6, i8** %2
%7 = load i32, i32* %1
%8 = load i8*, i8** %2
%9 = call i32 @read(i32 %7, i8* %8, i32 1024)
%10 = load i8*, i8** %2
%11 = call i64 @atof(i8* %10)
%12 = sitofp i64 %11 to float
store float %12, float* %3
%13 = load float, float* %3
%14 = fdiv float %13, 1.000000e+03
store float %14, float* %3
%15 = load i32, i32* @stdout
%16 = load float, float* %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), float %16)
%18 = load i8*, i8** %2
%19 = call i32 @free(i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"/sys/class/thermal/thermal_zone0/temp\00"
@O_RDONLY = global i32 0
@stdout = global i32 0
@.str.1 = [17 x i8] c"CPU temp=%.1f'C\0A\00"
define void @cpu_temp() {
%1 = load i32, i32* @O_RDONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%4 = tail call i32 @read(i32 %2, i8* %3, i32 1024)
%5 = tail call i64 @atof(i8* %3)
%6 = sitofp i64 %5 to float
%7 = fdiv float %6, 1.000000e+03
%8 = load i32, i32* @stdout
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), float %7)
%10 = tail call i32 @free(i8* %3)
ret void
}