int load_otp_VCM(struct msm_sensor_ctrl_t *a_ctrl) {
  int i, code, temp, otp_index;
  for (code = 0; code < 2; code++) {
    for (i = 1; i <= 3; i++) {
      temp = check_otp_VCM(i, code, a_ctrl);
      pr_err("otpaf %s  temp =%d , i=%d,code=%d", __func__, temp, i, code);
      if (temp == 2) {
        otp_index = i;
        break;
      }
    }
    if (i > 3) {
      pr_err("otpaf %s  i=%d   no valid af OTP data ", __func__, i);
      return 1;
    }
    read_otp_VCM(otp_index, code, a_ctrl);
  }
  return 0;
}


x86 assembly (clang, -O0):
<load_otp_VCM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    1206 <load_otp_VCM+0xd6>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     11b9 <load_otp_VCM+0x89>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <check_otp_VCM@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe7d(%rip),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1050 <pr_err@plt>
cmpl   $0x2,-0x1c(%rbp)
jne    11a6 <load_otp_VCM+0x76>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11b9 <load_otp_VCM+0x89>
jmp    11ab <load_otp_VCM+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <load_otp_VCM+0x24>
cmpl   $0x3,-0x14(%rbp)
jle    11e7 <load_otp_VCM+0xb7>
mov    -0x14(%rbp),%edx
lea    0xe62(%rip),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1050 <pr_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    120d <load_otp_VCM+0xdd>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <read_otp_VCM@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <load_otp_VCM+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_otp_VCM>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
mov    $0x1,%r14d
mov    $0x1,%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <check_otp_VCM@plt>
mov    %eax,%ebx
lea    0xea5(%rip),%rdi
lea    0xec0(%rip),%rsi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <pr_err@plt>
mov    $0x1,%ebp
cmp    $0x2,%ebx
je     11f9 <load_otp_VCM+0xc9>
mov    $0x2,%ebp
mov    $0x2,%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <check_otp_VCM@plt>
mov    %eax,%ebx
lea    0xe64(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    %eax,%edx
mov    $0x2,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <pr_err@plt>
cmp    $0x2,%ebx
je     11f9 <load_otp_VCM+0xc9>
mov    $0x3,%ebp
mov    $0x3,%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <check_otp_VCM@plt>
mov    %eax,%ebx
lea    0xe28(%rip),%rdi
lea    0xe43(%rip),%rsi
mov    %eax,%edx
mov    $0x3,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <pr_err@plt>
cmp    $0x2,%ebx
jne    12e5 <load_otp_VCM+0x1b5>
xor    %r15d,%r15d
mov    %ebp,%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <read_otp_VCM@plt>
mov    $0x1,%edi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <check_otp_VCM@plt>
mov    %eax,%ebx
lea    0xdd9(%rip),%rdi
lea    0xdf4(%rip),%rsi
mov    %eax,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <pr_err@plt>
cmp    $0x2,%ebx
je     12d1 <load_otp_VCM+0x1a1>
mov    $0x2,%r14d
mov    $0x2,%edi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <check_otp_VCM@plt>
mov    %eax,%ebx
lea    0xd92(%rip),%rdi
lea    0xdad(%rip),%rsi
mov    %eax,%edx
mov    $0x2,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <pr_err@plt>
cmp    $0x2,%ebx
je     12d1 <load_otp_VCM+0x1a1>
mov    $0x3,%r14d
mov    $0x3,%edi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <check_otp_VCM@plt>
mov    %eax,%ebx
lea    0xd4f(%rip),%rdi
lea    0xd6a(%rip),%rsi
mov    %eax,%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <pr_err@plt>
cmp    $0x2,%ebx
jne    12e5 <load_otp_VCM+0x1b5>
mov    %r14d,%edi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <read_otp_VCM@plt>
jmp    1305 <load_otp_VCM+0x1d5>
lea    0xd43(%rip),%rdi
lea    0xd2f(%rip),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <pr_err@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.msm_sensor_ctrl_t = type opaque
@.str = [34 x i8] c"otpaf %s temp =%d , i=%d,code=%d\00"
@__func__.load_otp_VCM = [13 x i8] c"load_otp_VCM\00"
@.str.1 = [39 x i8] c"otpaf %s i=%d no valid af OTP data \00"
define i32 @load_otp_VCM(%struct.msm_sensor_ctrl_t* %0) {
%2 = alloca i32
%3 = alloca %struct.msm_sensor_ctrl_t*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.msm_sensor_ctrl_t* %0, %struct.msm_sensor_ctrl_t** %3
store i32 0, i32* %5
br label %8
8: ; preds = %43, %1
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %46
11: ; preds = %8
store i32 1, i32* %4
br label %12
12: ; preds = %29, %11
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 3
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load %struct.msm_sensor_ctrl_t*, %struct.msm_sensor_ctrl_t** %3
%19 = call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 %16, i32 %17, %struct.msm_sensor_ctrl_t* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = load i32, i32* %4
store i32 %27, i32* %7
br label %32
28: ; preds = %15
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %12
32: ; preds = %26, %12
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 3
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* %4
%37 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %36)
store i32 1, i32* %2
br label %47
38: ; preds = %32
%39 = load i32, i32* %7
%40 = load i32, i32* %5
%41 = load %struct.msm_sensor_ctrl_t*, %struct.msm_sensor_ctrl_t** %3
%42 = call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @read_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 %39, i32 %40, %struct.msm_sensor_ctrl_t* %41)
br label %43
43: ; preds = %38
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %8
46: ; preds = %8
store i32 0, i32* %2
br label %47
47: ; preds = %46, %35
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
%struct.msm_sensor_ctrl_t = type opaque
@.str = [34 x i8] c"otpaf %s temp =%d , i=%d,code=%d\00"
@__func__.load_otp_VCM = [13 x i8] c"load_otp_VCM\00"
@.str.1 = [39 x i8] c"otpaf %s i=%d no valid af OTP data \00"
define i32 @load_otp_VCM(%struct.msm_sensor_ctrl_t* %0) {
%2 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 1, i32 0, %struct.msm_sensor_ctrl_t* %0)
%3 = tail call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %2, i32 1, i32 0)
%4 = icmp eq i32 %2, 2
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 2, i32 0, %struct.msm_sensor_ctrl_t* %0)
%7 = tail call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %6, i32 2, i32 0)
%8 = icmp eq i32 %6, 2
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 3, i32 0, %struct.msm_sensor_ctrl_t* %0)
%11 = tail call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %10, i32 3, i32 0)
%12 = icmp eq i32 %10, 2
br i1 %12, label %15, label %13
13: ; preds = %25, %9
%14 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 4)
br label %32
15: ; preds = %9, %5, %1
%16 = phi i32 [ 1, %1 ], [ 2, %5 ], [ 3, %9 ]
%17 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @read_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 %16, i32 0, %struct.msm_sensor_ctrl_t* %0)
%18 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 1, i32 1, %struct.msm_sensor_ctrl_t* %0)
%19 = tail call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %18, i32 1, i32 1)
%20 = icmp eq i32 %18, 2
br i1 %20, label %29, label %21
21: ; preds = %15
%22 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 2, i32 1, %struct.msm_sensor_ctrl_t* %0)
%23 = tail call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %22, i32 2, i32 1)
%24 = icmp eq i32 %22, 2
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @check_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 3, i32 1, %struct.msm_sensor_ctrl_t* %0)
%27 = tail call i32 (i8*, i8*, i32, i32, i32, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__func__.load_otp_VCM, i64 0, i64 0), i32 %26, i32 3, i32 1)
%28 = icmp eq i32 %26, 2
br i1 %28, label %29, label %13
29: ; preds = %25, %21, %15
%30 = phi i32 [ 1, %15 ], [ 2, %21 ], [ 3, %25 ]
%31 = tail call i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...) bitcast (i32 (...)* @read_otp_VCM to i32 (i32, i32, %struct.msm_sensor_ctrl_t*, ...)*)(i32 %30, i32 1, %struct.msm_sensor_ctrl_t* %0)
br label %32
32: ; preds = %29, %13
%33 = phi i32 [ 1, %13 ], [ 0, %29 ]
ret i32 %33
}