#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 ipmi_cmdraw(int, int, int, int /*<<< orphan*/, int /*<<< orphan*/,
                unsigned char *, int, unsigned char *, int *, unsigned char *,
                char);
int ipmi_getpicmg(unsigned char *presp, int sresp, char fdebug) {
  unsigned char idata[2];
  int rc;
  unsigned char cc;
  if (sresp < 4)
    return (-3);
  idata[0] = 0x00;
  rc =
      ipmi_cmdraw(0x00, 0x2c, 0x20, 0, 0, idata, 1, presp, &sresp, &cc, fdebug);
  if (rc != 0)
    return (rc);
  if (cc != 0)
    return (cc);
  return (0);
}


x86 assembly (clang, -O0):
<ipmi_getpicmg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %al,-0x15(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    113a <ipmi_getpicmg+0x2a>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11bc <ipmi_getpicmg+0xac>
movb   $0x0,-0x17(%rbp)
lea    -0x17(%rbp),%r9
mov    -0x10(%rbp),%r11
xor    %r8d,%r8d
mov    $0x2c,%esi
mov    $0x20,%edx
lea    -0x14(%rbp),%r10
lea    -0x1d(%rbp),%rax
mov    %r8d,%edi
mov    %r8d,%ecx
movl   $0x1,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
movsbl -0x15(%rbp),%eax
mov    %eax,0x20(%rsp)
call   1030 <ipmi_cmdraw@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     119c <ipmi_getpicmg+0x8c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <ipmi_getpicmg+0xac>
movzbl -0x1d(%rbp),%eax
cmp    $0x0,%eax
je     11b5 <ipmi_getpicmg+0xa5>
movzbl -0x1d(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <ipmi_getpicmg+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipmi_getpicmg>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,0xc(%rsp)
mov    $0xfffffffd,%eax
cmp    $0x4,%esi
jl     116c <ipmi_getpicmg+0x5c>
mov    %rdi,%r10
movb   $0x0,0xa(%rsp)
sub    $0x8,%rsp
movsbl %dl,%eax
lea    0x11(%rsp),%r11
lea    0x14(%rsp),%rbx
lea    0x12(%rsp),%r9
xor    %edi,%edi
mov    $0x2c,%esi
mov    $0x20,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
push   %rax
push   %r11
push   %rbx
push   %r10
push   $0x1
call   1030 <ipmi_cmdraw@plt>
add    $0x30,%rsp
test   %eax,%eax
jne    116c <ipmi_getpicmg+0x5c>
movzbl 0x9(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ipmi_getpicmg(i8* %0, i32 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca [2 x i8]
%9 = alloca i32
%10 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8 %2, i8* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -3, i32* %4
br label %32
14: ; preds = %3
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 0, i8* %15
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = load i8, i8* %7
%19 = call i32 @ipmi_cmdraw(i32 0, i32 44, i32 32, i32 0, i32 0, i8* %16, i32 1, i8* %17, i32* %6, i8* %10, i8 signext %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = load i32, i32* %9
store i32 %23, i32* %4
br label %32
24: ; preds = %14
%25 = load i8, i8* %10
%26 = zext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8, i8* %10
%30 = zext i8 %29 to i32
store i32 %30, i32* %4
br label %32
31: ; preds = %24
store i32 0, i32* %4
br label %32
32: ; preds = %31, %28, %22, %13
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @ipmi_getpicmg(i8* %0, i32 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca [2 x i8]
%6 = alloca i8
store i32 %1, i32* %4
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%8 = icmp slt i32 %1, 4
br i1 %8, label %15, label %9
9: ; preds = %3
store i8 0, i8* %7
%10 = call i32 @ipmi_cmdraw(i32 0, i32 44, i32 32, i32 0, i32 0, i8* %7, i32 1, i8* %0, i32* %4, i8* %6, i8 signext %2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
br label %15
15: ; preds = %12, %9, %3
%16 = phi i32 [ -3, %3 ], [ %10, %9 ], [ %14, %12 ]
ret i32 %16
}