#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char buff1[10], buff2[10];
  FILE *f = fopen("/sys/class/power_supply/BAT0/voltage_now", "r");
  if (f != NULL) {
    fgets(buff1, 10, f);
    fclose(f);
    f = fopen("/sys/class/power_supply/BAT0/current_now", "r");
    fgets(buff2, 10, f);
    fclose(f);
    float potencia =
        (float)atoi(buff1) / 100000 * (float)atoi(buff2) / 10000000;
    if (potencia > 30)
      strcpy(buff2, "\"red\"");
    else
      strcpy(buff2, "\"black\"");
    f = fopen("/sys/devices/platform/coretemp.0/temp2_input", "r");
    fgets(buff1, 5, f);
    fclose(f);
    float temper = (float)atoi(buff1) / 100;
    if (temper > 70)
      strcpy(buff1, "\"red\"");
    else
      strcpy(buff1, "\"green\"");
    printf("<txt><span fgcolor=%s>%.2fW</span>\n<span "
           "fgcolor=%s>%.1f°C</span></txt>",
           buff2, potencia, buff1, temper);
    return 0;
  } else
    printf("Sem Bateria\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1320 <main+0x1c0>
lea    -0xe(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe8c(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0xe(%rbp),%rdi
call   1080 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  0xe14(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <atoi@plt>
movss  -0x2c(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
movss  0xde8(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  0xdce(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1250 <main+0xf0>
lea    -0x18(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1260 <main+0x100>
lea    -0x18(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xe0f(%rip),%rdi
lea    0xdcf(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0xe(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x5,%esi
call   1060 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0xe(%rbp),%rdi
call   1080 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  0xd68(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  0xd4e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    12dc <main+0x17c>
lea    -0xe(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12ec <main+0x18c>
lea    -0xe(%rbp),%rdi
lea    0xdbc(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x18(%rbp),%rsi
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    -0xe(%rbp),%rdx
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd9e(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1335 <main+0x1d5>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xe90(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12db <main+0x16b>
mov    %rax,%rbx
lea    0x16(%rsp),%r12
mov    %r12,%rdi
mov    $0xa,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xe7f(%rip),%rdi
lea    0xe76(%rip),%r15
mov    %r15,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1090 <atoi@plt>
cvtsi2ss %rax,%xmm0
divss  0xdfc(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
call   1090 <atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0x4(%rsp),%xmm0
divss  0xddc(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
ucomiss 0xdd3(%rip),%xmm0
lea    0xe2c(%rip),%r13
lea    0xe2b(%rip),%rsi
cmova  %r13,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe20(%rip),%rdi
mov    %r15,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x5,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1090 <atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  0xd7b(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
ucomiss 0xd72(%rip),%xmm0
lea    0xdfe(%rip),%rsi
cmova  %r13,%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xddf(%rip),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    $0x2,%al
call   1060 <printf@plt>
jmp    12e7 <main+0x177>
lea    0xe12(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [41 x i8] c"/sys/class/power_supply/BAT0/voltage_now\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [41 x i8] c"/sys/class/power_supply/BAT0/current_now\00"
@.str.3 = [6 x i8] c"\22red\22\00"
@.str.4 = [8 x i8] c"\22black\22\00"
@.str.5 = [45 x i8] c"/sys/devices/platform/coretemp.0/temp2_input\00"
@.str.6 = [8 x i8] c"\22green\22\00"
@.str.7 = [73 x i8] c"<txt><span fgcolor=%s>%.2fW</span>\0A<span fgcolor=%s>%.1f\C2\B0C</span></txt>\00"
@.str.8 = [13 x i8] c"Sem Bateria\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32*
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %66
10: ; preds = %0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%12 = load i32*, i32** %4
%13 = call i32 @fgets(i8* %11, i32 10, i32* %12)
%14 = load i32*, i32** %4
%15 = call i32 @fclose(i32* %14)
%16 = call i32* @fopen(i8* getelementptr inbounds ([41 x i8], [41 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* %16, i32** %4
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = call i32 @fgets(i8* %17, i32 10, i32* %18)
%20 = load i32*, i32** %4
%21 = call i32 @fclose(i32* %20)
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%23 = call i64 @atoi(i8* %22)
%24 = sitofp i64 %23 to float
%25 = fdiv float %24, 1.000000e+05
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%27 = call i64 @atoi(i8* %26)
%28 = sitofp i64 %27 to float
%29 = fmul float %25, %28
%30 = fdiv float %29, 1.000000e+07
store float %30, float* %5
%31 = load float, float* %5
%32 = fcmp ogt float %31, 3.000000e+01
br i1 %32, label %33, label %36
33: ; preds = %10
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %39
36: ; preds = %10
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
%40 = call i32* @fopen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %40, i32** %4
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%42 = load i32*, i32** %4
%43 = call i32 @fgets(i8* %41, i32 5, i32* %42)
%44 = load i32*, i32** %4
%45 = call i32 @fclose(i32* %44)
%46 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%47 = call i64 @atoi(i8* %46)
%48 = sitofp i64 %47 to float
%49 = fdiv float %48, 1.000000e+02
store float %49, float* %6
%50 = load float, float* %6
%51 = fcmp ogt float %50, 7.000000e+01
br i1 %51, label %52, label %55
52: ; preds = %39
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%54 = call i32 @strcpy(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %58
55: ; preds = %39
%56 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%57 = call i32 @strcpy(i8* %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %58
58: ; preds = %55, %52
%59 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%60 = load float, float* %5
%61 = fpext float %60 to double
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%63 = load float, float* %6
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.7, i64 0, i64 0), i8* %59, double %61, i8* %62, double %64)
store i32 0, i32* %1
br label %69
66: ; preds = %0
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %68
68: ; preds = %66
store i32 0, i32* %1
br label %69
69: ; preds = %68, %58
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
@.str = [41 x i8] c"/sys/class/power_supply/BAT0/voltage_now\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [41 x i8] c"/sys/class/power_supply/BAT0/current_now\00"
@.str.3 = [6 x i8] c"\22red\22\00"
@.str.4 = [8 x i8] c"\22black\22\00"
@.str.5 = [45 x i8] c"/sys/devices/platform/coretemp.0/temp2_input\00"
@.str.6 = [8 x i8] c"\22green\22\00"
@.str.7 = [73 x i8] c"<txt><span fgcolor=%s>%.2fW</span>\0A<span fgcolor=%s>%.1f\C2\B0C</span></txt>\00"
@str = [12 x i8] c"Sem Bateria\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %35, label %7
7: ; preds = %0
%8 = call i32 @fgets(i8* %3, i32 10, i32* %5)
%9 = call i32 @fclose(i32* %5)
%10 = call i32* @fopen(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @fgets(i8* %4, i32 10, i32* %10)
%12 = call i32 @fclose(i32* %10)
%13 = call i64 @atoi(i8* %3)
%14 = sitofp i64 %13 to float
%15 = fdiv float %14, 1.000000e+05
%16 = call i64 @atoi(i8* %4)
%17 = sitofp i64 %16 to float
%18 = fmul float %15, %17
%19 = fdiv float %18, 1.000000e+07
%20 = fcmp ogt float %19, 3.000000e+01
%21 = select i1 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%22 = call i32 @strcpy(i8* %4, i8* %21)
%23 = call i32* @fopen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @fgets(i8* %3, i32 5, i32* %23)
%25 = call i32 @fclose(i32* %23)
%26 = call i64 @atoi(i8* %3)
%27 = sitofp i64 %26 to float
%28 = fdiv float %27, 1.000000e+02
%29 = fcmp ogt float %28, 7.000000e+01
%30 = select i1 %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0)
%31 = call i32 @strcpy(i8* %3, i8* %30)
%32 = fpext float %19 to double
%33 = fpext float %28 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.7, i64 0, i64 0), i8* %4, double %32, i8* %3, double %33)
br label %37
35: ; preds = %0
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %35, %7
ret i32 0
}