#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*/ uint32_t;
typedef int /*<<< orphan*/ timebuf;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ die(char *, ...);
int /*<<< orphan*/ errno;
struct tm *gmtime(int /*<<< orphan*/ *);
double ntohl(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ recv_acknak(int);
double scale_pressure_sensor(double);
int /*<<< orphan*/ send_command(int, char);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void print_status(int fd) {
  uint32_t buf[16];
  int rc;
  char timebuf[32];
  struct tm *tm;
  time_t t;
  t = time(NULL);
  if (!(tm = gmtime(&t)))
    die("localtime");
  if (strftime(timebuf, sizeof(timebuf), "%FT%TZ", tm) == 0)
    die("strftime");
  send_command(fd, 'I');
  rc = read(fd, buf, sizeof(buf));
  if (rc < 0)
    die("read: %s\n", strerror(errno));
  if (rc < sizeof(buf))
    die("read: timed out reading 16 32-bit integers\n");
  recv_acknak(fd);
  printf("#time\t\t\tccd-C\tplate-C\tccd-Torr\n");
  printf("%s\t%.1f\t%.1f\t%.1f\n", timebuf, 0.1 * ntohl(buf[0]) - 273.15,
         0.1 * ntohl(buf[1]) - 273.15, scale_pressure_sensor(ntohl(buf[2])));
}


x86 assembly (clang, -O0):
<print_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x8c(%rbp)
lea    -0x8c(%rbp),%rdi
call   10b0 <gmtime@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    11f8 <print_status+0x48>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rcx
mov    $0x20,%esi
lea    0xe0b(%rip),%rdx
call   1080 <strftime@plt>
cmp    $0x0,%rax
jne    122c <print_status+0x7c>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
mov    -0x4(%rbp),%edi
mov    $0x49,%esi
call   1090 <send_command@plt>
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x40,%edx
call   1060 <read@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    1275 <print_status+0xc5>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
movslq -0x54(%rbp),%rax
cmp    $0x40,%rax
jae    1291 <print_status+0xe1>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
mov    -0x4(%rbp),%edi
call   1030 <recv_acknak@plt>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x50(%rbp),%edi
call   10c0 <ntohl@plt>
movsd  0xd3e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd3a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x4c(%rbp),%edi
call   10c0 <ntohl@plt>
movsd  0xd16(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd12(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x48(%rbp),%edi
call   10c0 <ntohl@plt>
call   1040 <scale_pressure_sensor@plt>
mov    -0xa8(%rbp),%rsi
movsd  -0xa0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x98(%rbp),%xmm0
ff
lea    0xd50(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_status>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
mov    %edi,%ebp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   10c0 <gmtime@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11f6 <print_status+0x36>
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
lea    0xe1d(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x20,%esi
mov    %rbx,%rcx
call   1090 <strftime@plt>
test   %rax,%rax
jne    1222 <print_status+0x62>
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
mov    %ebp,%edi
mov    $0x49,%esi
call   10a0 <send_command@plt>
lea    0x40(%rsp),%rsi
mov    %ebp,%edi
mov    $0x40,%edx
call   1070 <read@plt>
test   %eax,%eax
js     1258 <print_status+0x98>
cmp    $0x3f,%eax
ja     1276 <print_status+0xb6>
lea    0xde5(%rip),%rdi
xor    %eax,%eax
call   10b0 <die@plt>
jmp    1276 <print_status+0xb6>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xdbd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10b0 <die@plt>
mov    %ebp,%edi
call   1030 <recv_acknak@plt>
lea    0xdef(%rip),%rdi
call   1040 <puts@plt>
mov    0x40(%rsp),%edi
call   10d0 <ntohl@plt>
mulsd  0xd66(%rip),%xmm0
addsd  0xd66(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0x44(%rsp),%edi
call   10d0 <ntohl@plt>
movsd  0xd47(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xd43(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    0x48(%rsp),%edi
call   10d0 <ntohl@plt>
call   1050 <scale_pressure_sensor@plt>
movapd %xmm0,%xmm2
lea    0xd7c(%rip),%rdi
lea    0x20(%rsp),%rsi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x3,%al
call   1060 <printf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [10 x i8] c"localtime\00"
@.str.1 = [7 x i8] c"%FT%TZ\00"
@.str.2 = [9 x i8] c"strftime\00"
@.str.3 = [10 x i8] c"read: %s\0A\00"
@errno = global i32 0
@.str.4 = [44 x i8] c"read: timed out reading 16 32-bit integers\0A\00"
@.str.5 = [32 x i8] c"#time\09\09\09ccd-C\09plate-C\09ccd-Torr\0A\00"
@.str.6 = [19 x i8] c"%s\09%.1f\09%.1f\09%.1f\0A\00"
define void @print_status(i32 %0) {
%2 = alloca i32
%3 = alloca [16 x i32]
%4 = alloca i32
%5 = alloca [32 x i8]
%6 = alloca %struct.tm*
%7 = alloca i32
store i32 %0, i32* %2
%8 = call i32 @time(i32* null)
store i32 %8, i32* %7
%9 = call %struct.tm* @gmtime(i32* %7)
store %struct.tm* %9, %struct.tm** %6
%10 = icmp ne %struct.tm* %9, null
br i1 %10, label %13, label %11
11: ; preds = %1
%12 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%15 = load %struct.tm*, %struct.tm** %6
%16 = call i64 @strftime(i8* %14, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
%21 = load i32, i32* %2
%22 = call i32 @send_command(i32 %21, i8 signext 73)
%23 = load i32, i32* %2
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%25 = call i32 @read(i32 %23, i32* %24, i32 64)
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %20
%29 = load i32, i32* @errno
%30 = call i32 @strerror(i32 %29)
%31 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %20
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = icmp ult i64 %34, 64
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
%39 = load i32, i32* %2
%40 = call i32 @recv_acknak(i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%44 = load i32, i32* %43
%45 = call double @ntohl(i32 %44)
%46 = call double @llvm.fmuladd.f64(double 1.000000e-01, double %45, double -2.731500e+02)
%47 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call double @ntohl(i32 %48)
%50 = call double @llvm.fmuladd.f64(double 1.000000e-01, double %49, double -2.731500e+02)
%51 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 2
%52 = load i32, i32* %51
%53 = call double @ntohl(i32 %52)
%54 = call double @scale_pressure_sensor(double %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %42, double %46, double %50, double %54)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [10 x i8] c"localtime\00"
@.str.1 = [7 x i8] c"%FT%TZ\00"
@.str.2 = [9 x i8] c"strftime\00"
@.str.3 = [10 x i8] c"read: %s\0A\00"
@errno = global i32 0
@.str.4 = [44 x i8] c"read: timed out reading 16 32-bit integers\0A\00"
@.str.6 = [19 x i8] c"%s\09%.1f\09%.1f\09%.1f\0A\00"
@str = [31 x i8] c"#time\09\09\09ccd-C\09plate-C\09ccd-Torr\00"
define void @print_status(i32 %0) {
%2 = alloca [16 x i32]
%3 = alloca [32 x i8]
%4 = alloca i32
%5 = bitcast [16 x i32]* %2 to i8*
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = tail call i32 @time(i32* null)
store i32 %8, i32* %4
%9 = call %struct.tm* @gmtime(i32* %4)
%10 = icmp eq %struct.tm* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = call i64 @strftime(i8* %6, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %9)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = call i32 @send_command(i32 %0, i8 signext 73)
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%21 = call i32 @read(i32 %0, i32* %20, i32 64)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* @errno
%25 = call i32 @strerror(i32 %24)
%26 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %31
27: ; preds = %18
%28 = icmp ult i32 %21, 64
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %23, %29, %27
%32 = call i32 @recv_acknak(i32 %0)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%34 = load i32, i32* %20
%35 = call double @ntohl(i32 %34)
%36 = call double @llvm.fmuladd.f64(double %35, double 1.000000e-01, double -2.731500e+02)
%37 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 1
%38 = load i32, i32* %37
%39 = call double @ntohl(i32 %38)
%40 = call double @llvm.fmuladd.f64(double %39, double 1.000000e-01, double -2.731500e+02)
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 2
%42 = load i32, i32* %41
%43 = call double @ntohl(i32 %42)
%44 = call double @scale_pressure_sensor(double %43)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %6, double %36, double %40, double %44)
ret void
}