#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 write_block(int, int, int, int, int /*<<< orphan*/, int /*<<< orphan*/);
int servoWrite(int pin, int angle) {
  if (angle < 0 || angle > 360) {
    printf("Invalid angle specified  %d\\n", angle);
    return -1;
  }
  int byte1 = angle & 255;
  int byte2 = angle >> 8;
  return write_block(37, pin, byte1, byte2, 0, 0);
}


x86 assembly (clang, -O0):
<servoWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1145 <servoWrite+0x25>
cmpl   $0x168,-0xc(%rbp)
jle    1160 <servoWrite+0x40>
mov    -0xc(%rbp),%esi
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1190 <servoWrite+0x70>
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x25,%edi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1030 <write_block@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<servoWrite>:
mov    %esi,%ecx
cmp    $0x169,%esi
jb     1140 <servoWrite+0x20>
push   %rax
lea    0xece(%rip),%rdi
mov    %ecx,%esi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    %edi,%esi
movzbl %cl,%edx
shr    $0x8,%ecx
mov    $0x25,%edi
xor    %r8d,%r8d
xor    %r9d,%r9d
jmp    1030 <write_block@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Invalid angle specified %d\\n\00"
define i32 @servoWrite(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 360
br i1 %12, label %13, label %16
13: ; preds = %10, %2
%14 = load i32, i32* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 -1, i32* %3
br label %25
16: ; preds = %10
%17 = load i32, i32* %5
%18 = and i32 %17, 255
store i32 %18, i32* %6
%19 = load i32, i32* %5
%20 = ashr i32 %19, 8
store i32 %20, i32* %7
%21 = load i32, i32* %4
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 @write_block(i32 37, i32 %21, i32 %22, i32 %23, i32 0, i32 0)
store i32 %24, i32* %3
br label %25
25: ; preds = %16, %13
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [30 x i8] c"Invalid angle specified %d\\n\00"
define i32 @servoWrite(i32 %0, i32 %1) {
%3 = icmp ugt i32 %1, 360
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %10
6: ; preds = %2
%7 = and i32 %1, 255
%8 = lshr i32 %1, 8
%9 = tail call i32 @write_block(i32 37, i32 %0, i32 %7, i32 %8, i32 0, i32 0)
br label %10
10: ; preds = %6, %4
%11 = phi i32 [ -1, %4 ], [ %9, %6 ]
ret i32 %11
}