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

/* Variables and functions */
int UP3DCOMM_Read(int *, int);
int UP3DCOMM_Write(int *, int);
bool UP3D_SetPrintJobInfo(uint8_t progID, uint8_t x, uint32_t y) {
  if (progID > 9)
    return false;
  uint8_t UP3D_CMD_63_X_Y[7] = {0x63,
                                progID,
                                x,
                                (y >> 0) & 0xFF,
                                (y >> 8) & 0xFF,
                                (y >> 16) & 0xFF,
                                (y >> 24) & 0xFF};
  uint8_t resp[2048];
  if ((UP3DCOMM_Write(UP3D_CMD_63_X_Y, sizeof(UP3D_CMD_63_X_Y)) !=
       sizeof(UP3D_CMD_63_X_Y)) ||
      (1 != UP3DCOMM_Read(resp, sizeof(resp))) || (6 != resp[0]))
    return false;
  return true;
}


x86 assembly (clang, -O0):
<UP3D_SetPrintJobInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x9,-0x8(%rbp)
jle    114a <UP3D_SetPrintJobInfo+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <UP3D_SetPrintJobInfo+0xd3>
movl   $0x63,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x1c,%esi
call   1030 <UP3DCOMM_Write@plt>
cltq
cmp    $0x1c,%rax
jne    11e0 <UP3D_SetPrintJobInfo+0xc0>
lea    -0x2030(%rbp),%rdi
mov    $0x2000,%esi
call   1040 <UP3DCOMM_Read@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    11e0 <UP3D_SetPrintJobInfo+0xc0>
mov    $0x6,%eax
cmp    -0x2030(%rbp),%eax
je     11ec <UP3D_SetPrintJobInfo+0xcc>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <UP3D_SetPrintJobInfo+0xd3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UP3D_SetPrintJobInfo>:
xor    %eax,%eax
cmp    $0x9,%edi
jg     119d <UP3D_SetPrintJobInfo+0x7d>
sub    $0x2028,%rsp
movl   $0x63,(%rsp)
mov    %edi,0x4(%rsp)
mov    %esi,0x8(%rsp)
movzbl %dl,%eax
mov    %eax,0xc(%rsp)
movzbl %dh,%eax
mov    %eax,0x10(%rsp)
mov    %edx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x14(%rsp)
shr    $0x18,%edx
mov    %edx,0x18(%rsp)
mov    %rsp,%rdi
mov    $0x1c,%esi
call   1030 <UP3DCOMM_Write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1c,%ecx
jne    1196 <UP3D_SetPrintJobInfo+0x76>
lea    0x20(%rsp),%rdi
mov    $0x2000,%esi
call   1040 <UP3DCOMM_Read@plt>
mov    %eax,%ecx
xor    $0x1,%ecx
mov    0x20(%rsp),%edx
xor    $0x6,%edx
xor    %eax,%eax
or     %ecx,%edx
sete   %al
add    $0x2028,%rsp
ret

LLVM IR (-O0):
define i32 @UP3D_SetPrintJobInfo(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [7 x i32]
%9 = alloca [2048 x i32]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 9
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 0, i32* %4
br label %49
13: ; preds = %3
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %8, i64 0, i64 0
store i32 99, i32* %14
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %5
store i32 %16, i32* %15
%17 = getelementptr inbounds i32, i32* %15, i64 1
%18 = load i32, i32* %6
store i32 %18, i32* %17
%19 = getelementptr inbounds i32, i32* %17, i64 1
%20 = load i32, i32* %7
%21 = ashr i32 %20, 0
%22 = and i32 %21, 255
store i32 %22, i32* %19
%23 = getelementptr inbounds i32, i32* %19, i64 1
%24 = load i32, i32* %7
%25 = ashr i32 %24, 8
%26 = and i32 %25, 255
store i32 %26, i32* %23
%27 = getelementptr inbounds i32, i32* %23, i64 1
%28 = load i32, i32* %7
%29 = ashr i32 %28, 16
%30 = and i32 %29, 255
store i32 %30, i32* %27
%31 = getelementptr inbounds i32, i32* %27, i64 1
%32 = load i32, i32* %7
%33 = ashr i32 %32, 24
%34 = and i32 %33, 255
store i32 %34, i32* %31
%35 = getelementptr inbounds [7 x i32], [7 x i32]* %8, i64 0, i64 0
%36 = call i32 @UP3DCOMM_Write(i32* %35, i32 28)
%37 = sext i32 %36 to i64
%38 = icmp ne i64 %37, 28
br i1 %38, label %47, label %39
39: ; preds = %13
%40 = getelementptr inbounds [2048 x i32], [2048 x i32]* %9, i64 0, i64 0
%41 = call i32 @UP3DCOMM_Read(i32* %40, i32 8192)
%42 = icmp ne i32 1, %41
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = getelementptr inbounds [2048 x i32], [2048 x i32]* %9, i64 0, i64 0
%45 = load i32, i32* %44
%46 = icmp ne i32 6, %45
br i1 %46, label %47, label %48
47: ; preds = %43, %39, %13
store i32 0, i32* %4
br label %49
48: ; preds = %43
store i32 1, i32* %4
br label %49
49: ; preds = %48, %47, %12
%50 = load i32, i32* %4
ret i32 %50
}

LLVM IR (-O2):
define i32 @UP3D_SetPrintJobInfo(i32 %0, i32 %1, i32 %2) {
%4 = alloca [7 x i32]
%5 = alloca [2048 x i32]
%6 = icmp sgt i32 %0, 9
br i1 %6, label %35, label %7
7: ; preds = %3
%8 = bitcast [7 x i32]* %4 to i8*
%9 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
store i32 99, i32* %9
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 1
store i32 %0, i32* %10
%11 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 2
store i32 %1, i32* %11
%12 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 3
%13 = and i32 %2, 255
store i32 %13, i32* %12
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 4
%15 = lshr i32 %2, 8
%16 = and i32 %15, 255
store i32 %16, i32* %14
%17 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 5
%18 = lshr i32 %2, 16
%19 = and i32 %18, 255
store i32 %19, i32* %17
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 6
%21 = lshr i32 %2, 24
store i32 %21, i32* %20
%22 = bitcast [2048 x i32]* %5 to i8*
%23 = call i32 @UP3DCOMM_Write(i32* %9, i32 28)
%24 = icmp eq i32 %23, 28
br i1 %24, label %25, label %33
25: ; preds = %7
%26 = getelementptr inbounds [2048 x i32], [2048 x i32]* %5, i64 0, i64 0
%27 = call i32 @UP3DCOMM_Read(i32* %26, i32 8192)
%28 = icmp eq i32 %27, 1
%29 = load i32, i32* %26
%30 = icmp eq i32 %29, 6
%31 = select i1 %28, i1 %30, i1 false
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %25, %7
%34 = phi i32 [ 0, %7 ], [ %32, %25 ]
br label %35
35: ; preds = %3, %33
%36 = phi i32 [ %34, %33 ], [ 0, %3 ]
ret i32 %36
}