#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*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ write(int, int *, int /*<<< orphan*/);
void servo_send(int fd, int servo, uint8_t value) {
  uint8_t msg[3];
  msg[0] = (uint8_t)0xFF;
  msg[1] = (uint8_t)servo;
  msg[2] = value;
  printf("%X sending servo %d value %d\n", msg[0], msg[1], msg[2]);
  write(fd, msg, (ssize_t)3);
}


x86 assembly (clang, -O0):
<servo_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0xff,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<servo_send>:
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ecx
mov    %esi,%edx
mov    %edi,%ebx
movl   $0xff,0x4(%rsp)
mov    %esi,0x8(%rsp)
mov    %ecx,0xc(%rsp)
lea    0xebe(%rip),%rdi
mov    $0xff,%esi
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"%X sending servo %d value %d\0A\00"
define void @servo_send(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [3 x i32]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
store i32 255, i32* %8
%9 = load i32, i32* %5
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
store i32 %9, i32* %10
%11 = load i32, i32* %6
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
store i32 %11, i32* %12
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %16, i32 %18)
%20 = load i32, i32* %4
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%22 = call i32 @write(i32 %20, i32* %21, i32 3)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"%X sending servo %d value %d\0A\00"
define void @servo_send(i32 %0, i32 %1, i32 %2) {
%4 = alloca [3 x i32]
%5 = bitcast [3 x i32]* %4 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
store i32 255, i32* %6
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
store i32 %1, i32* %7
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
store i32 %2, i32* %8
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 255, i32 %1, i32 %2)
%10 = call i32 @write(i32 %0, i32* %6, i32 3)
ret void
}