#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 scalar_t__ int32_t;

/* Variables and functions */
int /*<<< orphan*/ __rleu32(int *);
int i2c_transact(int, int, int *, int, int);
int i2c_read_leint32(int fd, int chip_addr, int reg, int32_t *value) {
  uint8_t data[sizeof(int32_t)];
  data[0] = reg;
  int err = i2c_transact(fd, chip_addr, data, 1, sizeof(int32_t));
  if (err == sizeof(int32_t))
    *value = (int32_t)__rleu32(data);
  return err;
}


x86 assembly (clang, -O0):
<i2c_read_leint32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    $0x1,%ecx
mov    $0x8,%r8d
call   1040 <i2c_transact@plt>
mov    %eax,-0x44(%rbp)
movslq -0x44(%rbp),%rax
cmp    $0x8,%rax
jne    1179 <i2c_read_leint32+0x59>
lea    -0x40(%rbp),%rdi
call   1030 <__rleu32@plt>
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_read_leint32>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %edx,(%rsp)
mov    %rsp,%rdx
mov    $0x1,%ecx
mov    $0x8,%r8d
call   1040 <i2c_transact@plt>
mov    %eax,%ebp
cmp    $0x8,%eax
jne    1153 <i2c_read_leint32+0x33>
mov    %rsp,%rdi
call   1030 <__rleu32@plt>
cltq
mov    %rax,(%rbx)
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @i2c_read_leint32(i32 %0, i32 %1, i32 %2, i64* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64*
%9 = alloca [8 x i32]
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i64* %3, i64** %8
%11 = load i32, i32* %7
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 0
store i32 %11, i32* %12
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 0
%16 = call i32 @i2c_transact(i32 %13, i32 %14, i32* %15, i32 1, i32 8)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = icmp eq i64 %18, 8
br i1 %19, label %20, label %25
20: ; preds = %4
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 0
%22 = call i32 @__rleu32(i32* %21)
%23 = sext i32 %22 to i64
%24 = load i64*, i64** %8
store i64 %23, i64* %24
br label %25
25: ; preds = %20, %4
%26 = load i32, i32* %10
ret i32 %26
}

LLVM IR (-O2):
define i32 @i2c_read_leint32(i32 %0, i32 %1, i32 %2, i64* nocapture writeonly %3) {
%5 = alloca [8 x i32]
%6 = bitcast [8 x i32]* %5 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
store i32 %2, i32* %7
%8 = call i32 @i2c_transact(i32 %0, i32 %1, i32* %7, i32 1, i32 8)
%9 = icmp eq i32 %8, 8
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = call i32 @__rleu32(i32* %7)
%12 = sext i32 %11 to i64
store i64 %12, i64* %3
br label %13
13: ; preds = %10, %4
ret i32 %8
}