#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 uint8_t;
typedef int /*<<< orphan*/ resp;
typedef int /*<<< orphan*/ UP3D_CMD_58;

/* Variables and functions */
scalar_t__ UP3DCOMM_Read(int *, int);
int UP3DCOMM_Write(int const *, int);
bool UP3D_StartResumeProgram() {
  static const uint8_t UP3D_CMD_58[] = {0x58};
  uint8_t resp[2048];
  if ((UP3DCOMM_Write(UP3D_CMD_58, sizeof(UP3D_CMD_58)) !=
       sizeof(UP3D_CMD_58)) ||
      (0 == UP3DCOMM_Read(resp, sizeof(resp))))
    return false;
  return true;
}


x86 assembly (clang, -O0):
<UP3D_StartResumeProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2010,%rsp
lea    0xece(%rip),%rdi
mov    $0x4,%esi
call   1030 <UP3DCOMM_Write@plt>
cltq
cmp    $0x4,%rax
jne    1167 <UP3D_StartResumeProgram+0x47>
lea    -0x2010(%rbp),%rdi
mov    $0x2000,%esi
call   1040 <UP3DCOMM_Read@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1173 <UP3D_StartResumeProgram+0x53>
movl   $0x0,-0x4(%rbp)
jmp    117a <UP3D_StartResumeProgram+0x5a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UP3D_StartResumeProgram>:
sub    $0x2008,%rsp
lea    0xed2(%rip),%rdi
mov    $0x4,%esi
call   1030 <UP3DCOMM_Write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
jne    1159 <UP3D_StartResumeProgram+0x39>
mov    %rsp,%rdi
mov    $0x2000,%esi
call   1040 <UP3DCOMM_Read@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x2008,%rsp
ret

LLVM IR (-O0):
@UP3D_StartResumeProgram.UP3D_CMD_58 = internal constant [1 x i32] [i32 88]
define i32 @UP3D_StartResumeProgram() {
%1 = alloca i32
%2 = alloca [2048 x i32]
%3 = call i32 @UP3DCOMM_Write(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @UP3D_StartResumeProgram.UP3D_CMD_58, i64 0, i64 0), i32 4)
%4 = sext i32 %3 to i64
%5 = icmp ne i64 %4, 4
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = getelementptr inbounds [2048 x i32], [2048 x i32]* %2, i64 0, i64 0
%8 = call i64 @UP3DCOMM_Read(i32* %7, i32 8192)
%9 = icmp eq i64 0, %8
br i1 %9, label %10, label %11
10: ; preds = %6, %0
store i32 0, i32* %1
br label %12
11: ; preds = %6
store i32 1, i32* %1
br label %12
12: ; preds = %11, %10
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@UP3D_StartResumeProgram.UP3D_CMD_58 = internal constant [1 x i32] [i32 88]
define i32 @UP3D_StartResumeProgram() {
%1 = alloca [2048 x i32]
%2 = bitcast [2048 x i32]* %1 to i8*
%3 = tail call i32 @UP3DCOMM_Write(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @UP3D_StartResumeProgram.UP3D_CMD_58, i64 0, i64 0), i32 4)
%4 = icmp eq i32 %3, 4
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = getelementptr inbounds [2048 x i32], [2048 x i32]* %1, i64 0, i64 0
%7 = call i64 @UP3DCOMM_Read(i32* %6, i32 8192)
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %5, %0
%11 = phi i32 [ 0, %0 ], [ %9, %5 ]
ret i32 %11
}