#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ my_addr;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
scalar_t__ daemon(int /*<<< orphan*/, int);
int /*<<< orphan*/ err(char *);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
#define no_argument 128
int ntohs(int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char);
int /*<<< orphan*/ strlen(char *);
scalar_t__ write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct sockaddr_in my_addr, cli_addr;
  int sockfd, i;
  socklen_t slen = sizeof(cli_addr);
  unsigned char buf[512];
  int fd;
  int daemonize = 1;
  while (1) {
    int c;
    int option_index;
    static struct option long_options[] = {{"debug", no_argument, 0, 'd'},
                                           {"help", no_argument, 0, 'h'},
                                           {0, 0, 0, 0}};
    c = getopt_long(argc, argv, "d", long_options, &option_index);
    if (c == -1) {
      break;
    } else if (c == 'd') {
      daemonize = 0;
    } else if (c == 'h') {
      printf("\nUsage: %s <options>\n\n"
             "Options:\n"
             " --debug      Run in local mode (don't daemonize)\n"
             " --help       Show this prompt.\n",
             argv[0]);
    } else {
      err("Invalid Parameters\n");
    }
  }
  if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
    err("socket");
  fd = open("/dev/servoblaster", O_RDWR);
  if (fd < 0) {
    err("open /dev/servoblaster");
  }
  bzero(&my_addr, sizeof(my_addr));
  my_addr.sin_family = AF_INET;
  my_addr.sin_port = htons(2002);
  my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(my_addr)) == -1)
    err("bind");
  if (daemonize && daemon(0, 1) < 0)
    err("Failed to daemonize process\n");
  while (1) {
    int cnt;
    cnt = recvfrom(sockfd, (char *)buf, 512, 0, (struct sockaddr *)&cli_addr,
                   &slen);
    if (cnt == -1)
      err("recvfrom()");
    if (!daemonize)
      printf("\n%s:%d ", inet_ntoa(cli_addr.sin_addr),
             ntohs(cli_addr.sin_port));
    if (cnt == 3) {
      char str[32];
      sprintf(str, "0=%u%%\n1=%u%%\n2=%u%%\n",
              (unsigned char)((float)buf[0] / 2.55),
              (unsigned char)((float)buf[1] / 2.55),
              (unsigned char)((float)buf[2] / 2.55));
      if (write(fd, str, strlen(str)) < 0) {
        err("device write failed");
      }
      if (!daemonize)
        printf("x=%u%% y=%u%%, z=%u%%", (unsigned char)((float)buf[0] / 2.55),
               (unsigned char)((float)buf[1] / 2.55),
               (unsigned char)((float)buf[2] / 2.55));
    }
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc,-0x3c(%rbp)
movl   $0x1,-0x248(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xedc(%rip),%rdx
lea    0x2e71(%rip),%rcx
lea    -0x250(%rbp),%r8
call   1060 <getopt_long@plt>
mov    %eax,-0x24c(%rbp)
cmpl   $0xffffffff,-0x24c(%rbp)
jne    1263 <main+0x63>
jmp    12c1 <main+0xc1>
cmpl   $0x64,-0x24c(%rbp)
jne    127f <main+0x7f>
movl   $0x0,-0x248(%rbp)
jmp    12b7 <main+0xb7>
cmpl   $0x68,-0x24c(%rbp)
jne    12a6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    12b2 <main+0xb2>
lea    0xdd8(%rip),%rdi
call   10a0 <err@plt>
jmp    12b7 <main+0xb7>
jmp    12bc <main+0xbc>
jmp    122a <main+0x2a>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
mov    0x2cff(%rip),%rax
mov    (%rax),%esi
mov    0x2cde(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    12f9 <main+0xf9>
lea    0xda5(%rip),%rdi
call   10a0 <err@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
lea    0xd9c(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0x244(%rbp)
cmpl   $0x0,-0x244(%rbp)
jge    132d <main+0x12d>
lea    0xd78(%rip),%rdi
call   10a0 <err@plt>
lea    -0x20(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x7d2,%edi
call   1070 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    0x2c7d(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    138b <main+0x18b>
lea    0xd31(%rip),%rdi
call   10a0 <err@plt>
cmpl   $0x0,-0x248(%rbp)
je     13ba <main+0x1ba>
xor    %edi,%edi
mov    $0x1,%esi
call   10c0 <daemon@plt>
cmp    $0x0,%rax
jge    13ba <main+0x1ba>
lea    0xd07(%rip),%rdi
call   10a0 <err@plt>
jmp    13bf <main+0x1bf>
mov    -0x34(%rbp),%edi
lea    -0x240(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x200,%edx
xor    %ecx,%ecx
lea    -0x3c(%rbp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,-0x254(%rbp)
cmpl   $0xffffffff,-0x254(%rbp)
jne    13fc <main+0x1fc>
lea    0xce2(%rip),%rdi
call   10a0 <err@plt>
cmpl   $0x0,-0x248(%rbp)
jne    1437 <main+0x237>
mov    -0x2c(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x288(%rbp)
mov    -0x30(%rbp),%edi
call   10d0 <ntohs@plt>
mov    -0x288(%rbp),%rsi
mov    %eax,%edx
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpl   $0x3,-0x254(%rbp)
jne    1578 <main+0x378>
lea    -0x280(%rbp),%rdi
movzbl -0x240(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xb9e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%dl
movzbl -0x23f(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
movzbl -0x23e(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
lea    0xc49(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %al,%r8d
call   1110 <sprintf@plt>
mov    -0x244(%rbp),%eax
mov    %eax,-0x294(%rbp)
lea    -0x280(%rbp),%rax
mov    %rax,-0x290(%rbp)
lea    -0x280(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x294(%rbp),%edi
mov    -0x290(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1502 <main+0x302>
lea    0xc05(%rip),%rdi
call   10a0 <err@plt>
cmpl   $0x0,-0x248(%rbp)
jne    1573 <main+0x373>
movzbl -0x240(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xada(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%esi
movzbl -0x23f(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%edx
movzbl -0x23e(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%ecx
lea    0xbaa(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1578 <main+0x378>
jmp    13bf <main+0x1bf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x258,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0xc,0xc(%rsp)
mov    $0x1,%r12d
lea    0xee9(%rip),%r14
lea    0x2e7e(%rip),%r15
lea    0x50(%rsp),%r13
jmp    1257 <main+0x57>
nopl   0x0(%rax)
mov    (%rbx),%rsi
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12d,%ecx
mov    %ecx,%r12d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r13,%r8
call   1060 <getopt_long@plt>
mov    $0x0,%ecx
cmp    $0x64,%eax
je     1254 <main+0x54>
cmp    $0x68,%eax
je     1240 <main+0x40>
cmp    $0xffffffff,%eax
je     128c <main+0x8c>
lea    0xe00(%rip),%rdi
call   10a0 <err@plt>
jmp    1251 <main+0x51>
mov    0x2d4d(%rip),%r14
mov    (%r14),%edi
mov    0x2d33(%rip),%rax
mov    (%rax),%esi
mov    0x2d12(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,(%rsp)
cmp    $0xffffffff,%eax
jne    12c1 <main+0xc1>
lea    0xddd(%rip),%rdi
call   10a0 <err@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
lea    0xdd4(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
jns    12ea <main+0xea>
lea    0xdbb(%rip),%rdi
call   10a0 <err@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    (%r14),%eax
mov    %eax,0x18(%rsp)
mov    $0x7d2,%edi
call   1070 <htons@plt>
mov    %eax,0x10(%rsp)
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    (%rsp),%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
je     133f <main+0x13f>
test   %r12d,%r12d
jne    1350 <main+0x150>
jmp    136d <main+0x16d>
lea    0xd71(%rip),%rdi
call   10a0 <err@plt>
test   %r12d,%r12d
je     136d <main+0x16d>
xor    %edi,%edi
mov    $0x1,%esi
call   10c0 <daemon@plt>
test   %rax,%rax
jns    136d <main+0x16d>
lea    0xd54(%rip),%rdi
call   10a0 <err@plt>
lea    0x50(%rsp),%r15
lea    0x20(%rsp),%rbx
lea    0xc(%rsp),%r13
mov    %r12d,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%edi
mov    %r15,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r13,%r9
call   10b0 <recvfrom@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     13c0 <main+0x1c0>
test   %r12d,%r12d
je     13d1 <main+0x1d1>
cmp    $0x3,%r14d
jne    1390 <main+0x190>
jmp    140a <main+0x20a>
nopl   (%rax)
lea    0xd12(%rip),%rdi
call   10a0 <err@plt>
test   %r12d,%r12d
jne    13b5 <main+0x1b5>
mov    0x24(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %r15,%rbp
mov    %rax,%r15
mov    0x20(%rsp),%edi
call   10d0 <ntohs@plt>
lea    0xcf4(%rip),%rdi
mov    %r15,%rsi
mov    0x4(%rsp),%r12d
mov    %rbp,%r15
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0x3,%r14d
jne    1390 <main+0x190>
movzbl 0x50(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xbe2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl 0x51(%rsp),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movzbl 0x52(%rsp),%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
movzbl %al,%edx
movzbl %cl,%ecx
movzbl %sil,%r8d
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
lea    0xc85(%rip),%rsi
call   1110 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %rax,%rax
js     1492 <main+0x292>
test   %r12d,%r12d
jne    1390 <main+0x190>
jmp    14a7 <main+0x2a7>
lea    0xc69(%rip),%rdi
call   10a0 <err@plt>
test   %r12d,%r12d
jne    1390 <main+0x190>
movzbl 0x50(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xb45(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl 0x51(%rsp),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movzbl %al,%esi
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%edx
movzbl 0x52(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%ecx
lea    0xc1b(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1390 <main+0x190>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option zeroinitializer]
@.str = [6 x i8] c"debug\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [2 x i8] c"d\00"
@.str.3 = [114 x i8] c"\0AUsage: %s <options>\0A\0AOptions:\0A --debug Run in local mode (don't daemonize)\0A --help Show this prompt.\0A\00"
@.str.4 = [20 x i8] c"Invalid Parameters\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.5 = [7 x i8] c"socket\00"
@.str.6 = [18 x i8] c"/dev/servoblaster\00"
@O_RDWR = global i32 0
@.str.7 = [23 x i8] c"open /dev/servoblaster\00"
@INADDR_ANY = global i32 0
@.str.8 = [5 x i8] c"bind\00"
@.str.9 = [29 x i8] c"Failed to daemonize process\0A\00"
@.str.10 = [11 x i8] c"recvfrom()\00"
@.str.11 = [8 x i8] c"\0A%s:%d \00"
@.str.12 = [22 x i8] c"0=%u%%\0A1=%u%%\0A2=%u%%\0A\00"
@.str.13 = [20 x i8] c"device write failed\00"
@.str.14 = [22 x i8] c"x=%u%% y=%u%%, z=%u%%\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [512 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12, i32* %10
store i32 1, i32* %13
br label %18
18: ; preds = %2, %41
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt_long(i32 %19, i8** %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %15)
store i32 %21, i32* %14
%22 = load i32, i32* %14
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %18
br label %42
25: ; preds = %18
%26 = load i32, i32* %14
%27 = icmp eq i32 %26, 100
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 0, i32* %13
br label %40
29: ; preds = %25
%30 = load i32, i32* %14
%31 = icmp eq i32 %30, 104
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %39
37: ; preds = %29
%38 = call i32 @err(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
br label %40
40: ; preds = %39, %28
br label %41
41: ; preds = %40
br label %18
42: ; preds = %24
%43 = load i32, i32* @AF_INET
%44 = load i32, i32* @SOCK_DGRAM
%45 = load i32, i32* @IPPROTO_UDP
%46 = call i32 @socket(i32 %43, i32 %44, i32 %45)
store i32 %46, i32* %8
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
%51 = load i32, i32* @O_RDWR
%52 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %51)
store i32 %52, i32* %12
%53 = load i32, i32* %12
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @err(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %57
57: ; preds = %55, %50
%58 = call i32 @bzero(%struct.sockaddr_in* %6, i32 12)
%59 = load i32, i32* @AF_INET
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %59, i32* %60
%61 = call i32 @htons(i32 2002)
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i32 %61, i32* %62
%63 = load i32, i32* @INADDR_ANY
%64 = call i32 @htonl(i32 %63)
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%66 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %65, i32 0, i32 0
store i32 %64, i32* %66
%67 = load i32, i32* %8
%68 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%69 = call i32 @bind(i32 %67, %struct.sockaddr* %68, i32 12)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %57
%72 = call i32 @err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %73
73: ; preds = %71, %57
%74 = load i32, i32* %13
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %73
%77 = call i64 @daemon(i32 0, i32 1)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 @err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
br label %81
81: ; preds = %79, %76, %73
br label %82
82: ; preds = %81, %162
%83 = load i32, i32* %8
%84 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%85 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%86 = call i32 @recvfrom(i32 %83, i8* %84, i32 512, i32 0, %struct.sockaddr* %85, i32* %10)
store i32 %86, i32* %16
%87 = load i32, i32* %16
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %91
89: ; preds = %82
%90 = call i32 @err(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %91
91: ; preds = %89, %82
%92 = load i32, i32* %13
%93 = icmp ne i32 %92, 0
br i1 %93, label %103, label %94
94: ; preds = %91
%95 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%96 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %95, i32 0, i32 0
%97 = load i32, i32* %96
%98 = call i8* @inet_ntoa(i32 %97)
%99 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%100 = load i32, i32* %99
%101 = call i32 @ntohs(i32 %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* %98, i32 %101)
br label %103
103: ; preds = %94, %91
%104 = load i32, i32* %16
%105 = icmp eq i32 %104, 3
br i1 %105, label %106, label %162
106: ; preds = %103
%107 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%108 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%109 = load i8, i8* %108
%110 = uitofp i8 %109 to float
%111 = fpext float %110 to double
%112 = fdiv double %111, 2.550000e+00
%113 = fptoui double %112 to i8
%114 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 1
%115 = load i8, i8* %114
%116 = uitofp i8 %115 to float
%117 = fpext float %116 to double
%118 = fdiv double %117, 2.550000e+00
%119 = fptoui double %118 to i8
%120 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 2
%121 = load i8, i8* %120
%122 = uitofp i8 %121 to float
%123 = fpext float %122 to double
%124 = fdiv double %123, 2.550000e+00
%125 = fptoui double %124 to i8
%126 = call i32 @sprintf(i8* %107, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8 zeroext %113, i8 zeroext %119, i8 zeroext %125)
%127 = load i32, i32* %12
%128 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%129 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%130 = call i32 @strlen(i8* %129)
%131 = call i64 @write(i32 %127, i8* %128, i32 %130)
%132 = icmp slt i64 %131, 0
br i1 %132, label %133, label %135
133: ; preds = %106
%134 = call i32 @err(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
br label %135
135: ; preds = %133, %106
%136 = load i32, i32* %13
%137 = icmp ne i32 %136, 0
br i1 %137, label %161, label %138
138: ; preds = %135
%139 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%140 = load i8, i8* %139
%141 = uitofp i8 %140 to float
%142 = fpext float %141 to double
%143 = fdiv double %142, 2.550000e+00
%144 = fptoui double %143 to i8
%145 = zext i8 %144 to i32
%146 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 1
%147 = load i8, i8* %146
%148 = uitofp i8 %147 to float
%149 = fpext float %148 to double
%150 = fdiv double %149, 2.550000e+00
%151 = fptoui double %150 to i8
%152 = zext i8 %151 to i32
%153 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 2
%154 = load i8, i8* %153
%155 = uitofp i8 %154 to float
%156 = fpext float %155 to double
%157 = fdiv double %156, 2.550000e+00
%158 = fptoui double %157 to i8
%159 = zext i8 %158 to i32
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), i32 %145, i32 %152, i32 %159)
br label %161
161: ; preds = %138, %135
br label %162
162: ; preds = %161, %103
br label %82
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option zeroinitializer]
@.str = [6 x i8] c"debug\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [2 x i8] c"d\00"
@.str.3 = [114 x i8] c"\0AUsage: %s <options>\0A\0AOptions:\0A --debug Run in local mode (don't daemonize)\0A --help Show this prompt.\0A\00"
@.str.4 = [20 x i8] c"Invalid Parameters\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.5 = [7 x i8] c"socket\00"
@.str.6 = [18 x i8] c"/dev/servoblaster\00"
@O_RDWR = global i32 0
@.str.7 = [23 x i8] c"open /dev/servoblaster\00"
@INADDR_ANY = global i32 0
@.str.8 = [5 x i8] c"bind\00"
@.str.9 = [29 x i8] c"Failed to daemonize process\0A\00"
@.str.10 = [11 x i8] c"recvfrom()\00"
@.str.11 = [8 x i8] c"\0A%s:%d \00"
@.str.12 = [22 x i8] c"0=%u%%\0A1=%u%%\0A2=%u%%\0A\00"
@.str.13 = [20 x i8] c"device write failed\00"
@.str.14 = [22 x i8] c"x=%u%% y=%u%%, z=%u%%\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [512 x i8]
%7 = alloca i32
%8 = alloca [32 x i8]
%9 = bitcast %struct.sockaddr_in* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast i32* %5 to i8*
store i32 12, i32* %5
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%13 = bitcast i32* %7 to i8*
br label %14
14: ; preds = %22, %2
%15 = phi i32 [ 1, %2 ], [ %23, %22 ]
%16 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %7)
switch i32 %16, label %20 [
i32 -1, label %24
i32 100, label %22
i32 104, label %17
]
17: ; preds = %14
%18 = load i8*, i8** %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %22
20: ; preds = %14
%21 = call i32 @err(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %17, %20, %14
%23 = phi i32 [ %15, %17 ], [ %15, %20 ], [ 0, %14 ]
br label %14
24: ; preds = %14
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = load i32, i32* @IPPROTO_UDP
%28 = call i32 @socket(i32 %25, i32 %26, i32 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = load i32, i32* @O_RDWR
%34 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @err(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
%39 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %40, i32* %41
%42 = call i32 @htons(i32 2002)
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %42, i32* %43
%44 = load i32, i32* @INADDR_ANY
%45 = call i32 @htonl(i32 %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %45, i32* %46
%47 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%48 = call i32 @bind(i32 %28, %struct.sockaddr* %47, i32 12)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %38
%51 = call i32 @err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %38
%53 = icmp eq i32 %15, 0
br i1 %53, label %59, label %54
54: ; preds = %52
%55 = call i64 @daemon(i32 0, i32 1)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @err(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
br label %59
59: ; preds = %57, %54, %52
%60 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 1
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 2
br label %66
66: ; preds = %118, %59
%67 = call i32 @recvfrom(i32 %28, i8* %12, i32 512, i32 0, %struct.sockaddr* %60, i32* %5)
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = call i32 @err(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %71
71: ; preds = %69, %66
br i1 %53, label %72, label %78
72: ; preds = %71
%73 = load i32, i32* %61
%74 = call i8* @inet_ntoa(i32 %73)
%75 = load i32, i32* %62
%76 = call i32 @ntohs(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* %74, i32 %76)
br label %78
78: ; preds = %72, %71
%79 = icmp eq i32 %67, 3
br i1 %79, label %80, label %118
80: ; preds = %78
%81 = load i8, i8* %12
%82 = uitofp i8 %81 to double
%83 = fdiv double %82, 2.550000e+00
%84 = fptoui double %83 to i8
%85 = load i8, i8* %64
%86 = uitofp i8 %85 to double
%87 = fdiv double %86, 2.550000e+00
%88 = fptoui double %87 to i8
%89 = load i8, i8* %65
%90 = uitofp i8 %89 to double
%91 = fdiv double %90, 2.550000e+00
%92 = fptoui double %91 to i8
%93 = call i32 @sprintf(i8* %63, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8 zeroext %84, i8 zeroext %88, i8 zeroext %92)
%94 = call i32 @strlen(i8* %63)
%95 = call i64 @write(i32 %34, i8* %63, i32 %94)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %80
%98 = call i32 @err(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
br label %99
99: ; preds = %97, %80
br i1 %53, label %100, label %117
100: ; preds = %99
%101 = load i8, i8* %12
%102 = uitofp i8 %101 to double
%103 = fdiv double %102, 2.550000e+00
%104 = fptoui double %103 to i8
%105 = zext i8 %104 to i32
%106 = load i8, i8* %64
%107 = uitofp i8 %106 to double
%108 = fdiv double %107, 2.550000e+00
%109 = fptoui double %108 to i8
%110 = zext i8 %109 to i32
%111 = load i8, i8* %65
%112 = uitofp i8 %111 to double
%113 = fdiv double %112, 2.550000e+00
%114 = fptoui double %113 to i8
%115 = zext i8 %114 to i32
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), i32 %105, i32 %110, i32 %115)
br label %117
117: ; preds = %100, %99
br label %118
118: ; preds = %117, %78
br label %66
}