#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
void get_CPU_temperature(char *thz0, char *thz1) {
  FILE *f;
  char c;
  int i0 = 0;
  int i1 = 0;
  f = fopen("/sys/class/thermal/thermal_zone0/temp", "rt");
  while ((c = fgetc(f)) != EOF) {
    thz0[i0] = c;
    i0++;
  }
  thz0[5] = '\0';
  fclose(f);
}


x86 assembly (clang, -O0):
<get_CPU_temperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeab(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e6d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a2 <get_CPU_temperature+0x72>
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1165 <get_CPU_temperature+0x35>
mov    -0x8(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_CPU_temperature>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xebe(%rip),%rdi
lea    0xedd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e88(%rip),%r15
cmp    (%r15),%al
je     1183 <get_CPU_temperature+0x53>
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %al,(%rbx)
mov    %r12,%rdi
call   1040 <fgetc@plt>
add    $0x1,%rbx
cmp    (%r15),%al
jne    1170 <get_CPU_temperature+0x40>
movb   $0x0,0x5(%r14)
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"/sys/class/thermal/thermal_zone0/temp\00"
@.str.1 = [3 x i8] c"rt\00"
@EOF = global i8 0
define void @get_CPU_temperature(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %5
br label %10
10: ; preds = %17, %2
%11 = load i32*, i32** %5
%12 = call signext i8 @fgetc(i32* %11)
store i8 %12, i8* %6
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %25
17: ; preds = %10
%18 = load i8, i8* %6
%19 = load i8*, i8** %3
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %10
25: ; preds = %10
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 5
store i8 0, i8* %27
%28 = load i32*, i32** %5
%29 = call i32 @fclose(i32* %28)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"/sys/class/thermal/thermal_zone0/temp\00"
@.str.1 = [3 x i8] c"rt\00"
@EOF = global i8 0
define void @get_CPU_temperature(i8* nocapture writeonly %0, i8* nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call signext i8 @fgetc(i32* %3)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %15, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %11, %7 ], [ 0, %2 ]
%9 = phi i8 [ %12, %7 ], [ %4, %2 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %9, i8* %10
%11 = add nuw i64 %8, 1
%12 = tail call signext i8 @fgetc(i32* %3)
%13 = load i8, i8* @EOF
%14 = icmp eq i8 %12, %13
br i1 %14, label %15, label %7
15: ; preds = %7, %2
%16 = getelementptr inbounds i8, i8* %0, i64 5
store i8 0, i8* %16
%17 = tail call i32 @fclose(i32* %3)
ret void
}