#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *t_file;
  double temperature;
  t_file = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
  if (t_file == NULL) {
    printf("cant get file-descriptor form fopen()");
  }
  fscanf(t_file, "%lf", &temperature);
  temperature /= 1000;
  printf("The cpu-temperature is %4.1f °C\n", temperature);
  fclose(t_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
lea    0xed1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <main+0x3f>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xecc(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <fscanf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe60(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
lea    0xedb(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116e <main+0x2e>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee1(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <fscanf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xe70(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xebd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"/sys/class/thermal/thermal_zone0/temp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"cant get file-descriptor form fopen()\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [34 x i8] c"The cpu-temperature is %4.1f \C2\B0C\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca double
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 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 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32*, i32** %2
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
%12 = load double, double* %3
%13 = fdiv double %12, 1.000000e+03
store double %13, double* %3
%14 = load double, double* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), double %14)
%16 = load i32*, i32** %2
%17 = call i32 @fclose(i32* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"/sys/class/thermal/thermal_zone0/temp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"cant get file-descriptor form fopen()\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [34 x i8] c"The cpu-temperature is %4.1f \C2\B0C\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 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 %5, label %7
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%9 = load double, double* %1
%10 = fdiv double %9, 1.000000e+03
store double %10, double* %1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), double %10)
%12 = call i32 @fclose(i32* %3)
ret i32 0
}