#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 char uint8_t;
struct netio {
  int dummy;
};
struct atrf_dsc {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ atrf_buf_write(struct atrf_dsc *, char *, int);
scalar_t__ atrf_error(struct atrf_dsc *);
int /*<<< orphan*/ atrf_reg_write(struct atrf_dsc *, int, int);
scalar_t__ atrf_slp_tr(struct atrf_dsc *, int, int);
int /*<<< orphan*/ atrf_sram_write(struct atrf_dsc *, int, int);
int /*<<< orphan*/ free(char *);
int get_num(struct netio *, int, int *);
char *malloc(int);
int netio_printf(struct netio *, char *);
int netio_read(struct netio *, char *, int);
int /*<<< orphan*/ strcasecmp(char const *, char *);
int cmd_two(struct atrf_dsc *dsc, struct netio *netio, const char *cmd) {
  int n, ret;
  n = get_num(netio, 0, &ret);
  if (n < 0)
    return ret;
  if (n > 255)
    return netio_printf(netio, "-bad argument\n");
  if (!strcasecmp(cmd, "set")) {
    int val;
    val = get_num(netio, 1, &ret);
    if (val < 0)
      return ret;
    if (val > 255)
      return netio_printf(netio, "-bad argument\n");
    atrf_reg_write(dsc, n, val);
    if (atrf_error(dsc))
      return netio_printf(netio, "-I/O error\n");
    return netio_printf(netio, "+\n");
  }
  if (!strcasecmp(cmd, "write")) {
    uint8_t *tmp;
    ssize_t got;
    if (n > 128)
      return netio_printf(netio, "-bad argument\n");
    tmp = malloc(n + 1);
    if (!tmp)
      return netio_printf(netio, "-out of memory\n");
    got = netio_read(netio, tmp, n + 1);
    if (got != n + 1) {
      free(tmp);
      return -1;
    }
    if (tmp[n] != '\n') {
      free(tmp);
      return netio_printf(netio, "-unterminated command\n");
    }
    atrf_buf_write(dsc, tmp, n);
    free(tmp);
    if (atrf_error(dsc))
      return netio_printf(netio, "-I/O error\n");
    return netio_printf(netio, "+\n");
  }
  if (!strcasecmp(cmd, "setram")) {
    int val;
    val = get_num(netio, 1, &ret);
    if (val < 0)
      return ret;
    if (val > 255)
      return netio_printf(netio, "-bad argument\n");
    atrf_sram_write(dsc, n, val);
    if (atrf_error(dsc))
      return netio_printf(netio, "-I/O error\n");
    return netio_printf(netio, "+\n");
  }
  if (!strcasecmp(cmd, "slp_tr")) {
    int val;
    if (n > 1)
      return netio_printf(netio, "-bad argument\n");
    val = get_num(netio, 1, &ret);
    if (val < 0)
      return ret;
    if (val > 1)
      return netio_printf(netio, "-bad argument\n");
    if (atrf_slp_tr(dsc, n, val) < 0)
      return netio_printf(netio, "-I/O error\n");
    return netio_printf(netio, "+\n");
  }
  abort();
}


x86 assembly (clang, -O0):
<cmd_two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
lea    -0x28(%rbp),%rdx
call   1060 <get_num@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11fb <cmd_two+0x3b>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
cmpl   $0xff,-0x24(%rbp)
jle    1220 <cmd_two+0x60>
mov    -0x18(%rbp),%rdi
lea    0xded(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x20(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    12da <cmd_two+0x11a>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
lea    -0x28(%rbp),%rdx
call   1060 <get_num@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1263 <cmd_two+0xa3>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
cmpl   $0xff,-0x2c(%rbp)
jle    1288 <cmd_two+0xc8>
mov    -0x18(%rbp),%rdi
lea    0xd85(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10c0 <atrf_reg_write@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <atrf_error@plt>
cmp    $0x0,%rax
je     12c2 <cmd_two+0x102>
mov    -0x18(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x18(%rbp),%rdi
lea    0xd52(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x20(%rbp),%rdi
lea    0xd3d(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1418 <cmd_two+0x258>
cmpl   $0x80,-0x24(%rbp)
jle    1318 <cmd_two+0x158>
mov    -0x18(%rbp),%rdi
lea    0xcf5(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    134a <cmd_two+0x18a>
mov    -0x18(%rbp),%rdi
lea    0xceb(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
call   10e0 <netio_read@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     1386 <cmd_two+0x1c6>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     13bc <cmd_two+0x1fc>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xc89(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <atrf_buf_write@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <atrf_error@plt>
cmp    $0x0,%rax
je     1400 <cmd_two+0x240>
mov    -0x18(%rbp),%rdi
lea    0xc20(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x18(%rbp),%rdi
lea    0xc14(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x20(%rbp),%rdi
lea    0xc2c(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    14d2 <cmd_two+0x312>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
lea    -0x28(%rbp),%rdx
call   1060 <get_num@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    145b <cmd_two+0x29b>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
cmpl   $0xff,-0x40(%rbp)
jle    1480 <cmd_two+0x2c0>
mov    -0x18(%rbp),%rdi
lea    0xb8d(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x40(%rbp),%edx
call   1090 <atrf_sram_write@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <atrf_error@plt>
cmp    $0x0,%rax
je     14ba <cmd_two+0x2fa>
mov    -0x18(%rbp),%rdi
lea    0xb66(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x18(%rbp),%rdi
lea    0xb5a(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x20(%rbp),%rdi
lea    0xb79(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    15a2 <cmd_two+0x3e2>
cmpl   $0x1,-0x24(%rbp)
jle    150d <cmd_two+0x34d>
mov    -0x18(%rbp),%rdi
lea    0xb00(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
lea    -0x28(%rbp),%rdx
call   1060 <get_num@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1537 <cmd_two+0x377>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
cmpl   $0x1,-0x44(%rbp)
jle    1559 <cmd_two+0x399>
mov    -0x18(%rbp),%rdi
lea    0xab4(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x44(%rbp),%edx
call   1070 <atrf_slp_tr@plt>
cmp    $0x0,%rax
jge    158a <cmd_two+0x3ca>
mov    -0x18(%rbp),%rdi
lea    0xa96(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    -0x18(%rbp),%rdi
lea    0xa8a(%rip),%rsi
call   10d0 <netio_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    15a9 <cmd_two+0x3e9>
mov    $0x0,%al
call   1050 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_two>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xc(%rsp),%rdx
mov    %rsi,%rdi
xor    %esi,%esi
call   1060 <get_num@plt>
test   %eax,%eax
js     1392 <cmd_two+0x1d2>
mov    %eax,%r12d
cmp    $0x100,%eax
jb     120a <cmd_two+0x4a>
lea    0xe03(%rip),%rsi
mov    %r15,%rdi
call   10d0 <netio_printf@plt>
jmp    1396 <cmd_two+0x1d6>
lea    0xdfe(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     12b1 <cmd_two+0xf1>
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     12e8 <cmd_two+0x128>
lea    0xe10(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     1347 <cmd_two+0x187>
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
jne    13d2 <cmd_two+0x212>
cmp    $0x2,%r12d
jae    11f6 <cmd_two+0x36>
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
call   1060 <get_num@plt>
test   %eax,%eax
js     1392 <cmd_two+0x1d2>
cmp    $0x2,%eax
jae    11f6 <cmd_two+0x36>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1070 <atrf_slp_tr@plt>
test   %rax,%rax
js     1386 <cmd_two+0x1c6>
lea    0xd73(%rip),%rsi
jmp    11fd <cmd_two+0x3d>
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
call   1060 <get_num@plt>
test   %eax,%eax
js     1392 <cmd_two+0x1d2>
cmp    $0x100,%eax
jae    11f6 <cmd_two+0x36>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   10c0 <atrf_reg_write@plt>
jmp    1375 <cmd_two+0x1b5>
cmp    $0x81,%r12d
jae    11f6 <cmd_two+0x36>
lea    0x1(%r12),%ebp
mov    %ebp,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     13a3 <cmd_two+0x1e3>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   10e0 <netio_read@plt>
cmp    %ebp,%eax
jne    13af <cmd_two+0x1ef>
mov    %r12d,%eax
cmpb   $0xa,(%rbx,%rax,1)
jne    13be <cmd_two+0x1fe>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1080 <atrf_buf_write@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1375 <cmd_two+0x1b5>
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
call   1060 <get_num@plt>
test   %eax,%eax
js     1392 <cmd_two+0x1d2>
cmp    $0x100,%eax
jae    11f6 <cmd_two+0x36>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1090 <atrf_sram_write@plt>
mov    %r14,%rdi
call   10a0 <atrf_error@plt>
test   %rax,%rax
je     12a5 <cmd_two+0xe5>
lea    0xc86(%rip),%rsi
jmp    11fd <cmd_two+0x3d>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc7e(%rip),%rsi
jmp    11fd <cmd_two+0x3d>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xffffffff,%eax
jmp    1396 <cmd_two+0x1d6>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xc6b(%rip),%rsi
jmp    11fd <cmd_two+0x3d>
xor    %eax,%eax
call   1050 <abort@plt>

LLVM IR (-O0):
%struct.atrf_dsc = type { i32 }
%struct.netio = type { i32 }
@.str = [15 x i8] c"-bad argument\0A\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [12 x i8] c"-I/O error\0A\00"
@.str.3 = [3 x i8] c"+\0A\00"
@.str.4 = [6 x i8] c"write\00"
@.str.5 = [16 x i8] c"-out of memory\0A\00"
@.str.6 = [23 x i8] c"-unterminated command\0A\00"
@.str.7 = [7 x i8] c"setram\00"
@.str.8 = [7 x i8] c"slp_tr\00"
define i32 @cmd_two(%struct.atrf_dsc* %0, %struct.netio* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.atrf_dsc*
%6 = alloca %struct.netio*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store %struct.atrf_dsc* %0, %struct.atrf_dsc** %5
store %struct.netio* %1, %struct.netio** %6
store i8* %2, i8** %7
%15 = load %struct.netio*, %struct.netio** %6
%16 = call i32 @get_num(%struct.netio* %15, i32 0, i32* %9)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = load i32, i32* %9
store i32 %20, i32* %4
br label %187
21: ; preds = %3
%22 = load i32, i32* %8
%23 = icmp sgt i32 %22, 255
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load %struct.netio*, %struct.netio** %6
%26 = call i32 @netio_printf(%struct.netio* %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %26, i32* %4
br label %187
27: ; preds = %21
%28 = load i8*, i8** %7
%29 = call i32 @strcasecmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %58, label %31
31: ; preds = %27
%32 = load %struct.netio*, %struct.netio** %6
%33 = call i32 @get_num(%struct.netio* %32, i32 1, i32* %9)
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i32, i32* %9
store i32 %37, i32* %4
br label %187
38: ; preds = %31
%39 = load i32, i32* %10
%40 = icmp sgt i32 %39, 255
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load %struct.netio*, %struct.netio** %6
%43 = call i32 @netio_printf(%struct.netio* %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %43, i32* %4
br label %187
44: ; preds = %38
%45 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%46 = load i32, i32* %8
%47 = load i32, i32* %10
%48 = call i32 @atrf_reg_write(%struct.atrf_dsc* %45, i32 %46, i32 %47)
%49 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%50 = call i64 @atrf_error(%struct.atrf_dsc* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %44
%53 = load %struct.netio*, %struct.netio** %6
%54 = call i32 @netio_printf(%struct.netio* %53, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %54, i32* %4
br label %187
55: ; preds = %44
%56 = load %struct.netio*, %struct.netio** %6
%57 = call i32 @netio_printf(%struct.netio* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %57, i32* %4
br label %187
58: ; preds = %27
%59 = load i8*, i8** %7
%60 = call i32 @strcasecmp(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %119, label %62
62: ; preds = %58
%63 = load i32, i32* %8
%64 = icmp sgt i32 %63, 128
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load %struct.netio*, %struct.netio** %6
%67 = call i32 @netio_printf(%struct.netio* %66, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %67, i32* %4
br label %187
68: ; preds = %62
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
%71 = call i8* @malloc(i32 %70)
store i8* %71, i8** %11
%72 = load i8*, i8** %11
%73 = icmp ne i8* %72, null
br i1 %73, label %77, label %74
74: ; preds = %68
%75 = load %struct.netio*, %struct.netio** %6
%76 = call i32 @netio_printf(%struct.netio* %75, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
store i32 %76, i32* %4
br label %187
77: ; preds = %68
%78 = load %struct.netio*, %struct.netio** %6
%79 = load i8*, i8** %11
%80 = load i32, i32* %8
%81 = add nsw i32 %80, 1
%82 = call i32 @netio_read(%struct.netio* %78, i8* %79, i32 %81)
store i32 %82, i32* %12
%83 = load i32, i32* %12
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
%86 = icmp ne i32 %83, %85
br i1 %86, label %87, label %90
87: ; preds = %77
%88 = load i8*, i8** %11
%89 = call i32 @free(i8* %88)
store i32 -1, i32* %4
br label %187
90: ; preds = %77
%91 = load i8*, i8** %11
%92 = load i32, i32* %8
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %91, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp ne i32 %96, 10
br i1 %97, label %98, label %103
98: ; preds = %90
%99 = load i8*, i8** %11
%100 = call i32 @free(i8* %99)
%101 = load %struct.netio*, %struct.netio** %6
%102 = call i32 @netio_printf(%struct.netio* %101, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 %102, i32* %4
br label %187
103: ; preds = %90
%104 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%105 = load i8*, i8** %11
%106 = load i32, i32* %8
%107 = call i32 @atrf_buf_write(%struct.atrf_dsc* %104, i8* %105, i32 %106)
%108 = load i8*, i8** %11
%109 = call i32 @free(i8* %108)
%110 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%111 = call i64 @atrf_error(%struct.atrf_dsc* %110)
%112 = icmp ne i64 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %103
%114 = load %struct.netio*, %struct.netio** %6
%115 = call i32 @netio_printf(%struct.netio* %114, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %115, i32* %4
br label %187
116: ; preds = %103
%117 = load %struct.netio*, %struct.netio** %6
%118 = call i32 @netio_printf(%struct.netio* %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %118, i32* %4
br label %187
119: ; preds = %58
%120 = load i8*, i8** %7
%121 = call i32 @strcasecmp(i8* %120, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%122 = icmp ne i32 %121, 0
br i1 %122, label %150, label %123
123: ; preds = %119
%124 = load %struct.netio*, %struct.netio** %6
%125 = call i32 @get_num(%struct.netio* %124, i32 1, i32* %9)
store i32 %125, i32* %13
%126 = load i32, i32* %13
%127 = icmp slt i32 %126, 0
br i1 %127, label %128, label %130
128: ; preds = %123
%129 = load i32, i32* %9
store i32 %129, i32* %4
br label %187
130: ; preds = %123
%131 = load i32, i32* %13
%132 = icmp sgt i32 %131, 255
br i1 %132, label %133, label %136
133: ; preds = %130
%134 = load %struct.netio*, %struct.netio** %6
%135 = call i32 @netio_printf(%struct.netio* %134, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %135, i32* %4
br label %187
136: ; preds = %130
%137 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%138 = load i32, i32* %8
%139 = load i32, i32* %13
%140 = call i32 @atrf_sram_write(%struct.atrf_dsc* %137, i32 %138, i32 %139)
%141 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%142 = call i64 @atrf_error(%struct.atrf_dsc* %141)
%143 = icmp ne i64 %142, 0
br i1 %143, label %144, label %147
144: ; preds = %136
%145 = load %struct.netio*, %struct.netio** %6
%146 = call i32 @netio_printf(%struct.netio* %145, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %146, i32* %4
br label %187
147: ; preds = %136
%148 = load %struct.netio*, %struct.netio** %6
%149 = call i32 @netio_printf(%struct.netio* %148, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %149, i32* %4
br label %187
150: ; preds = %119
%151 = load i8*, i8** %7
%152 = call i32 @strcasecmp(i8* %151, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%153 = icmp ne i32 %152, 0
br i1 %153, label %185, label %154
154: ; preds = %150
%155 = load i32, i32* %8
%156 = icmp sgt i32 %155, 1
br i1 %156, label %157, label %160
157: ; preds = %154
%158 = load %struct.netio*, %struct.netio** %6
%159 = call i32 @netio_printf(%struct.netio* %158, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %159, i32* %4
br label %187
160: ; preds = %154
%161 = load %struct.netio*, %struct.netio** %6
%162 = call i32 @get_num(%struct.netio* %161, i32 1, i32* %9)
store i32 %162, i32* %14
%163 = load i32, i32* %14
%164 = icmp slt i32 %163, 0
br i1 %164, label %165, label %167
165: ; preds = %160
%166 = load i32, i32* %9
store i32 %166, i32* %4
br label %187
167: ; preds = %160
%168 = load i32, i32* %14
%169 = icmp sgt i32 %168, 1
br i1 %169, label %170, label %173
170: ; preds = %167
%171 = load %struct.netio*, %struct.netio** %6
%172 = call i32 @netio_printf(%struct.netio* %171, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %172, i32* %4
br label %187
173: ; preds = %167
%174 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%175 = load i32, i32* %8
%176 = load i32, i32* %14
%177 = call i64 @atrf_slp_tr(%struct.atrf_dsc* %174, i32 %175, i32 %176)
%178 = icmp slt i64 %177, 0
br i1 %178, label %179, label %182
179: ; preds = %173
%180 = load %struct.netio*, %struct.netio** %6
%181 = call i32 @netio_printf(%struct.netio* %180, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %181, i32* %4
br label %187
182: ; preds = %173
%183 = load %struct.netio*, %struct.netio** %6
%184 = call i32 @netio_printf(%struct.netio* %183, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %184, i32* %4
br label %187
185: ; preds = %150
%186 = call i32 (...) @abort()
unreachable
187: ; preds = %182, %179, %170, %165, %157, %147, %144, %133, %128, %116, %113, %98, %87, %74, %65, %55, %52, %41, %36, %24, %19
%188 = load i32, i32* %4
ret i32 %188
}

LLVM IR (-O2):
%struct.atrf_dsc = type { i32 }
%struct.netio = type { i32 }
@.str = [15 x i8] c"-bad argument\0A\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [12 x i8] c"-I/O error\0A\00"
@.str.3 = [3 x i8] c"+\0A\00"
@.str.4 = [6 x i8] c"write\00"
@.str.5 = [16 x i8] c"-out of memory\0A\00"
@.str.6 = [23 x i8] c"-unterminated command\0A\00"
@.str.7 = [7 x i8] c"setram\00"
@.str.8 = [7 x i8] c"slp_tr\00"
define i32 @cmd_two(%struct.atrf_dsc* %0, %struct.netio* %1, i8* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @get_num(%struct.netio* %1, i32 0, i32* %4)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = load i32, i32* %4
br label %114
10: ; preds = %3
%11 = icmp ugt i32 %6, 255
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %114
14: ; preds = %10
%15 = call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %34
17: ; preds = %14
%18 = call i32 @get_num(%struct.netio* %1, i32 1, i32* %4)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32, i32* %4
br label %114
22: ; preds = %17
%23 = icmp ugt i32 %18, 255
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %114
26: ; preds = %22
%27 = call i32 @atrf_reg_write(%struct.atrf_dsc* %0, i32 %6, i32 %18)
%28 = call i64 @atrf_error(%struct.atrf_dsc* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %114
32: ; preds = %26
%33 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %114
34: ; preds = %14
%35 = call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %69
37: ; preds = %34
%38 = icmp ugt i32 %6, 128
br i1 %38, label %39, label %41
39: ; preds = %37
%40 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %114
41: ; preds = %37
%42 = add nuw nsw i32 %6, 1
%43 = call i8* @malloc(i32 %42)
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %114
47: ; preds = %41
%48 = call i32 @netio_read(%struct.netio* %1, i8* %43, i32 %42)
%49 = icmp eq i32 %48, %42
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 @free(i8* %43)
br label %114
52: ; preds = %47
%53 = zext i32 %6 to i64
%54 = getelementptr inbounds i8, i8* %43, i64 %53
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 10
br i1 %56, label %60, label %57
57: ; preds = %52
%58 = call i32 @free(i8* %43)
%59 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %114
60: ; preds = %52
%61 = call i32 @atrf_buf_write(%struct.atrf_dsc* %0, i8* %43, i32 %6)
%62 = call i32 @free(i8* %43)
%63 = call i64 @atrf_error(%struct.atrf_dsc* %0)
%64 = icmp eq i64 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %60
%66 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %114
67: ; preds = %60
%68 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %114
69: ; preds = %34
%70 = call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %89
72: ; preds = %69
%73 = call i32 @get_num(%struct.netio* %1, i32 1, i32* %4)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = load i32, i32* %4
br label %114
77: ; preds = %72
%78 = icmp ugt i32 %73, 255
br i1 %78, label %79, label %81
79: ; preds = %77
%80 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %114
81: ; preds = %77
%82 = call i32 @atrf_sram_write(%struct.atrf_dsc* %0, i32 %6, i32 %73)
%83 = call i64 @atrf_error(%struct.atrf_dsc* %0)
%84 = icmp eq i64 %83, 0
br i1 %84, label %87, label %85
85: ; preds = %81
%86 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %114
87: ; preds = %81
%88 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %114
89: ; preds = %69
%90 = call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %112
92: ; preds = %89
%93 = icmp ugt i32 %6, 1
br i1 %93, label %94, label %96
94: ; preds = %92
%95 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %114
96: ; preds = %92
%97 = call i32 @get_num(%struct.netio* %1, i32 1, i32* %4)
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = load i32, i32* %4
br label %114
101: ; preds = %96
%102 = icmp ugt i32 %97, 1
br i1 %102, label %103, label %105
103: ; preds = %101
%104 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %114
105: ; preds = %101
%106 = call i64 @atrf_slp_tr(%struct.atrf_dsc* %0, i32 %6, i32 %97)
%107 = icmp slt i64 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %114
110: ; preds = %105
%111 = call i32 @netio_printf(%struct.netio* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %114
112: ; preds = %89
%113 = call i32 (...) @abort()
unreachable
114: ; preds = %94, %99, %103, %108, %110, %75, %79, %85, %87, %39, %45, %50, %57, %65, %67, %20, %24, %30, %32, %12, %8
%115 = phi i32 [ %9, %8 ], [ %13, %12 ], [ %21, %20 ], [ %25, %24 ], [ %31, %30 ], [ %33, %32 ], [ %40, %39 ], [ -1, %50 ], [ %59, %57 ], [ %66, %65 ], [ %68, %67 ], [ %46, %45 ], [ %76, %75 ], [ %80, %79 ], [ %86, %85 ], [ %88, %87 ], [ %95, %94 ], [ %100, %99 ], [ %104, %103 ], [ %109, %108 ], [ %111, %110 ]
ret i32 %115
}