#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 */
typedef int uint32_t;
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ _pmu(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int pigpio_command(int, int, unsigned int, int /*<<< orphan*/,
                   int /*<<< orphan*/);
int /*<<< orphan*/ recvMax(int, int *, int, int);
int script_status(int pi, unsigned script_id, uint32_t *param) {
  int status;
  uint32_t p[10 + 1];
  status = pigpio_command(pi, 45, script_id, 0, 0);
  if (status > 0) {
    recvMax(pi, p, sizeof(p), status);
    status = p[0];
    if (param)
      memcpy(param, p + 1, sizeof(p) - 4);
  }
  _pmu(pi);
  return status;
}


x86 assembly (clang, -O0):
<script_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x2d,%esi
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1050 <pigpio_command@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11b5 <script_status+0x75>
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0x2c,%edx
call   1060 <recvMax@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b0 <script_status+0x70>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
add    $0x4,%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
jmp    11b5 <script_status+0x75>
mov    -0x4(%rbp),%edi
call   1030 <_pmu@plt>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<script_status>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %esi,%edx
mov    %edi,%ebx
mov    $0x2d,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <pigpio_command@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    118f <script_status+0x4f>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x2c,%edx
mov    %ebp,%ecx
call   1060 <recvMax@plt>
mov    (%rsp),%ebp
test   %r14,%r14
je     118f <script_status+0x4f>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
mov    $0x28,%edx
call   1040 <memcpy@plt>
mov    %ebx,%edi
call   1030 <_pmu@plt>
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @script_status(i32 %0, i32 %1, i32* %2) {
%4 = alloca [11 x i32]
%5 = bitcast [11 x i32]* %4 to i8*
%6 = tail call i32 @pigpio_command(i32 %0, i32 45, i32 %1, i32 0, i32 0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%10 = call i32 @recvMax(i32 %0, i32* %9, i32 44, i32 %6)
%11 = load i32, i32* %9
%12 = icmp eq i32* %2, null
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 1
%15 = call i32 @memcpy(i32* %2, i32* %14, i32 40)
br label %16
16: ; preds = %8, %13, %3
%17 = phi i32 [ %11, %13 ], [ %11, %8 ], [ %6, %3 ]
%18 = call i32 @_pmu(i32 %0)
ret i32 %17
}