#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 */
scalar_t__ BMP180_Read(int, int, char *);
int BMP180_Write(int, char);
int /*<<< orphan*/ usleep(int);
int BMP180_ReadRawTemperature(long *pUt) {
  int errors = 0;
  char val;
  char data[2];
  val = 0x2E;
  errors = BMP180_Write(0xF4, val);
  usleep(5 * 1000);
  ;
  errors += BMP180_Read(0xF6, 2, data);
  if (errors)
    return 0;
  else
    *pUt = data[0] << 8 | data[1];
  return 1;
}


x86 assembly (clang, -O0):
<BMP180_ReadRawTemperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x2e,-0x15(%rbp)
mov    $0xf4,%edi
movsbl -0x15(%rbp),%esi
call   1040 <BMP180_Write@plt>
mov    %eax,-0x14(%rbp)
mov    $0x1388,%edi
call   1050 <usleep@plt>
lea    -0x17(%rbp),%rdx
mov    $0xf6,%edi
mov    $0x2,%esi
call   1030 <BMP180_Read@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1198 <BMP180_ReadRawTemperature+0x68>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <BMP180_ReadRawTemperature+0x86>
movsbl -0x17(%rbp),%eax
shl    $0x8,%eax
movsbl -0x16(%rbp),%ecx
or     %ecx,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BMP180_ReadRawTemperature>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xf4,%edi
mov    $0x2e,%esi
call   1040 <BMP180_Write@plt>
mov    %eax,%ebp
mov    $0x1388,%edi
call   1050 <usleep@plt>
lea    0x6(%rsp),%rdx
mov    $0xf6,%edi
mov    $0x2,%esi
call   1030 <BMP180_Read@plt>
mov    %rax,%rcx
xor    %eax,%eax
add    %ebp,%ecx
jne    1189 <BMP180_ReadRawTemperature+0x59>
movsbq 0x6(%rsp),%rax
shl    $0x8,%rax
movsbq 0x7(%rsp),%rcx
or     %rax,%rcx
mov    %rcx,(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BMP180_ReadRawTemperature(i64* %0) {
%2 = alloca i32
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i8
%6 = alloca [2 x i8]
store i64* %0, i64** %3
store i32 0, i32* %4
store i8 46, i8* %5
%7 = load i8, i8* %5
%8 = call i32 @BMP180_Write(i32 244, i8 signext %7)
store i32 %8, i32* %4
%9 = call i32 @usleep(i32 5000)
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%11 = call i64 @BMP180_Read(i32 246, i32 2, i8* %10)
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = add nsw i64 %13, %11
%15 = trunc i64 %14 to i32
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %1
store i32 0, i32* %2
br label %31
19: ; preds = %1
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = shl i32 %22, 8
%24 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = or i32 %23, %26
%28 = sext i32 %27 to i64
%29 = load i64*, i64** %3
store i64 %28, i64* %29
br label %30
30: ; preds = %19
store i32 1, i32* %2
br label %31
31: ; preds = %30, %18
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @BMP180_ReadRawTemperature(i64* nocapture writeonly %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @BMP180_Write(i32 244, i8 signext 46)
%5 = tail call i32 @usleep(i32 5000)
%6 = call i64 @BMP180_Read(i32 246, i32 2, i8* %3)
%7 = trunc i64 %6 to i32
%8 = sub i32 0, %7
%9 = icmp eq i32 %4, %8
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = shl nsw i32 %12, 8
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = or i32 %13, %16
%18 = sext i32 %17 to i64
store i64 %18, i64* %0
br label %19
19: ; preds = %1, %10
%20 = phi i32 [ 1, %10 ], [ 0, %1 ]
ret i32 %20
}