#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*/ _pmu(int);
int pigpio_command(int, int, unsigned int, unsigned int, int /*<<< orphan*/);
int recvMax(int, char *, unsigned int, int);
int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count) {
  int bytes;
  bytes = pigpio_command(pi, 56, handle, count, 0);
  if (bytes > 0) {
    bytes = recvMax(pi, buf, count, bytes);
  }
  _pmu(pi);
  return bytes;
}


x86 assembly (clang, -O0):
<i2c_read_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x38,%esi
xor    %r8d,%r8d
call   1040 <pigpio_command@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    117d <i2c_read_device+0x4d>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <recvMax@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <_pmu@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_read_device>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%edx
mov    %edi,%ebx
mov    $0x38,%esi
xor    %r8d,%r8d
call   1040 <pigpio_command@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1165 <i2c_read_device+0x35>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1050 <recvMax@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <_pmu@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @i2c_read_device(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load i32, i32* %8
%13 = call i32 @pigpio_command(i32 %10, i32 56, i32 %11, i32 %12, i32 0)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %4
%17 = load i32, i32* %5
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = call i32 @recvMax(i32 %17, i8* %18, i32 %19, i32 %20)
store i32 %21, i32* %9
br label %22
22: ; preds = %16, %4
%23 = load i32, i32* %5
%24 = call i32 @_pmu(i32 %23)
%25 = load i32, i32* %9
ret i32 %25
}

LLVM IR (-O2):
define i32 @i2c_read_device(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = tail call i32 @pigpio_command(i32 %0, i32 56, i32 %1, i32 %3, i32 0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @recvMax(i32 %0, i8* %2, i32 %3, i32 %5)
br label %9
9: ; preds = %7, %4
%10 = phi i32 [ %8, %7 ], [ %5, %4 ]
%11 = tail call i32 @_pmu(i32 %0)
ret i32 %10
}