#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 *, float *);
char *smprintf(char *, float, float);
char *gettemp(void) {
  FILE *thermal_zone0 = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
  FILE *thermal_zone1 = fopen("/sys/class/thermal/thermal_zone1/temp", "r");
  float temp0, temp1;
  temp0 = temp1 = 0;
  fscanf(thermal_zone0, "%f", &temp0);
  fscanf(thermal_zone1, "%f", &temp1);
  fclose(thermal_zone0);
  fclose(thermal_zone1);
  temp0 /= 1000;
  temp1 /= 1000;
  return smprintf("TEMP %.1fC %.1fC", temp0, temp1);
}


x86 assembly (clang, -O0):
<gettemp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb5(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    0xec6(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec1(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe33(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe1d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
lea    0xe58(%rip),%rdi
call   1030 <smprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettemp>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
lea    0xed3(%rip),%r14
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xec3(%rip),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xec7(%rip),%r14
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
movss  0xc(%rsp),%xmm0
movss  0xe37(%rip),%xmm2
divss  %xmm2,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,0x8(%rsp)
lea    0xe6b(%rip),%rdi
call   1030 <smprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
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"/sys/class/thermal/thermal_zone1/temp\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [17 x i8] c"TEMP %.1fC %.1fC\00"
define i8* @gettemp() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca float
%4 = alloca float
%5 = 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* %5, i32** %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %3
%7 = load i32*, i32** %1
%8 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%9 = load i32*, i32** %2
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%11 = load i32*, i32** %1
%12 = call i32 @fclose(i32* %11)
%13 = load i32*, i32** %2
%14 = call i32 @fclose(i32* %13)
%15 = load float, float* %3
%16 = fdiv float %15, 1.000000e+03
store float %16, float* %3
%17 = load float, float* %4
%18 = fdiv float %17, 1.000000e+03
store float %18, float* %4
%19 = load float, float* %3
%20 = load float, float* %4
%21 = call i8* @smprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float %19, float %20)
ret i8* %21
}

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"/sys/class/thermal/thermal_zone1/temp\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [17 x i8] c"TEMP %.1fC %.1fC\00"
define i8* @gettemp() {
%1 = alloca float
%2 = alloca float
%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 = tail call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %1
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %1)
%8 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%9 = call i32 @fclose(i32* %3)
%10 = call i32 @fclose(i32* %4)
%11 = load float, float* %1
%12 = fdiv float %11, 1.000000e+03
store float %12, float* %1
%13 = load float, float* %2
%14 = fdiv float %13, 1.000000e+03
store float %14, float* %2
%15 = call i8* @smprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), float %12, float %14)
ret i8* %15
}