#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 hex2data(int, char const *);
int /*<<< orphan*/ sendMesg(char *);
int /*<<< orphan*/ send_servo_off(int);
int /*<<< orphan*/ send_servo_on(int);
void eval_set_servo_on_off(const char in[]) {
  int servoid;
  sendMesg("in on off\n");
  switch (in[0]) {
  case 'N':
    servoid = hex2data(2, &in[1]);
    send_servo_on(servoid);
    break;
  default:
    servoid = hex2data(2, &in[2]);
    send_servo_off(servoid);
    break;
  }
}


x86 assembly (clang, -O0):
<eval_set_servo_on_off>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1050 <sendMesg@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
sub    $0x4e,%al
jne    118d <eval_set_servo_on_off+0x4d>
jmp    116b <eval_set_servo_on_off+0x2b>
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    $0x2,%edi
call   1040 <hex2data@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <send_servo_on@plt>
jmp    11aa <eval_set_servo_on_off+0x6a>
mov    -0x8(%rbp),%rsi
add    $0x2,%rsi
mov    $0x2,%edi
call   1040 <hex2data@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <send_servo_off@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_set_servo_on_off>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
call   1050 <sendMesg@plt>
cmpb   $0x4e,(%rbx)
jne    116e <eval_set_servo_on_off+0x2e>
add    $0x1,%rbx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1040 <hex2data@plt>
mov    %eax,%edi
pop    %rbx
jmp    1030 <send_servo_on@plt>
add    $0x2,%rbx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1040 <hex2data@plt>
mov    %eax,%edi
pop    %rbx
jmp    1060 <send_servo_off@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"in on off\0A\00"
define void @eval_set_servo_on_off(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @sendMesg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %15 [
i32 78, label %9
]
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i32 @hex2data(i32 2, i8* %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @send_servo_on(i32 %13)
br label %21
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = call i32 @hex2data(i32 2, i8* %17)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = call i32 @send_servo_off(i32 %19)
br label %21
21: ; preds = %15, %9
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"in on off\0A\00"
define void @eval_set_servo_on_off(i8* %0) {
%2 = tail call i32 @sendMesg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 78
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = tail call i32 @hex2data(i32 2, i8* %6)
%8 = tail call i32 @send_servo_on(i32 %7)
br label %13
9: ; preds = %1
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = tail call i32 @hex2data(i32 2, i8* %10)
%12 = tail call i32 @send_servo_off(i32 %11)
br label %13
13: ; preds = %9, %5
ret void
}