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

/* Variables and functions */
int O_NONBLOCK;
int O_RDWR;
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, unsigned int *, int);
int main(int argc, char **argv) {
  int fd;
  unsigned int temp = 0;
  float t;
  fd = open("/dev/ds18b20", O_RDWR | O_NONBLOCK);
  if (fd < 0) {
    printf("can't open!\n");
    return -1;
  }
  read(fd, &temp, sizeof(temp));
  t = temp * 0.0625;
  printf("temp = %d,--->%f<---\n", temp, t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%esi
mov    0x2e83(%rip),%rax
or     (%rax),%esi
lea    0xea2(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1192 <main+0x62>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e1 <main+0xb1>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
mov    0x2e98(%rip),%rax
mov    0x2e89(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xea6(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     11a7 <main+0x67>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1050 <read@plt>
mov    0x4(%rsp),%esi
cvtsi2sd %rsi,%xmm0
mulsd  0xe73(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe79(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/ds18b20\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [13 x i8] c"can't open!\0A\00"
@.str.2 = [22 x i8] c"temp = %d,--->%f<---\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = load i32, i32* @O_RDWR
%10 = load i32, i32* @O_NONBLOCK
%11 = or i32 %9, %10
%12 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
17: ; preds = %2
%18 = load i32, i32* %6
%19 = call i32 @read(i32 %18, i32* %7, i32 4)
%20 = load i32, i32* %7
%21 = uitofp i32 %20 to double
%22 = fmul double %21, 6.250000e-02
%23 = fptrunc double %22 to float
store float %23, float* %8
%24 = load i32, i32* %7
%25 = load float, float* %8
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %24, double %26)
store i32 0, i32* %3
br label %28
28: ; preds = %17, %15
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/ds18b20\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.2 = [22 x i8] c"temp = %d,--->%f<---\0A\00"
@str = [12 x i8] c"can't open!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_NONBLOCK
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %20
12: ; preds = %2
%13 = call i32 @read(i32 %8, i32* %3, i32 4)
%14 = load i32, i32* %3
%15 = uitofp i32 %14 to double
%16 = fmul double %15, 6.250000e-02
%17 = fptrunc double %16 to float
%18 = fpext float %17 to double
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %14, double %18)
br label %20
20: ; preds = %12, %10
%21 = phi i32 [ -1, %10 ], [ 0, %12 ]
ret i32 %21
}