#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*/ fprintf(int /*<<< orphan*/ *, char *, float);
int fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ system(char *);
int main() {
  float systemp, millideg;
  FILE *thermal;
  FILE *fout;
  int n, deg;
  thermal = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
  fout = fopen("temp.txt", "w");
  n = fscanf(thermal, "%f", &millideg);
  fclose(thermal);
  systemp = millideg / 1000;
  printf("CPU temperature is %f degrees C\n", systemp);
  fprintf(fout, "%f \n", systemp);
  fclose(fout);
  system("");
  system("flite -voice slt -t \"My processor temperature is\" ");
  system("flite -voice slt -f \"temp.txt\" ");
  system("flite -voice slt -t \" degrees Celsius\" ");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
lea    0xead(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe9f(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8f(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <fscanf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movss  -0xc(%rbp),%xmm0
movss  0xe36(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
movss  -0x8(%rbp),%xmm0
lea    0xe67(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe56(%rip),%rdi
call   1040 <system@plt>
lea    0xe4b(%rip),%rdi
call   1040 <system@plt>
lea    0xe72(%rip),%rdi
call   1040 <system@plt>
lea    0xe86(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe99(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rdi
lea    0xead(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xea0(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
movss  0x4(%rsp),%xmm0
divss  0xe46(%rip),%xmm0
movss  %xmm0,(%rsp)
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
lea    0xe89(%rip),%rsi
mov    %r14,%rdi
movss  (%rsp),%xmm0
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xe71(%rip),%rdi
call   1040 <system@plt>
lea    0xe66(%rip),%rdi
call   1040 <system@plt>
lea    0xe8d(%rip),%rdi
call   1040 <system@plt>
lea    0xea1(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [9 x i8] c"temp.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [33 x i8] c"CPU temperature is %f degrees C\0A\00"
@.str.6 = [5 x i8] c"%f \0A\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [51 x i8] c"flite -voice slt -t \22My processor temperature is\22 \00"
@.str.9 = [32 x i8] c"flite -voice slt -f \22temp.txt\22 \00"
@.str.10 = [40 x i8] c"flite -voice slt -t \22 degrees Celsius\22 \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = 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* %8, i32** %4
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %4
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
store i32 %11, i32* %6
%12 = load i32*, i32** %4
%13 = call i32 @fclose(i32* %12)
%14 = load float, float* %3
%15 = fdiv float %14, 1.000000e+03
store float %15, float* %2
%16 = load float, float* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), float %16)
%18 = load i32*, i32** %5
%19 = load float, float* %2
%20 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), float %19)
%21 = load i32*, i32** %5
%22 = call i32 @fclose(i32* %21)
%23 = call i32 @system(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0))
%25 = call i32 @system(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%26 = call i32 @system(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
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 = [9 x i8] c"temp.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [33 x i8] c"CPU temperature is %f degrees C\0A\00"
@.str.6 = [5 x i8] c"%f \0A\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [51 x i8] c"flite -voice slt -t \22My processor temperature is\22 \00"
@.str.9 = [32 x i8] c"flite -voice slt -f \22temp.txt\22 \00"
@.str.10 = [40 x i8] c"flite -voice slt -t \22 degrees Celsius\22 \00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %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 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%6 = call i32 @fclose(i32* %3)
%7 = load float, float* %1
%8 = fdiv float %7, 1.000000e+03
%9 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), float %8)
%10 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), float %8)
%11 = call i32 @fclose(i32* %4)
%12 = call i32 @system(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 @system(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%15 = call i32 @system(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}