#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 otp_AF_copy(unsigned char const *, int const, unsigned char *, int *);
int otp_AWB_LSC_light_copy(unsigned char const *, int const, unsigned char *,
                           int *);
int otp_Module_Information_copy(unsigned char const *, int const,
                                unsigned char *, int *);
int otp_crc(unsigned char *, int *);
int otp_data_copy(const unsigned char *ov8865_data_ptr, const int ov8865_size,
                  unsigned char *otp_data_ptr, int *otp_size) {
  int ret = 0;
  *otp_size = 0;
  ret = otp_Module_Information_copy(ov8865_data_ptr, ov8865_size, otp_data_ptr,
                                    otp_size);
  if (ret == -1)
    return ret;
  ret = otp_AF_copy(ov8865_data_ptr, ov8865_size, otp_data_ptr, otp_size);
  if (ret == -1)
    return ret;
  ret = otp_AWB_LSC_light_copy(ov8865_data_ptr, ov8865_size, otp_data_ptr,
                               otp_size);
  if (ret == -1)
    return ret;
  ret = otp_crc(otp_data_ptr, otp_size);
  if (ret == -1)
    return ret;
  return 0;
}


x86 assembly (clang, -O0):
<otp_data_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <otp_Module_Information_copy@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1194 <otp_data_copy+0x54>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <otp_data_copy+0xd8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <otp_AF_copy@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11c0 <otp_data_copy+0x80>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <otp_data_copy+0xd8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <otp_AWB_LSC_light_copy@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11ec <otp_data_copy+0xac>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <otp_data_copy+0xd8>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <otp_crc@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1211 <otp_data_copy+0xd1>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <otp_data_copy+0xd8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<otp_data_copy>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%rbp
movl   $0x0,(%rcx)
call   1050 <otp_Module_Information_copy@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     11ae <otp_data_copy+0x6e>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1030 <otp_AF_copy@plt>
cmp    $0xffffffff,%eax
je     11ae <otp_data_copy+0x6e>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <otp_AWB_LSC_light_copy@plt>
cmp    $0xffffffff,%eax
je     11ae <otp_data_copy+0x6e>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <otp_crc@plt>
xor    %r14d,%r14d
cmp    $0xffffffff,%eax
sete   %r14b
neg    %r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @otp_data_copy(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i32 0, i32* %10
%11 = load i32*, i32** %9
store i32 0, i32* %11
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = load i8*, i8** %8
%15 = load i32*, i32** %9
%16 = call i32 @otp_Module_Information_copy(i8* %12, i32 %13, i8* %14, i32* %15)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i32, i32* %10
store i32 %20, i32* %5
br label %50
21: ; preds = %4
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = load i8*, i8** %8
%25 = load i32*, i32** %9
%26 = call i32 @otp_AF_copy(i8* %22, i32 %23, i8* %24, i32* %25)
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = load i32, i32* %10
store i32 %30, i32* %5
br label %50
31: ; preds = %21
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = load i8*, i8** %8
%35 = load i32*, i32** %9
%36 = call i32 @otp_AWB_LSC_light_copy(i8* %32, i32 %33, i8* %34, i32* %35)
store i32 %36, i32* %10
%37 = load i32, i32* %10
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = load i32, i32* %10
store i32 %40, i32* %5
br label %50
41: ; preds = %31
%42 = load i8*, i8** %8
%43 = load i32*, i32** %9
%44 = call i32 @otp_crc(i8* %42, i32* %43)
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = load i32, i32* %10
store i32 %48, i32* %5
br label %50
49: ; preds = %41
store i32 0, i32* %5
br label %50
50: ; preds = %49, %47, %39, %29, %19
%51 = load i32, i32* %5
ret i32 %51
}

LLVM IR (-O2):
define i32 @otp_data_copy(i8* %0, i32 %1, i8* %2, i32* %3) {
store i32 0, i32* %3
%5 = tail call i32 @otp_Module_Information_copy(i8* %0, i32 %1, i8* %2, i32* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i32 @otp_AF_copy(i8* %0, i32 %1, i8* %2, i32* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i32 @otp_AWB_LSC_light_copy(i8* %0, i32 %1, i8* %2, i32* %3)
%12 = icmp eq i32 %11, -1
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @otp_crc(i8* %2, i32* %3)
%15 = icmp eq i32 %14, -1
%16 = sext i1 %15 to i32
br label %17
17: ; preds = %13, %10, %7, %4
%18 = phi i32 [ -1, %4 ], [ -1, %7 ], [ -1, %10 ], [ %16, %13 ]
ret i32 %18
}