// File: /workspace/github_c_makefile_star2_O0/ZombiesYard[P]MPU6050-DMP-raspberry-pi/libs/I2Cdev/I2Cdev.c
// Function: readBytes(unsigned char, unsigned char, unsigned char, unsigned char*)
int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data) {
    int8_t count = 0;
#ifdef DEBUG
    printf("read %#x %#x %u\n",devAddr,regAddr,length);
#endif
    int fd = open("/dev/i2c-1", O_RDWR);

    if (fd < 0) {
        fprintf(stderr, "Failed to open device: %s\n", strerror(errno));
        return(-1);
    }
    if (ioctl(fd, I2C_SLAVE, devAddr) < 0) {
        fprintf(stderr, "Failed to select device: %s\n", strerror(errno));
        close(fd);
        return(-1);
    }
    if (write(fd, &regAddr, 1) != 1) {
        fprintf(stderr, "Failed to write reg: %s\n", strerror(errno));
        close(fd);
        return(-1);
    }
    count = read(fd, data, length);
    if (count < 0) {
        fprintf(stderr, "Failed to read device(%d): %s\n", count, strerror(errno));
        close(fd);
        return(-1);
    } else if (count != length) {
        fprintf(stderr, "Short read  from device, expected %d, got %d\n", length, count);
        close(fd);
        return(-1);
    }
    close(fd);

    return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movb %sil, %dl
movb %dil, %sil
movb %sil, -0x2(%rbp)
movb %dl, -0x3(%rbp)
movb %al, -0x4(%rbp)
movq %rcx, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq 0x23dd(%rip), %rdi      # 0x91f6
movl $0x2, %esi
movb $0x0, %al
callq 0x1090
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x6e66
movq 0x51ab(%rip), %rax      # 0xbfe0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1050
movq -0x20(%rbp), %rdi
movq %rax, %rdx
leaq 0x23ab(%rip), %rsi      # 0x9201
movb $0x0, %al
callq 0x1100
movb $-0x1, -0x1(%rbp)
jmp 0x6fc4
movl -0x18(%rbp), %edi
movzbl -0x2(%rbp), %edx
movl $0x703, %esi            # imm = 0x703
movb $0x0, %al
callq 0x10e0
cmpl $0x0, %eax
jge 0x6ebe
movq 0x515b(%rip), %rax      # 0xbfe0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1050
movq -0x28(%rbp), %rdi
movq %rax, %rdx
leaq 0x2376(%rip), %rsi      # 0x921c
movb $0x0, %al
callq 0x1100
movl -0x18(%rbp), %edi
callq 0x1130
movb $-0x1, -0x1(%rbp)
jmp 0x6fc4
movl -0x18(%rbp), %edi
leaq -0x3(%rbp), %rsi
movl $0x1, %edx
callq 0x1060
cmpq $0x1, %rax
je 0x6f15
movq 0x5104(%rip), %rax      # 0xbfe0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1050
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0x233c(%rip), %rsi      # 0x9239
movb $0x0, %al
callq 0x1100
movl -0x18(%rbp), %edi
callq 0x1130
movb $-0x1, -0x1(%rbp)
jmp 0x6fc4
movl -0x18(%rbp), %edi
movq -0x10(%rbp), %rsi
movzbl -0x4(%rbp), %eax
movl %eax, %edx
callq 0x1110
movb %al, -0x11(%rbp)
movsbl -0x11(%rbp), %eax
cmpl $0x0, %eax
jge 0x6f7a
movq 0x50a6(%rip), %rax      # 0xbfe0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movsbl -0x11(%rbp), %eax
movl %eax, -0x34(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1050
movq -0x40(%rbp), %rdi
movl -0x34(%rbp), %edx
movq %rax, %rcx
leaq 0x22ed(%rip), %rsi      # 0x9252
movb $0x0, %al
callq 0x1100
movl -0x18(%rbp), %edi
callq 0x1130
movb $-0x1, -0x1(%rbp)
jmp 0x6fc4
movsbl -0x11(%rbp), %eax
movzbl -0x4(%rbp), %ecx
cmpl %ecx, %eax
je 0x6fb4
movq 0x5053(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movzbl -0x4(%rbp), %edx
movsbl -0x11(%rbp), %ecx
leaq 0x22d2(%rip), %rsi      # 0x9271
movb $0x0, %al
callq 0x1100
movl -0x18(%rbp), %edi
callq 0x1130
movb $-0x1, -0x1(%rbp)
jmp 0x6fc4
jmp 0x6fb6
movl -0x18(%rbp), %edi
callq 0x1130
movb -0x11(%rbp), %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)