#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 */
int /*<<< orphan*/ __delay_us(int);
char ow_read_byte();
int /*<<< orphan*/ ow_reset();
int /*<<< orphan*/ ow_write_byte(int);
int ds_get_temp(void) {
  char temp_low;
  char temp_high;
  int temperature = 0;
  ow_reset();
  __delay_us(300);
  ow_write_byte(0xCC);
  __delay_us(10);
  ow_write_byte(0x44);
  __delay_us(255);
  __delay_us(255);
  __delay_us(255);
  ow_reset();
  __delay_us(300);
  ow_write_byte(0xCC);
  __delay_us(10);
  ow_write_byte(0xBE);
  __delay_us(10);
  temp_low = ow_read_byte();
  __delay_us(1);
  temp_high = ow_read_byte();
  ow_reset();
  temperature = temperature | temp_low;
  temperature = temperature | (temp_high << 8);
  return temperature;
}


x86 assembly (clang, -O0):
<ds_get_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <ow_reset@plt>
mov    $0x12c,%edi
call   1030 <__delay_us@plt>
mov    $0xcc,%edi
call   1060 <ow_write_byte@plt>
mov    $0xa,%edi
call   1030 <__delay_us@plt>
mov    $0x44,%edi
call   1060 <ow_write_byte@plt>
mov    $0xff,%edi
call   1030 <__delay_us@plt>
mov    $0xff,%edi
call   1030 <__delay_us@plt>
mov    $0xff,%edi
call   1030 <__delay_us@plt>
mov    $0x0,%al
call   1040 <ow_reset@plt>
mov    $0x12c,%edi
call   1030 <__delay_us@plt>
mov    $0xcc,%edi
call   1060 <ow_write_byte@plt>
mov    $0xa,%edi
call   1030 <__delay_us@plt>
mov    $0xbe,%edi
call   1060 <ow_write_byte@plt>
mov    $0xa,%edi
call   1030 <__delay_us@plt>
mov    $0x0,%al
call   1050 <ow_read_byte@plt>
mov    %al,-0x1(%rbp)
mov    $0x1,%edi
call   1030 <__delay_us@plt>
mov    $0x0,%al
call   1050 <ow_read_byte@plt>
mov    %al,-0x2(%rbp)
mov    $0x0,%al
call   1040 <ow_reset@plt>
mov    -0x8(%rbp),%eax
movsbl -0x1(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
movsbl -0x2(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ds_get_temp>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <ow_reset@plt>
mov    $0x12c,%edi
call   1030 <__delay_us@plt>
mov    $0xcc,%edi
call   1060 <ow_write_byte@plt>
mov    $0xa,%edi
call   1030 <__delay_us@plt>
mov    $0x44,%edi
call   1060 <ow_write_byte@plt>
mov    $0xff,%edi
call   1030 <__delay_us@plt>
mov    $0xff,%edi
call   1030 <__delay_us@plt>
mov    $0xff,%edi
call   1030 <__delay_us@plt>
xor    %eax,%eax
call   1040 <ow_reset@plt>
mov    $0x12c,%edi
call   1030 <__delay_us@plt>
mov    $0xcc,%edi
call   1060 <ow_write_byte@plt>
mov    $0xa,%edi
call   1030 <__delay_us@plt>
mov    $0xbe,%edi
call   1060 <ow_write_byte@plt>
mov    $0xa,%edi
call   1030 <__delay_us@plt>
xor    %eax,%eax
call   1050 <ow_read_byte@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   1030 <__delay_us@plt>
xor    %eax,%eax
call   1050 <ow_read_byte@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <ow_reset@plt>
movsbl %bpl,%ecx
movsbl %bl,%eax
shl    $0x8,%eax
or     %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ds_get_temp() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %3
%4 = call i32 (...) @ow_reset()
%5 = call i32 @__delay_us(i32 300)
%6 = call i32 @ow_write_byte(i32 204)
%7 = call i32 @__delay_us(i32 10)
%8 = call i32 @ow_write_byte(i32 68)
%9 = call i32 @__delay_us(i32 255)
%10 = call i32 @__delay_us(i32 255)
%11 = call i32 @__delay_us(i32 255)
%12 = call i32 (...) @ow_reset()
%13 = call i32 @__delay_us(i32 300)
%14 = call i32 @ow_write_byte(i32 204)
%15 = call i32 @__delay_us(i32 10)
%16 = call i32 @ow_write_byte(i32 190)
%17 = call i32 @__delay_us(i32 10)
%18 = call signext i8 (...) @ow_read_byte()
store i8 %18, i8* %1
%19 = call i32 @__delay_us(i32 1)
%20 = call signext i8 (...) @ow_read_byte()
store i8 %20, i8* %2
%21 = call i32 (...) @ow_reset()
%22 = load i32, i32* %3
%23 = load i8, i8* %1
%24 = sext i8 %23 to i32
%25 = or i32 %22, %24
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = shl i32 %28, 8
%30 = or i32 %26, %29
store i32 %30, i32* %3
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @ds_get_temp() {
%1 = tail call i32 (...) @ow_reset()
%2 = tail call i32 @__delay_us(i32 300)
%3 = tail call i32 @ow_write_byte(i32 204)
%4 = tail call i32 @__delay_us(i32 10)
%5 = tail call i32 @ow_write_byte(i32 68)
%6 = tail call i32 @__delay_us(i32 255)
%7 = tail call i32 @__delay_us(i32 255)
%8 = tail call i32 @__delay_us(i32 255)
%9 = tail call i32 (...) @ow_reset()
%10 = tail call i32 @__delay_us(i32 300)
%11 = tail call i32 @ow_write_byte(i32 204)
%12 = tail call i32 @__delay_us(i32 10)
%13 = tail call i32 @ow_write_byte(i32 190)
%14 = tail call i32 @__delay_us(i32 10)
%15 = tail call signext i8 (...) @ow_read_byte()
%16 = tail call i32 @__delay_us(i32 1)
%17 = tail call signext i8 (...) @ow_read_byte()
%18 = tail call i32 (...) @ow_reset()
%19 = sext i8 %15 to i32
%20 = sext i8 %17 to i32
%21 = shl nsw i32 %20, 8
%22 = or i32 %21, %19
ret i32 %22
}