#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*/ AMI_LOG(char *);
int checkDigitalCircuit(void *);
int checkMIElement1(void *);
int checkMIElement2(void *);
int checkOTP(void *);
int checkTempSensor(void *);
int AMI_SelfTest(void *i2c_hnd) {
  int ret = 0;
  AMI_LOG("----- OTP Check -----");
  ret = checkOTP(i2c_hnd);
  if (ret != 0)
    return ret;
  AMI_LOG("-----TEMP Check -----");
  ret = checkTempSensor(i2c_hnd);
  if (ret != 0)
    return ret;
  AMI_LOG("----- MI Element Check 1 -----");
  ret = checkMIElement1(i2c_hnd);
  if (ret != 0)
    return ret;
  AMI_LOG("----- MI Element Check 2 -----");
  ret = checkMIElement2(i2c_hnd);
  if (ret != 0)
    return ret;
  AMI_LOG("----- Digital Circuit Check -----");
  ret = checkDigitalCircuit(i2c_hnd);
  if (ret != 0)
    return ret;
  return 0;
}


x86 assembly (clang, -O0):
<AMI_SelfTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe86(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    -0x10(%rbp),%rdi
call   1030 <checkOTP@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a0 <AMI_SelfTest+0x40>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125b <AMI_SelfTest+0xfb>
lea    0xe6f(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    -0x10(%rbp),%rdi
call   1040 <checkTempSensor@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11cd <AMI_SelfTest+0x6d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125b <AMI_SelfTest+0xfb>
lea    0xe58(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    -0x10(%rbp),%rdi
call   1070 <checkMIElement1@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11fa <AMI_SelfTest+0x9a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125b <AMI_SelfTest+0xfb>
lea    0xe4a(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    -0x10(%rbp),%rdi
call   1050 <checkMIElement2@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1227 <AMI_SelfTest+0xc7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125b <AMI_SelfTest+0xfb>
lea    0xe3c(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    -0x10(%rbp),%rdi
call   1060 <checkDigitalCircuit@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1254 <AMI_SelfTest+0xf4>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125b <AMI_SelfTest+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AMI_SelfTest>:
push   %rbx
mov    %rdi,%rbx
lea    0xe95(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    %rbx,%rdi
call   1030 <checkOTP@plt>
test   %eax,%eax
jne    11c4 <AMI_SelfTest+0x64>
lea    0xe93(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    %rbx,%rdi
call   1040 <checkTempSensor@plt>
test   %eax,%eax
jne    11c4 <AMI_SelfTest+0x64>
lea    0xe91(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    %rbx,%rdi
call   1070 <checkMIElement1@plt>
test   %eax,%eax
jne    11c4 <AMI_SelfTest+0x64>
lea    0xe98(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    %rbx,%rdi
call   1050 <checkMIElement2@plt>
test   %eax,%eax
je     11c6 <AMI_SelfTest+0x66>
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
call   1080 <AMI_LOG@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <checkDigitalCircuit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"----- OTP Check -----\00"
@.str.1 = [22 x i8] c"-----TEMP Check -----\00"
@.str.2 = [31 x i8] c"----- MI Element Check 1 -----\00"
@.str.3 = [31 x i8] c"----- MI Element Check 2 -----\00"
@.str.4 = [34 x i8] c"----- Digital Circuit Check -----\00"
define i32 @AMI_SelfTest(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = call i32 @AMI_LOG(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %3
%7 = call i32 @checkOTP(i8* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i32, i32* %4
store i32 %11, i32* %2
br label %45
12: ; preds = %1
%13 = call i32 @AMI_LOG(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8*, i8** %3
%15 = call i32 @checkTempSensor(i8* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load i32, i32* %4
store i32 %19, i32* %2
br label %45
20: ; preds = %12
%21 = call i32 @AMI_LOG(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8*, i8** %3
%23 = call i32 @checkMIElement1(i8* %22)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %45
28: ; preds = %20
%29 = call i32 @AMI_LOG(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%30 = load i8*, i8** %3
%31 = call i32 @checkMIElement2(i8* %30)
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = load i32, i32* %4
store i32 %35, i32* %2
br label %45
36: ; preds = %28
%37 = call i32 @AMI_LOG(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%38 = load i8*, i8** %3
%39 = call i32 @checkDigitalCircuit(i8* %38)
store i32 %39, i32* %4
%40 = load i32, i32* %4
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* %4
store i32 %43, i32* %2
br label %45
44: ; preds = %36
store i32 0, i32* %2
br label %45
45: ; preds = %44, %42, %34, %26, %18, %10
%46 = load i32, i32* %2
ret i32 %46
}

LLVM IR (-O2):
@.str = [22 x i8] c"----- OTP Check -----\00"
@.str.1 = [22 x i8] c"-----TEMP Check -----\00"
@.str.2 = [31 x i8] c"----- MI Element Check 1 -----\00"
@.str.3 = [31 x i8] c"----- MI Element Check 2 -----\00"
@.str.4 = [34 x i8] c"----- Digital Circuit Check -----\00"
define i32 @AMI_SelfTest(i8* %0) {
%2 = tail call i32 @AMI_LOG(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @checkOTP(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = tail call i32 @AMI_LOG(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @checkTempSensor(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = tail call i32 @AMI_LOG(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @checkMIElement1(i8* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = tail call i32 @AMI_LOG(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @checkMIElement2(i8* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = tail call i32 @AMI_LOG(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%19 = tail call i32 @checkDigitalCircuit(i8* %0)
br label %20
20: ; preds = %17, %13, %9, %5, %1
%21 = phi i32 [ %3, %1 ], [ %7, %5 ], [ %11, %9 ], [ %15, %13 ], [ %19, %17 ]
ret i32 %21
}