#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 *, float);
int main(void) {
  char buff1[10], buff2[10];
  FILE *f = fopen("/sys/class/power_supply/BAT0/voltage_now", "r");
  fgets(buff1, 10, f);
  fclose(f);
  f = fopen("/sys/class/power_supply/BAT0/current_now", "r");
  fgets(buff2, 10, f);
  fclose(f);
  printf("%.2fW \n",
         (float)atoi(buff1) / 100000 * (float)atoi(buff2) / 10000000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
lea    0xec4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0xe(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xa,%esi
call   1050 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe9b(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xa,%esi
call   1050 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0xe(%rbp),%rdi
call   1070 <atoi@plt>
cvtsi2ss %rax,%xmm0
movss  0xe2b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <atoi@plt>
movss  -0x24(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
movss  0xdff(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xea8(%rip),%rdi
lea    0xeca(%rip),%r14
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0x16(%rsp),%r15
mov    %r15,%rdi
mov    $0xa,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe9d(%rip),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1070 <atoi@plt>
cvtsi2ss %rax,%xmm0
divss  0xe2d(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r14,%rdi
call   1070 <atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0x8(%rsp),%xmm0
divss  0xe0d(%rip),%xmm0
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
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 = [8 x i8] c"%.2fW \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32*
store i32 0, i32* %1
%5 = 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* %5, i32** %4
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = load i32*, i32** %4
%8 = call i32 @fgets(i8* %6, i32 10, i32* %7)
%9 = load i32*, i32** %4
%10 = call i32 @fclose(i32* %9)
%11 = 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* %11, i32** %4
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i32 @fgets(i8* %12, i32 10, i32* %13)
%15 = load i32*, i32** %4
%16 = call i32 @fclose(i32* %15)
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%18 = call i64 @atoi(i8* %17)
%19 = sitofp i64 %18 to float
%20 = fdiv float %19, 1.000000e+05
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%22 = call i64 @atoi(i8* %21)
%23 = sitofp i64 %22 to float
%24 = fmul float %20, %23
%25 = fdiv float %24, 1.000000e+07
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), float %25)
ret i32 0
}

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 = [8 x i8] c"%.2fW \0A\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 = call i32 @fgets(i8* %3, i32 10, i32* %5)
%7 = call i32 @fclose(i32* %5)
%8 = 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))
%9 = call i32 @fgets(i8* %4, i32 10, i32* %8)
%10 = call i32 @fclose(i32* %8)
%11 = call i64 @atoi(i8* %3)
%12 = sitofp i64 %11 to float
%13 = fdiv float %12, 1.000000e+05
%14 = call i64 @atoi(i8* %4)
%15 = sitofp i64 %14 to float
%16 = fmul float %13, %15
%17 = fdiv float %16, 1.000000e+07
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), float %17)
ret i32 0
}