#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 /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ send_cmd(unsigned char *, int, unsigned char *, int);
void setprop(int number, int value) {
  unsigned char prop[5];
  unsigned char resp[1];
  prop[0] = 0x12;
  prop[1] = 0;
  prop[2] = number / 256;
  prop[3] = number % 256;
  prop[4] = value / 256;
  prop[5] = value % 256;
  send_cmd(prop, 6, resp, 1);
  if (resp[0] & 0x40)
    printf("error setting property %04x to %04x\n", number, value);
}


x86 assembly (clang, -O0):
<setprop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movb   $0x12,-0xd(%rbp)
movb   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,-0xb(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x8(%rbp)
lea    -0xd(%rbp),%rdi
lea    -0xe(%rbp),%rdx
mov    $0x6,%esi
mov    $0x1,%ecx
call   1040 <send_cmd@plt>
movzbl -0xe(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     11ab <setprop+0x8b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setprop>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
movw   $0x12,0x3(%rsp)
lea    0xff(%rbx),%eax
test   %edi,%edi
cmovns %edi,%eax
mov    %ah,0x5(%rsp)
mov    %bl,0x6(%rsp)
lea    0xff(%r14),%eax
test   %esi,%esi
cmovns %esi,%eax
mov    %ah,0x7(%rsp)
mov    %r14b,0x8(%rsp)
lea    0x3(%rsp),%rdi
lea    0x2(%rsp),%rdx
mov    $0x6,%esi
mov    $0x1,%ecx
call   1040 <send_cmd@plt>
testb  $0x40,0x2(%rsp)
je     1189 <setprop+0x69>
lea    0xe81(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"error setting property %04x to %04x\0A\00"
define void @setprop(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x i8]
%6 = alloca [1 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
store i8 18, i8* %7
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 1
store i8 0, i8* %8
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 256
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 2
store i8 %11, i8* %12
%13 = load i32, i32* %3
%14 = srem i32 %13, 256
%15 = trunc i32 %14 to i8
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 3
store i8 %15, i8* %16
%17 = load i32, i32* %4
%18 = sdiv i32 %17, 256
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 4
store i8 %19, i8* %20
%21 = load i32, i32* %4
%22 = srem i32 %21, 256
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 5
store i8 %23, i8* %24
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%26 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%27 = call i32 @send_cmd(i8* %25, i32 6, i8* %26, i32 1)
%28 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = and i32 %30, 64
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %2
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %35)
br label %37
37: ; preds = %33, %2
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"error setting property %04x to %04x\0A\00"
define void @setprop(i32 %0, i32 %1) {
%3 = alloca [5 x i8]
%4 = alloca [1 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
store i8 18, i8* %5
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 1
store i8 0, i8* %7
%8 = sdiv i32 %0, 256
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
store i8 %9, i8* %10
%11 = trunc i32 %0 to i8
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 3
store i8 %11, i8* %12
%13 = sdiv i32 %1, 256
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
store i8 %14, i8* %15
%16 = trunc i32 %1 to i8
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 5
store i8 %16, i8* %17
%18 = call i32 @send_cmd(i8* %5, i32 6, i8* %6, i32 1)
%19 = load i8, i8* %6
%20 = and i8 %19, 64
%21 = icmp eq i8 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %2
%23 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %24
24: ; preds = %22, %2
ret void
}