#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 NAN;
double c2f(double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
double w1_therm_get(char *);
int main(int argc, char *argv[]) {
  double val;
  if (argc != 2) {
    fprintf(stderr, "Usage: w1util addr\n");
    exit(1);
  }
  val = w1_therm_get(argv[1]);
  if (val != NAN)
    printf("%f\n", c2f(val));
  exit(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)
cmpl   $0x2,-0x8(%rbp)
je     118f <main+0x3f>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <w1_therm_get@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2e4b(%rip),%rax
ucomisd (%rax),%xmm0
jne    11c2 <main+0x72>
jp     11c2 <main+0x72>
jmp    11d8 <main+0x88>
movsd  -0x18(%rbp),%xmm0
call   1030 <c2f@plt>
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1186 <main+0x36>
mov    0x8(%rsi),%rdi
call   1060 <w1_therm_get@plt>
mov    0x2e92(%rip),%rax
ucomisd (%rax),%xmm0
jne    116e <main+0x1e>
jnp    117f <main+0x2f>
call   1030 <c2f@plt>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: w1util addr\0A\00"
@NAN = global double 0.000000e+00
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call double @w1_therm_get(i8* %16)
store double %17, double* %6
%18 = load double, double* %6
%19 = load double, double* @NAN
%20 = fcmp une double %18, %19
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = load double, double* %6
%23 = call double @c2f(double %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %23)
br label %25
25: ; preds = %21, %13
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: w1util addr\0A\00"
@NAN = global double 0.000000e+00
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call double @w1_therm_get(i8* %10)
%12 = load double, double* @NAN
%13 = fcmp une double %11, %12
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = tail call double @c2f(double %11)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %15)
br label %17
17: ; preds = %14, %8
%18 = tail call i32 @exit(i32 0)
unreachable
}