#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 */

/* Variables and functions */
double atoi(char const *);
char *om_battery_temperature_path();
char *om_sysfs_readfile(char const *);
int om_battery_temperature_get(float *temperature) {
  const char *path = om_battery_temperature_path();
  if (path == NULL)
    return -1;
  const char *val = om_sysfs_readfile(path);
  if (val == NULL)
    return -1;
  *temperature = atoi(val) / 10.0;
  return 0;
}


x86 assembly (clang, -O0):
<om_battery_temperature_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <om_battery_temperature_path@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115e <om_battery_temperature_get+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <om_battery_temperature_get+0x7a>
mov    -0x18(%rbp),%rdi
call   1030 <om_sysfs_readfile@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1182 <om_battery_temperature_get+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <om_battery_temperature_get+0x7a>
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<om_battery_temperature_get>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <om_battery_temperature_path@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     116e <om_battery_temperature_get+0x3e>
mov    %rax,%rdi
call   1030 <om_sysfs_readfile@plt>
test   %rax,%rax
je     116e <om_battery_temperature_get+0x3e>
mov    %rax,%rdi
call   1050 <atoi@plt>
divsd  0xe9c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @om_battery_temperature_get(float* %0) {
%2 = alloca i32
%3 = alloca float*
%4 = alloca i8*
%5 = alloca i8*
store float* %0, float** %3
%6 = call i8* (...) @om_battery_temperature_path()
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %22
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i8* @om_sysfs_readfile(i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 -1, i32* %2
br label %22
16: ; preds = %10
%17 = load i8*, i8** %5
%18 = call double @atoi(i8* %17)
%19 = fdiv double %18, 1.000000e+01
%20 = fptrunc double %19 to float
%21 = load float*, float** %3
store float %20, float* %21
store i32 0, i32* %2
br label %22
22: ; preds = %16, %15, %9
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @om_battery_temperature_get(float* nocapture writeonly %0) {
%2 = tail call i8* (...) @om_battery_temperature_path()
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i8* @om_sysfs_readfile(i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call double @atoi(i8* %5)
%9 = fdiv double %8, 1.000000e+01
%10 = fptrunc double %9 to float
store float %10, float* %0
br label %11
11: ; preds = %7, %4, %1
%12 = phi i32 [ -1, %1 ], [ 0, %7 ], [ -1, %4 ]
ret i32 %12
}