#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 I2C_ReadBytes(int, int, unsigned char *, int);
int STC31xx_Read(int NumberOfBytes, int RegAddress, unsigned char *RxBuffer) {
  int retry;
  int res = -1;
  for (retry = 0; retry < 3; retry++) {
    res = I2C_ReadBytes(0xE0, RegAddress, RxBuffer, NumberOfBytes);
    if (res == 0)
      break;
  }
  return (res);
}


x86 assembly (clang, -O0):
<STC31xx_Read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1173 <STC31xx_Read+0x63>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    $0xe0,%edi
call   1030 <I2C_ReadBytes@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1160 <STC31xx_Read+0x50>
jmp    1173 <STC31xx_Read+0x63>
jmp    1165 <STC31xx_Read+0x55>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <STC31xx_Read+0x20>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<STC31xx_Read>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0xe0,%edi
mov    %ebp,%ecx
call   1030 <I2C_ReadBytes@plt>
test   %eax,%eax
je     1155 <STC31xx_Read+0x45>
mov    $0xe0,%edi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1030 <I2C_ReadBytes@plt>
test   %eax,%eax
je     1155 <STC31xx_Read+0x45>
mov    $0xe0,%edi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <I2C_ReadBytes@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @STC31xx_Read(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @I2C_ReadBytes(i32 224, i32 %1, i8* %2, i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 @I2C_ReadBytes(i32 224, i32 %1, i8* %2, i32 %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @I2C_ReadBytes(i32 224, i32 %1, i8* %2, i32 %0)
br label %11
11: ; preds = %9, %6, %3
%12 = phi i32 [ 0, %3 ], [ 0, %6 ], [ %10, %9 ]
ret i32 %12
}