#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 uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ calculate(int, int, int /*<<< orphan*/ *,
                             int /*<<< orphan*/ *);
int read_value(int);
int ms5803_read(int32_t *pressure, int32_t *temperature) {
  uint32_t d1;
  uint32_t d2;
  d1 = read_value(0x48);
  if (d1 == -1)
    return -1;
  d2 = read_value(0x58);
  if (d2 == -1)
    return -1;
  calculate(d1, d2, pressure, temperature);
  return 0;
}


x86 assembly (clang, -O0):
<ms5803_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x48,%edi
call   1030 <read_value@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1153 <ms5803_read+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    1190 <ms5803_read+0x70>
mov    $0x58,%edi
call   1030 <read_value@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1176 <ms5803_read+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    1190 <ms5803_read+0x70>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <calculate@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ms5803_read>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x48,%edi
call   1030 <read_value@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%eax
je     1163 <ms5803_read+0x43>
mov    %eax,%ebx
mov    $0x58,%edi
call   1030 <read_value@plt>
cmp    $0xffffffff,%eax
je     1163 <ms5803_read+0x43>
mov    %ebx,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <calculate@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ms5803_read(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = call i32 @read_value(i32 72)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %23
12: ; preds = %2
%13 = call i32 @read_value(i32 88)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %3
br label %23
17: ; preds = %12
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = load i32*, i32** %4
%21 = load i32*, i32** %5
%22 = call i32 @calculate(i32 %18, i32 %19, i32* %20, i32* %21)
store i32 0, i32* %3
br label %23
23: ; preds = %17, %16, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @ms5803_read(i32* %0, i32* %1) {
%3 = tail call i32 @read_value(i32 72)
%4 = icmp eq i32 %3, -1
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @read_value(i32 88)
%7 = icmp eq i32 %6, -1
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @calculate(i32 %3, i32 %6, i32* %0, i32* %1)
br label %10
10: ; preds = %5, %2, %8
%11 = phi i32 [ 0, %8 ], [ -1, %2 ], [ -1, %5 ]
ret i32 %11
}