#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ remote;

/* Variables and functions */
int get_led_duty(int);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ led(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void echo(int sd) {
  int len, n;
  char bufin[1024 * 1024];
  char cmd;
  char arg[20];
  char str_val[10];
  struct sockaddr_in remote;
  int chan, rchan, gchan, bchan;
  int val, rval, gval, bval;
  len = sizeof(remote);
  while (1) {
    n = recvfrom(sd, bufin, 1024 * 1024, 0, (struct sockaddr *)&remote, &len);
    printf("Got a datagram from %s port %d\n", inet_ntoa(remote.sin_addr),
           ntohs(remote.sin_port));
    if (n < 0) {
      perror("Error receiving data");
    } else {
      printf("GOT %d BYTES\n", n);
      strcpy(arg, "");
      sscanf(bufin, "%c%s", &cmd, &arg);
      printf("cmd:%c-arg:%s\n", cmd, arg);
      if (cmd == 'X') {
        sscanf(arg, "%3d%3d%3d%3d%3d%3d", &rchan, &gchan, &bchan, &rval, &gval,
               &bval);
        printf("rchan: %d rval: %d\n", rchan, rval);
        printf("gchan: %d gval: %d\n", gchan, gval);
        printf("bchan: %d bval: %d\n", bchan, bval);
        led(rchan, rval);
        led(gchan, gval);
        led(bchan, bval);
      } else if (cmd == 'S') {
        sscanf(arg, "%3d%3d", &chan, &val);
        printf("chan: %d val: %d\n", chan, val);
        led(chan, val);
      } else if (cmd == 'R') {
        sscanf(arg, "%3d", &chan);
        printf("read chan: %03d\n", chan);
        val = get_led_duty(chan);
        sprintf(str_val, "%03d\n", val);
        sendto(sd, str_val, 4, 0, (struct sockaddr *)&remote, len);
      } else if (cmd == 'Y') {
        sscanf(arg, "%3d%3d%3d", &rchan, &gchan, &bchan);
        printf("read rchan: %03d\n", rchan);
        printf("read gchan: %03d\n", gchan);
        printf("read bchan: %03d\n", bchan);
        rval = get_led_duty(rchan);
        gval = get_led_duty(gchan);
        bval = get_led_duty(bchan);
        printf("read rval: %03d\n", rval);
        printf("read gval: %03d\n", gval);
        printf("read bval: %03d\n", bval);
        printf("%03d%03d%03d\n", rval, gval, bval);
        sprintf(str_val, "%03d%03d%03d\n", rval, gval, bval);
        sendto(sd, str_val, 10, 0, (struct sockaddr *)&remote, len);
      }
    }
  }
}


x86 assembly (clang, -O0):
<echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100080,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x8,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x100010(%rbp),%rsi
lea    -0x100048(%rbp),%r8
mov    $0x100000,%edx
xor    %ecx,%ecx
lea    -0x8(%rbp),%r9
call   1080 <recvfrom@plt>
mov    %eax,-0xc(%rbp)
mov    -0x100044(%rbp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,-0x100070(%rbp)
mov    -0x100048(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0x100070(%rbp),%rsi
mov    %eax,%edx
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    1238 <echo+0x88>
lea    0xdf2(%rip),%rdi
call   10c0 <perror@plt>
jmp    15d0 <echo+0x420>
mov    -0xc(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x100030(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x100010(%rbp),%rdi
lea    0xdd9(%rip),%rsi
lea    -0x100011(%rbp),%rdx
lea    -0x100030(%rbp),%rcx
mov    $0x0,%al
call   1090 <sscanf@plt>
movsbl -0x100011(%rbp),%esi
lea    -0x100030(%rbp),%rdx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x100011(%rbp),%eax
cmp    $0x58,%eax
jne    1379 <echo+0x1c9>
lea    -0x100030(%rbp),%rdi
lea    0xd9e(%rip),%rsi
lea    -0x100050(%rbp),%rdx
lea    -0x100054(%rbp),%rcx
lea    -0x100058(%rbp),%r8
lea    -0x100060(%rbp),%r9
lea    -0x100064(%rbp),%r10
lea    -0x100068(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x100050(%rbp),%esi
mov    -0x100060(%rbp),%edx
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100054(%rbp),%esi
mov    -0x100064(%rbp),%edx
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100058(%rbp),%esi
mov    -0x100068(%rbp),%edx
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100050(%rbp),%edi
mov    -0x100060(%rbp),%esi
call   1030 <led@plt>
mov    -0x100054(%rbp),%edi
mov    -0x100064(%rbp),%esi
call   1030 <led@plt>
mov    -0x100058(%rbp),%edi
mov    -0x100068(%rbp),%esi
call   1030 <led@plt>
jmp    15cb <echo+0x41b>
movsbl -0x100011(%rbp),%eax
cmp    $0x53,%eax
jne    13dc <echo+0x22c>
lea    -0x100030(%rbp),%rdi
lea    0xccc(%rip),%rsi
lea    -0x10004c(%rbp),%rdx
lea    -0x10005c(%rbp),%rcx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x10004c(%rbp),%esi
mov    -0x10005c(%rbp),%edx
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10004c(%rbp),%edi
mov    -0x10005c(%rbp),%esi
call   1030 <led@plt>
jmp    15c6 <echo+0x416>
movsbl -0x100011(%rbp),%eax
cmp    $0x52,%eax
jne    146e <echo+0x2be>
lea    -0x100030(%rbp),%rdi
lea    0xc6c(%rip),%rsi
lea    -0x10004c(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x10004c(%rbp),%esi
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10004c(%rbp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,-0x10005c(%rbp)
lea    -0x10003a(%rbp),%rdi
mov    -0x10005c(%rbp),%edx
lea    0xceb(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x10003a(%rbp),%rsi
lea    -0x100048(%rbp),%r8
mov    -0x8(%rbp),%r9d
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
jmp    15c1 <echo+0x411>
movsbl -0x100011(%rbp),%eax
cmp    $0x59,%eax
jne    15bc <echo+0x40c>
lea    -0x100030(%rbp),%rdi
lea    0xbd4(%rip),%rsi
lea    -0x100050(%rbp),%rdx
lea    -0x100054(%rbp),%rcx
lea    -0x100058(%rbp),%r8
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x100050(%rbp),%esi
lea    0xc14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100054(%rbp),%esi
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100058(%rbp),%esi
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100050(%rbp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,-0x100060(%rbp)
mov    -0x100054(%rbp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,-0x100064(%rbp)
mov    -0x100058(%rbp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,-0x100068(%rbp)
mov    -0x100060(%rbp),%esi
lea    0xbdb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100064(%rbp),%esi
lea    0xbd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100068(%rbp),%esi
lea    0xbd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x100060(%rbp),%esi
mov    -0x100064(%rbp),%edx
mov    -0x100068(%rbp),%ecx
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x10003a(%rbp),%rdi
mov    -0x100060(%rbp),%edx
mov    -0x100064(%rbp),%ecx
mov    -0x100068(%rbp),%r8d
lea    0xb9e(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x10003a(%rbp),%rsi
lea    -0x100048(%rbp),%r8
mov    -0x8(%rbp),%r9d
mov    $0xa,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
jmp    15c1 <echo+0x411>
jmp    15c6 <echo+0x416>
jmp    15cb <echo+0x41b>
jmp    15d0 <echo+0x420>
jmp    11c5 <echo+0x15>

x86 assembly (clang, -O2):
<echo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100068,%rsp
mov    %edi,0x2c(%rsp)
movl   $0x8,0x34(%rsp)
lea    0x60(%rsp),%r14
lea    0x38(%rsp),%r15
lea    0x40(%rsp),%rbp
jmp    11ec <echo+0x3c>
xchg   %ax,%ax
lea    0xe59(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c(%rsp),%edi
mov    %r14,%rsi
mov    $0x100000,%edx
xor    %ecx,%ecx
mov    %r15,%r8
lea    0x34(%rsp),%r9
call   1080 <recvfrom@plt>
mov    %eax,%r12d
mov    0x3c(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%r13
mov    0x38(%rsp),%edi
call   10b0 <ntohs@plt>
lea    0xdfa(%rip),%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12d,%r12d
js     11e0 <echo+0x30>
lea    0xe17(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
lea    0xe10(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
lea    0xe02(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1090 <sscanf@plt>
movsbl 0xf(%rsp),%esi
lea    0xdec(%rip),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0xf(%rsp),%eax
add    $0xae,%al
cmp    $0x7,%al
ja     11ec <echo+0x3c>
movzbl %al,%eax
lea    0xd61(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbp,%rdi
lea    0xdd4(%rip),%rsi
lea    0x28(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0x28(%rsp),%esi
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x28(%rsp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,0x30(%rsp)
lea    0x56(%rsp),%rbp
mov    %rbp,%rdi
lea    0xe60(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    0x34(%rsp),%r9d
mov    0x2c(%rsp),%edi
mov    %rbp,%rsi
lea    0x38(%rsp),%r15
lea    0x40(%rsp),%rbp
mov    $0x4,%edx
jmp    150a <echo+0x35a>
mov    %rbp,%rdi
lea    0xd64(%rip),%rsi
lea    0x28(%rsp),%rdx
lea    0x30(%rsp),%rcx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0x28(%rsp),%esi
mov    0x30(%rsp),%edx
lea    0xd87(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x28(%rsp),%edi
mov    0x30(%rsp),%esi
call   1030 <led@plt>
jmp    11ec <echo+0x3c>
mov    %rbp,%rdi
lea    0xd15(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
xor    %eax,%eax
lea    0x10(%rsp),%rbx
push   %rbx
lea    0x48(%rsp),%rbp
lea    0x1c(%rsp),%rbx
push   %rbx
call   1090 <sscanf@plt>
add    $0x10,%rsp
mov    0x24(%rsp),%esi
mov    0x18(%rsp),%edx
lea    0xce9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    0x14(%rsp),%edx
lea    0xce7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    0x10(%rsp),%edx
lea    0xce5(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%edi
mov    0x18(%rsp),%esi
call   1030 <led@plt>
mov    0x20(%rsp),%edi
mov    0x14(%rsp),%esi
call   1030 <led@plt>
mov    0x1c(%rsp),%edi
mov    0x10(%rsp),%esi
call   1030 <led@plt>
jmp    11ec <echo+0x3c>
mov    %rbp,%rdi
lea    0xc76(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0x24(%rsp),%esi
lea    0xcbe(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xcbe(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xcbe(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,0x18(%rsp)
mov    0x20(%rsp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,0x14(%rsp)
mov    0x1c(%rsp),%edi
call   10a0 <get_led_duty@plt>
mov    %eax,0x10(%rsp)
mov    0x18(%rsp),%esi
lea    0xc97(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xc96(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xc95(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xc8c(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
lea    0x56(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    0x34(%rsp),%r9d
mov    0x2c(%rsp),%edi
mov    %rbp,%rsi
lea    0x38(%rsp),%r15
lea    0x40(%rsp),%rbp
mov    $0xa,%edx
xor    %ecx,%ecx
mov    %r15,%r8
call   1070 <sendto@plt>
jmp    11ec <echo+0x3c>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [32 x i8] c"Got a datagram from %s port %d\0A\00"
@.str.1 = [21 x i8] c"Error receiving data\00"
@.str.2 = [14 x i8] c"GOT %d BYTES\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [5 x i8] c"%c%s\00"
@.str.5 = [15 x i8] c"cmd:%c-arg:%s\0A\00"
@.str.6 = [19 x i8] c"%3d%3d%3d%3d%3d%3d\00"
@.str.7 = [20 x i8] c"rchan: %d rval: %d\0A\00"
@.str.8 = [20 x i8] c"gchan: %d gval: %d\0A\00"
@.str.9 = [20 x i8] c"bchan: %d bval: %d\0A\00"
@.str.10 = [7 x i8] c"%3d%3d\00"
@.str.11 = [18 x i8] c"chan: %d val: %d\0A\00"
@.str.12 = [4 x i8] c"%3d\00"
@.str.13 = [17 x i8] c"read chan: %03d\0A\00"
@.str.14 = [6 x i8] c"%03d\0A\00"
@.str.15 = [10 x i8] c"%3d%3d%3d\00"
@.str.16 = [18 x i8] c"read rchan: %03d\0A\00"
@.str.17 = [18 x i8] c"read gchan: %03d\0A\00"
@.str.18 = [18 x i8] c"read bchan: %03d\0A\00"
@.str.19 = [17 x i8] c"read rval: %03d\0A\00"
@.str.20 = [17 x i8] c"read gval: %03d\0A\00"
@.str.21 = [17 x i8] c"read bval: %03d\0A\00"
@.str.22 = [14 x i8] c"%03d%03d%03d\0A\00"
define void @echo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1048576 x i8]
%6 = alloca i8
%7 = alloca [20 x i8]
%8 = alloca [10 x i8]
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 %0, i32* %2
store i32 8, i32* %3
br label %18
18: ; preds = %1, %144
%19 = load i32, i32* %2
%20 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %5, i64 0, i64 0
%21 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%22 = call i32 @recvfrom(i32 %19, i8* %20, i32 1048576, i32 0, %struct.sockaddr* %21, i32* %3)
store i32 %22, i32* %4
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i8* @inet_ntoa(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @ntohs(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %25, i32 %28)
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %18
%33 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %144
34: ; preds = %18
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%39 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %5, i64 0, i64 0
%40 = call i32 (i8*, i8*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %6, [20 x i8]* %7)
%41 = load i8, i8* %6
%42 = sext i8 %41 to i32
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %42, i8* %43)
%45 = load i8, i8* %6
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 88
br i1 %47, label %48, label %69
48: ; preds = %34
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%50 = call i32 (i8*, i8*, ...) @sscanf(i8* %49, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32* %11, i32* %12, i32* %13, i32* %15, i32* %16, i32* %17)
%51 = load i32, i32* %11
%52 = load i32, i32* %15
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %51, i32 %52)
%54 = load i32, i32* %12
%55 = load i32, i32* %16
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %54, i32 %55)
%57 = load i32, i32* %13
%58 = load i32, i32* %17
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %57, i32 %58)
%60 = load i32, i32* %11
%61 = load i32, i32* %15
%62 = call i32 @led(i32 %60, i32 %61)
%63 = load i32, i32* %12
%64 = load i32, i32* %16
%65 = call i32 @led(i32 %63, i32 %64)
%66 = load i32, i32* %13
%67 = load i32, i32* %17
%68 = call i32 @led(i32 %66, i32 %67)
br label %143
69: ; preds = %34
%70 = load i8, i8* %6
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 83
br i1 %72, label %73, label %82
73: ; preds = %69
%74 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%75 = call i32 (i8*, i8*, ...) @sscanf(i8* %74, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32* %10, i32* %14)
%76 = load i32, i32* %10
%77 = load i32, i32* %14
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %76, i32 %77)
%79 = load i32, i32* %10
%80 = load i32, i32* %14
%81 = call i32 @led(i32 %79, i32 %80)
br label %142
82: ; preds = %69
%83 = load i8, i8* %6
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 82
br i1 %85, label %86, label %101
86: ; preds = %82
%87 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%88 = call i32 (i8*, i8*, ...) @sscanf(i8* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32* %10)
%89 = load i32, i32* %10
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i32 %89)
%91 = load i32, i32* %10
%92 = call i32 @get_led_duty(i32 %91)
store i32 %92, i32* %14
%93 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%94 = load i32, i32* %14
%95 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %93, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %2
%97 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%98 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%99 = load i32, i32* %3
%100 = call i32 @sendto(i32 %96, i8* %97, i32 4, i32 0, %struct.sockaddr* %98, i32 %99)
br label %141
101: ; preds = %82
%102 = load i8, i8* %6
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 89
br i1 %104, label %105, label %140
105: ; preds = %101
%106 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%107 = call i32 (i8*, i8*, ...) @sscanf(i8* %106, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%108 = load i32, i32* %11
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0), i32 %108)
%110 = load i32, i32* %12
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i32 %110)
%112 = load i32, i32* %13
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0), i32 %112)
%114 = load i32, i32* %11
%115 = call i32 @get_led_duty(i32 %114)
store i32 %115, i32* %15
%116 = load i32, i32* %12
%117 = call i32 @get_led_duty(i32 %116)
store i32 %117, i32* %16
%118 = load i32, i32* %13
%119 = call i32 @get_led_duty(i32 %118)
store i32 %119, i32* %17
%120 = load i32, i32* %15
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0), i32 %120)
%122 = load i32, i32* %16
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i32 %122)
%124 = load i32, i32* %17
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %15
%127 = load i32, i32* %16
%128 = load i32, i32* %17
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0), i32 %126, i32 %127, i32 %128)
%130 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%131 = load i32, i32* %15
%132 = load i32, i32* %16
%133 = load i32, i32* %17
%134 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %130, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0), i32 %131, i32 %132, i32 %133)
%135 = load i32, i32* %2
%136 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%137 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%138 = load i32, i32* %3
%139 = call i32 @sendto(i32 %135, i8* %136, i32 10, i32 0, %struct.sockaddr* %137, i32 %138)
br label %140
140: ; preds = %105, %101
br label %141
141: ; preds = %140, %86
br label %142
142: ; preds = %141, %73
br label %143
143: ; preds = %142, %48
br label %144
144: ; preds = %143, %32
br label %18
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [32 x i8] c"Got a datagram from %s port %d\0A\00"
@.str.1 = [21 x i8] c"Error receiving data\00"
@.str.2 = [14 x i8] c"GOT %d BYTES\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [5 x i8] c"%c%s\00"
@.str.5 = [15 x i8] c"cmd:%c-arg:%s\0A\00"
@.str.6 = [19 x i8] c"%3d%3d%3d%3d%3d%3d\00"
@.str.7 = [20 x i8] c"rchan: %d rval: %d\0A\00"
@.str.8 = [20 x i8] c"gchan: %d gval: %d\0A\00"
@.str.9 = [20 x i8] c"bchan: %d bval: %d\0A\00"
@.str.10 = [7 x i8] c"%3d%3d\00"
@.str.11 = [18 x i8] c"chan: %d val: %d\0A\00"
@.str.12 = [4 x i8] c"%3d\00"
@.str.13 = [17 x i8] c"read chan: %03d\0A\00"
@.str.14 = [6 x i8] c"%03d\0A\00"
@.str.15 = [10 x i8] c"%3d%3d%3d\00"
@.str.16 = [18 x i8] c"read rchan: %03d\0A\00"
@.str.17 = [18 x i8] c"read gchan: %03d\0A\00"
@.str.18 = [18 x i8] c"read bchan: %03d\0A\00"
@.str.19 = [17 x i8] c"read rval: %03d\0A\00"
@.str.20 = [17 x i8] c"read gval: %03d\0A\00"
@.str.21 = [17 x i8] c"read bval: %03d\0A\00"
@.str.22 = [14 x i8] c"%03d%03d%03d\0A\00"
define void @echo(i32 %0) {
%2 = alloca i32
%3 = alloca [1048576 x i8]
%4 = alloca i8
%5 = alloca [20 x i8]
%6 = alloca [10 x i8]
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = bitcast i32* %2 to i8*
%17 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%20 = bitcast %struct.sockaddr_in* %7 to i8*
%21 = bitcast i32* %8 to i8*
%22 = bitcast i32* %9 to i8*
%23 = bitcast i32* %10 to i8*
%24 = bitcast i32* %11 to i8*
%25 = bitcast i32* %12 to i8*
%26 = bitcast i32* %13 to i8*
%27 = bitcast i32* %14 to i8*
%28 = bitcast i32* %15 to i8*
store i32 8, i32* %2
%29 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
br label %32
32: ; preds = %50, %1
%33 = call i32 @recvfrom(i32 %0, i8* %17, i32 1048576, i32 0, %struct.sockaddr* %29, i32* %2)
%34 = load i32, i32* %30
%35 = call i8* @inet_ntoa(i32 %34)
%36 = load i32, i32* %31
%37 = call i32 @ntohs(i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %35, i32 %37)
%39 = icmp slt i32 %33, 0
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %50
42: ; preds = %32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%44 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 (i8*, i8*, ...) @sscanf(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %4, [20 x i8]* %5)
%46 = load i8, i8* %4
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %47, i8* %18)
%49 = load i8, i8* %4
switch i8 %49, label %50 [
i8 88, label %51
i8 83, label %71
i8 82, label %79
i8 89, label %88
]
50: ; preds = %42, %51, %79, %88, %71, %40
br label %32
51: ; preds = %42
%52 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32* %9, i32* %10, i32* %11, i32* %13, i32* %14, i32* %15)
%53 = load i32, i32* %9
%54 = load i32, i32* %13
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %53, i32 %54)
%56 = load i32, i32* %10
%57 = load i32, i32* %14
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %56, i32 %57)
%59 = load i32, i32* %11
%60 = load i32, i32* %15
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %59, i32 %60)
%62 = load i32, i32* %9
%63 = load i32, i32* %13
%64 = call i32 @led(i32 %62, i32 %63)
%65 = load i32, i32* %10
%66 = load i32, i32* %14
%67 = call i32 @led(i32 %65, i32 %66)
%68 = load i32, i32* %11
%69 = load i32, i32* %15
%70 = call i32 @led(i32 %68, i32 %69)
br label %50
71: ; preds = %42
%72 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32* %8, i32* %12)
%73 = load i32, i32* %8
%74 = load i32, i32* %12
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %73, i32 %74)
%76 = load i32, i32* %8
%77 = load i32, i32* %12
%78 = call i32 @led(i32 %76, i32 %77)
br label %50
79: ; preds = %42
%80 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32* %8)
%81 = load i32, i32* %8
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i32 %81)
%83 = load i32, i32* %8
%84 = call i32 @get_led_duty(i32 %83)
store i32 %84, i32* %12
%85 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 %84)
%86 = load i32, i32* %2
%87 = call i32 @sendto(i32 %0, i8* %19, i32 4, i32 0, %struct.sockaddr* %29, i32 %86)
br label %50
88: ; preds = %42
%89 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i32* %9, i32* %10, i32* %11)
%90 = load i32, i32* %9
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0), i32 %90)
%92 = load i32, i32* %10
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %11
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %9
%97 = call i32 @get_led_duty(i32 %96)
store i32 %97, i32* %13
%98 = load i32, i32* %10
%99 = call i32 @get_led_duty(i32 %98)
store i32 %99, i32* %14
%100 = load i32, i32* %11
%101 = call i32 @get_led_duty(i32 %100)
store i32 %101, i32* %15
%102 = load i32, i32* %13
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0), i32 %102)
%104 = load i32, i32* %14
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0), i32 %104)
%106 = load i32, i32* %15
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %13
%109 = load i32, i32* %14
%110 = load i32, i32* %15
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0), i32 %108, i32 %109, i32 %110)
%112 = load i32, i32* %13
%113 = load i32, i32* %14
%114 = load i32, i32* %15
%115 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0), i32 %112, i32 %113, i32 %114)
%116 = load i32, i32* %2
%117 = call i32 @sendto(i32 %0, i8* %19, i32 10, i32 0, %struct.sockaddr* %29, i32 %116)
br label %50
}