#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 oem_supermicro_get_bmc_status(unsigned char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int oem_supermicro_get_health(char *pstr, int sz) {
  int rv;
  unsigned char bsts;
  char *str;
  rv = oem_supermicro_get_bmc_status(&bsts);
  if (rv == 0) {
    if (bsts == 0x01)
      str = "BMC status = enabled";
    else
      str = "BMC status = disabled";
    strncpy(pstr, str, sz);
  }
  return (rv);
}


x86 assembly (clang, -O0):
<oem_supermicro_get_health>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x11(%rbp),%rdi
call   1040 <oem_supermicro_get_bmc_status@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    117d <oem_supermicro_get_health+0x5d>
movzbl -0x11(%rbp),%eax
cmp    $0x1,%eax
jne    1162 <oem_supermicro_get_health+0x42>
lea    0xea7(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    116d <oem_supermicro_get_health+0x4d>
lea    0xeac(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oem_supermicro_get_health>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xf(%rsp),%rdi
call   1040 <oem_supermicro_get_bmc_status@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1160 <oem_supermicro_get_health+0x40>
cmpb   $0x1,0xf(%rsp)
lea    0xeb6(%rip),%rax
lea    0xec4(%rip),%rsi
cmove  %rax,%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   1030 <strncpy@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"BMC status = enabled\00"
@.str.1 = [22 x i8] c"BMC status = disabled\00"
define i32 @oem_supermicro_get_health(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = call i32 @oem_supermicro_get_bmc_status(i8* %6)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i8, i8* %6
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %11
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %7
br label %17
16: ; preds = %11
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %17
17: ; preds = %16, %15
%18 = load i8*, i8** %3
%19 = load i8*, i8** %7
%20 = load i32, i32* %4
%21 = call i32 @strncpy(i8* %18, i8* %19, i32 %20)
br label %22
22: ; preds = %17, %2
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
@.str = [21 x i8] c"BMC status = enabled\00"
@.str.1 = [22 x i8] c"BMC status = disabled\00"
define i32 @oem_supermicro_get_health(i8* %0, i32 %1) {
%3 = alloca i8
%4 = call i32 @oem_supermicro_get_bmc_status(i8* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0)
%10 = call i32 @strncpy(i8* %0, i8* %9, i32 %1)
br label %11
11: ; preds = %6, %2
ret i32 %4
}