#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 */
unsigned char ds18b20ReadByte();
scalar_t__ ds18b20ReadTemperature();
scalar_t__ ds18b20Start();
int Ds18b20GetTemperature() {
  int temp;
  unsigned char tempH, tempL;
  if (ds18b20Start())
    return -55;
  if (ds18b20ReadTemperature())
    return -54;
  tempL = ds18b20ReadByte();
  tempH = ds18b20ReadByte();
  temp = tempH;
  temp = temp << 8;
  temp = temp + tempL;
  return temp;
}


x86 assembly (clang, -O0):
<Ds18b20GetTemperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <ds18b20Start@plt>
cmp    $0x0,%rax
je     1155 <Ds18b20GetTemperature+0x25>
movl   $0xffffffc9,-0x4(%rbp)
jmp    11a8 <Ds18b20GetTemperature+0x78>
mov    $0x0,%al
call   1040 <ds18b20ReadTemperature@plt>
cmp    $0x0,%rax
je     1172 <Ds18b20GetTemperature+0x42>
movl   $0xffffffca,-0x4(%rbp)
jmp    11a8 <Ds18b20GetTemperature+0x78>
mov    $0x0,%al
call   1030 <ds18b20ReadByte@plt>
mov    %al,-0xa(%rbp)
mov    $0x0,%al
call   1030 <ds18b20ReadByte@plt>
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
movzbl -0xa(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ds18b20GetTemperature>:
push   %rbx
xor    %eax,%eax
call   1050 <ds18b20Start@plt>
mov    %rax,%rcx
mov    $0xffffffc9,%eax
test   %rcx,%rcx
je     1147 <Ds18b20GetTemperature+0x17>
pop    %rbx
ret
xor    %eax,%eax
call   1040 <ds18b20ReadTemperature@plt>
mov    %rax,%rcx
mov    $0xffffffca,%eax
test   %rcx,%rcx
jne    1145 <Ds18b20GetTemperature+0x15>
xor    %eax,%eax
call   1030 <ds18b20ReadByte@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <ds18b20ReadByte@plt>
movzbl %al,%ecx
shl    $0x8,%ecx
movzbl %bl,%eax
or     %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @Ds18b20GetTemperature() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
%5 = call i64 (...) @ds18b20Start()
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -55, i32* %1
br label %24
8: ; preds = %0
%9 = call i64 (...) @ds18b20ReadTemperature()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 -54, i32* %1
br label %24
12: ; preds = %8
%13 = call zeroext i8 (...) @ds18b20ReadByte()
store i8 %13, i8* %4
%14 = call zeroext i8 (...) @ds18b20ReadByte()
store i8 %14, i8* %3
%15 = load i8, i8* %3
%16 = zext i8 %15 to i32
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = shl i32 %17, 8
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = add nsw i32 %19, %21
store i32 %22, i32* %2
%23 = load i32, i32* %2
store i32 %23, i32* %1
br label %24
24: ; preds = %12, %11, %7
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
define i32 @Ds18b20GetTemperature() {
%1 = tail call i64 (...) @ds18b20Start()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = tail call i64 (...) @ds18b20ReadTemperature()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = tail call zeroext i8 (...) @ds18b20ReadByte()
%8 = tail call zeroext i8 (...) @ds18b20ReadByte()
%9 = zext i8 %8 to i32
%10 = shl nuw nsw i32 %9, 8
%11 = zext i8 %7 to i32
%12 = or i32 %10, %11
br label %13
13: ; preds = %3, %0, %6
%14 = phi i32 [ %12, %6 ], [ -55, %0 ], [ -54, %3 ]
ret i32 %14
}