#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
scalar_t__ gpio_iic_Gack();
int /*<<< orphan*/ gpio_iic_Pack();
int /*<<< orphan*/ gpio_iic_Pnack();
int /*<<< orphan*/ gpio_iic_read(int *);
int /*<<< orphan*/ gpio_iic_start();
int /*<<< orphan*/ gpio_iic_stop();
int /*<<< orphan*/ gpio_iic_write(int);
uint32_t LTC2309_read() {
  uint32_t rdata;
  uint8_t temp;
  rdata = 0;
  temp = 0;
  gpio_iic_start();
  gpio_iic_write(((0x10) + 1));
  if (gpio_iic_Gack() == 0) {
    gpio_iic_read(&temp);
    gpio_iic_Pack();
    rdata = temp;
    gpio_iic_read(&temp);
    gpio_iic_Pnack();
    gpio_iic_stop();
    rdata <<= 8;
    rdata += temp;
    rdata >>= 4;
  } else {
    rdata = 0xf0000;
  }
  return rdata;
}


x86 assembly (clang, -O0):
<LTC2309_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1090 <gpio_iic_start@plt>
mov    $0x11,%edi
call   1050 <gpio_iic_write@plt>
mov    $0x0,%al
call   1060 <gpio_iic_Gack@plt>
cmp    $0x0,%rax
jne    11f5 <LTC2309_read+0x85>
lea    -0x8(%rbp),%rdi
call   1080 <gpio_iic_read@plt>
mov    $0x0,%al
call   1040 <gpio_iic_Pack@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1080 <gpio_iic_read@plt>
mov    $0x0,%al
call   1030 <gpio_iic_Pnack@plt>
mov    $0x0,%al
call   1070 <gpio_iic_stop@plt>
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    11fc <LTC2309_read+0x8c>
movl   $0xf0000,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LTC2309_read>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1090 <gpio_iic_start@plt>
mov    $0x11,%edi
call   1050 <gpio_iic_write@plt>
xor    %eax,%eax
call   1060 <gpio_iic_Gack@plt>
mov    $0xf0000,%ebx
test   %rax,%rax
jne    11d6 <LTC2309_read+0x66>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1080 <gpio_iic_read@plt>
xor    %eax,%eax
call   1040 <gpio_iic_Pack@plt>
mov    0x4(%rsp),%ebx
mov    %r14,%rdi
call   1080 <gpio_iic_read@plt>
xor    %eax,%eax
call   1030 <gpio_iic_Pnack@plt>
xor    %eax,%eax
call   1070 <gpio_iic_stop@plt>
shl    $0x8,%ebx
add    0x4(%rsp),%ebx
sar    $0x4,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @LTC2309_read() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (...) @gpio_iic_start()
%4 = call i32 @gpio_iic_write(i32 17)
%5 = call i64 (...) @gpio_iic_Gack()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %0
%8 = call i32 @gpio_iic_read(i32* %2)
%9 = call i32 (...) @gpio_iic_Pack()
%10 = load i32, i32* %2
store i32 %10, i32* %1
%11 = call i32 @gpio_iic_read(i32* %2)
%12 = call i32 (...) @gpio_iic_Pnack()
%13 = call i32 (...) @gpio_iic_stop()
%14 = load i32, i32* %1
%15 = shl i32 %14, 8
store i32 %15, i32* %1
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = add nsw i32 %17, %16
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = ashr i32 %19, 4
store i32 %20, i32* %1
br label %22
21: ; preds = %0
store i32 983040, i32* %1
br label %22
22: ; preds = %21, %7
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @LTC2309_read() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (...) @gpio_iic_start()
%4 = tail call i32 @gpio_iic_write(i32 17)
%5 = tail call i64 (...) @gpio_iic_Gack()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %0
%8 = call i32 @gpio_iic_read(i32* %1)
%9 = call i32 (...) @gpio_iic_Pack()
%10 = load i32, i32* %1
%11 = call i32 @gpio_iic_read(i32* %1)
%12 = call i32 (...) @gpio_iic_Pnack()
%13 = call i32 (...) @gpio_iic_stop()
%14 = shl i32 %10, 8
%15 = load i32, i32* %1
%16 = add nsw i32 %15, %14
%17 = ashr i32 %16, 4
br label %18
18: ; preds = %0, %7
%19 = phi i32 [ %17, %7 ], [ 983040, %0 ]
ret i32 %19
}