#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 int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ *xreadline(char *, char *, int);
void _prompt_loop_rpc3_de(void) {
  int i;
  char buf[128];
  int num_plugs = 8;
  char plug[8][4];
  int plug_origin = 1;
  int logged_in = 1;
  for (i = 0; i < num_plugs; i++)
    strcpy(plug[i], "Off");
  printf("\r\n\r\nRPC-3/4(A)DE Series\r\n(C) 2004 "
         "BayTech\r\nF1.08\r\n\r\nOption(s) Installed:\r\nTrue RMS "
         "Voltage\r\nTrue RMS Current\r\nInternal Temperature\r\n\r\n");
  while (logged_in) {
    if (xreadline("RPC-4>", buf, sizeof(buf)) == NULL)
      break;
    if (strlen(buf) == 0) {
      continue;
    } else if (!strcmp(buf, "logoff") || !strcmp(buf, "logout") ||
               !strcmp(buf, "exit")) {
      break;
    } else if (!strcmp(buf, "help")) {
      printf("\r\n\r\nOn n <cr>     --Turn on an Outlet, n=0,1...8,all\r\nOff "
             "n <cr>    --Turn off an Outlet, n=0,1...8,all\r\nReboot n <cr> "
             "--Reboot an Outlet, n=0,1...8,all\r\nStatus <cr>   --RPC-4 "
             "Status\r\nConfig <cr>   --Enter configuration mode\r\nRC <cr>    "
             "   --Powerup/watchdog reset counts\r\nLock n <cr>   --Locks "
             "Outlet(s) state, n=0,1...8,all\r\nUnlock n <cr> --Unlock "
             "Outlet(s) state, n=0,1...8,all\r\nCurrent <cr>  --Display True "
             "RMS Current\r\nVoltage <cr>  --Display True RMS Voltage\r\nPower "
             "<cr>    --Display Average Power\r\nClear <cr>    --Reset the "
             "maximum detected current\r\nTemp <cr>     --Read current "
             "temperature\r\nLogout <cr>   --Logoff\r\nLogoff <cr>   "
             "--Logoff\r\nExit <cr>     --Logoff\r\nPassword <cr> --Changes "
             "the current user password\r\nWhoami <cr>   --Displays the "
             "current user name\r\nUnitid <cr>   --Displays the unit "
             "ID\r\n\r\n\r\nType Help for a list of commands\r\n\r\n");
    } else if (!strcmp(buf, "temp"))
      printf("\r\n\r\nInternal Temperature:  77.9 F\r\n\r\nType Help for a "
             "list of commands\r\n\r\n");
    else if (!strcmp(buf, "voltage"))
      printf("\r\n\r\n--------------------------------\r\n|    Outlet      |  "
             "True RMS   |\r\n|    Group       |   Voltage   "
             "|\r\n--------------------------------\r\n|  Outlet  1-4   | "
             "122.4 Volts | \r\n|  Outlet  5-8   | 122.3 Volts | "
             "\r\n--------------------------------\r\n\r\nType Help for a list "
             "of commands\r\n\r\n");
    else if (!strcmp(buf, "current"))
      printf(
          "\r\n\r\n------------------------------------------\r\n|    Outlet   "
          "   | True RMS  | Peak RMS  |\r\n|    Group       |  Current  |  "
          "Current  |\r\n------------------------------------------\r\n|  "
          "Outlet  1-4   |  1.8 Amps |  2.3 Amps |\r\n|  Outlet  5-8   |  2.3 "
          "Amps |  5.0 Amps "
          "|\r\n------------------------------------------\r\n\r\n\r\n\r\nType "
          "Help for a list of commands\r\n\r\n");
    else if (!strcmp(buf, "power"))
      printf(
          "\r\n\r\n------------------------------------------\r\n|    Outlet   "
          "   | True RMS  | Peak RMS  |\r\n|    Group       |  Current  |  "
          "Current  |\r\n------------------------------------------\r\n|  "
          "Outlet  1-4   |  1.8 Amps |  2.3 Amps |\r\n|  Outlet  5-8   |  2.3 "
          "Amps |  5.0 Amps "
          "|\r\n------------------------------------------\r\n\r\n\r\n\r\nType "
          "Help for a list of commands\r\n\r\n");
    else if (!strcmp(buf, "status")) {
      printf(
          "\r\n\r\n------------------------------------------------------------"
          "-------------------\r\n|    Outlet      | True RMS  | Peak RMS  |  "
          "True RMS   |   Average  |  Volt-  |\r\n|    Group       |  Current  "
          "|  Current  |   Voltage   |    Power   |  Amps   "
          "|\r\n---------------------------------------------------------------"
          "----------------\r\n|  Outlet  1-4   |  1.8 Amps |  2.3 Amps | "
          "122.5 Volts |  216 Watts |  220 VA |\r\n|  Outlet  5-8   |  2.4 "
          "Amps |  5.0 Amps | 122.1 Volts |  269 Watts |  277 VA "
          "|\r\n---------------------------------------------------------------"
          "----------------\r\n\r\nInternal Temperature:  78.8 F\r\n\r\nSwitch "
          "1: Open 2: Open\r\n\r\n 1)...Outlet  1       : %s           \r\n "
          "2)...Outlet  2       : %s           \r\n 3)...Outlet  3       : %s  "
          "         \r\n 4)...Outlet  4       : %s           \r\n 5)...Outlet  "
          "5       : %s           \r\n 6)...Outlet  6       : %s           "
          "\r\n 7)...Outlet  7       : %s           \r\n 8)...Outlet  8       "
          ": %s           \r\n\r\n\r\nType Help for a list of commands\r\n\r\n",
          plug[0], plug[1], plug[2], plug[3], plug[4], plug[5], plug[6],
          plug[7]);
    } else if (sscanf(buf, "on %d", &i) == 1) {
      if (i >= plug_origin && i < num_plugs + plug_origin)
        strcpy(plug[i - plug_origin], "On ");
      else if (i == 0)
        for (i = 0; i < num_plugs; i++)
          strcpy(plug[i], "On ");
      else
        goto err;
    } else if (sscanf(buf, "off %d", &i) == 1) {
      if (i >= plug_origin && i < num_plugs + plug_origin)
        strcpy(plug[i - plug_origin], "Off");
      else if (i == 0)
        for (i = 0; i < num_plugs; i++)
          strcpy(plug[i], "Off");
      else
        goto err;
    } else if (sscanf(buf, "reboot %d", &i) == 1) {
      if (i == 0 || (i >= plug_origin && i < num_plugs + plug_origin)) {
        printf("\r\nRebooting...  ");
        for (i = 9; i >= 0; i--) {
          printf("%d", i);
          fflush(stdout);
          sleep(1);
        }
        printf("\r\n");
      } else
        goto err;
    } else
      goto err;
    continue;
  err:
    printf("Input error\r\n\r\n");
  }
}


x86 assembly (clang, -O0):
<_prompt_loop_rpc3_de>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x8,-0x94(%rbp)
movl   $0x1,-0xc4(%rbp)
movl   $0x1,-0xc8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    11eb <_prompt_loop_rpc3_de+0x6b>
movslq -0x4(%rbp),%rax
lea    -0xc0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    0xe28(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <_prompt_loop_rpc3_de+0x30>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0xc8(%rbp)
je     16cf <_prompt_loop_rpc3_de+0x54f>
lea    -0x90(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0x80,%edx
call   1060 <xreadline@plt>
cmp    $0x0,%rax
jne    122d <_prompt_loop_rpc3_de+0xad>
jmp    16cf <_prompt_loop_rpc3_de+0x54f>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    1248 <_prompt_loop_rpc3_de+0xc8>
jmp    11f9 <_prompt_loop_rpc3_de+0x79>
lea    -0x90(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     129c <_prompt_loop_rpc3_de+0x11c>
lea    -0x90(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     129c <_prompt_loop_rpc3_de+0x11c>
lea    -0x90(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12a1 <_prompt_loop_rpc3_de+0x121>
jmp    16cf <_prompt_loop_rpc3_de+0x54f>
lea    -0x90(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12d0 <_prompt_loop_rpc3_de+0x150>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    16ad <_prompt_loop_rpc3_de+0x52d>
lea    -0x90(%rbp),%rdi
lea    0x111d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12ff <_prompt_loop_rpc3_de+0x17f>
lea    0x110d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    16a8 <_prompt_loop_rpc3_de+0x528>
lea    -0x90(%rbp),%rdi
lea    0x113d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    132e <_prompt_loop_rpc3_de+0x1ae>
lea    0x1130(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    16a3 <_prompt_loop_rpc3_de+0x523>
lea    -0x90(%rbp),%rdi
lea    0x1231(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    135d <_prompt_loop_rpc3_de+0x1dd>
lea    0x1224(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    169e <_prompt_loop_rpc3_de+0x51e>
lea    -0x90(%rbp),%rdi
lea    0x136d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    138c <_prompt_loop_rpc3_de+0x20c>
lea    0x11f5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1699 <_prompt_loop_rpc3_de+0x519>
lea    -0x90(%rbp),%rdi
lea    0x1344(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    141d <_prompt_loop_rpc3_de+0x29d>
lea    -0xc0(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
add    $0x4,%rdx
lea    -0xc0(%rbp),%rcx
add    $0x8,%rcx
lea    -0xc0(%rbp),%r8
add    $0xc,%r8
lea    -0xc0(%rbp),%r9
add    $0x10,%r9
lea    -0xc0(%rbp),%r11
add    $0x14,%r11
lea    -0xc0(%rbp),%r10
add    $0x18,%r10
lea    -0xc0(%rbp),%rax
add    $0x1c,%rax
lea    0x12e2(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1694 <_prompt_loop_rpc3_de+0x514>
lea    -0x90(%rbp),%rdi
lea    0x1693(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    14ed <_prompt_loop_rpc3_de+0x36d>
mov    -0x4(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jl     148d <_prompt_loop_rpc3_de+0x30d>
mov    -0x4(%rbp),%eax
mov    -0x94(%rbp),%ecx
add    -0xc4(%rbp),%ecx
cmp    %ecx,%eax
jge    148d <_prompt_loop_rpc3_de+0x30d>
mov    -0x4(%rbp),%eax
sub    -0xc4(%rbp),%eax
cltq
lea    -0xc0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    0x1641(%rip),%rsi
call   1030 <strcpy@plt>
jmp    14e8 <_prompt_loop_rpc3_de+0x368>
cmpl   $0x0,-0x4(%rbp)
jne    14de <_prompt_loop_rpc3_de+0x35e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    14d9 <_prompt_loop_rpc3_de+0x359>
movslq -0x4(%rbp),%rax
lea    -0xc0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    0x15fe(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    149e <_prompt_loop_rpc3_de+0x31e>
jmp    14e3 <_prompt_loop_rpc3_de+0x363>
jmp    16bc <_prompt_loop_rpc3_de+0x53c>
jmp    14e8 <_prompt_loop_rpc3_de+0x368>
jmp    168f <_prompt_loop_rpc3_de+0x50f>
lea    -0x90(%rbp),%rdi
lea    0x15cd(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    15bd <_prompt_loop_rpc3_de+0x43d>
mov    -0x4(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jl     155d <_prompt_loop_rpc3_de+0x3dd>
mov    -0x4(%rbp),%eax
mov    -0x94(%rbp),%ecx
add    -0xc4(%rbp),%ecx
cmp    %ecx,%eax
jge    155d <_prompt_loop_rpc3_de+0x3dd>
mov    -0x4(%rbp),%eax
sub    -0xc4(%rbp),%eax
cltq
lea    -0xc0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    0xaad(%rip),%rsi
call   1030 <strcpy@plt>
jmp    15b8 <_prompt_loop_rpc3_de+0x438>
cmpl   $0x0,-0x4(%rbp)
jne    15ae <_prompt_loop_rpc3_de+0x42e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    15a9 <_prompt_loop_rpc3_de+0x429>
movslq -0x4(%rbp),%rax
lea    -0xc0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    0xa6a(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    156e <_prompt_loop_rpc3_de+0x3ee>
jmp    15b3 <_prompt_loop_rpc3_de+0x433>
jmp    16bc <_prompt_loop_rpc3_de+0x53c>
jmp    15b8 <_prompt_loop_rpc3_de+0x438>
jmp    168a <_prompt_loop_rpc3_de+0x50a>
lea    -0x90(%rbp),%rdi
lea    0x1504(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    1680 <_prompt_loop_rpc3_de+0x500>
cmpl   $0x0,-0x4(%rbp)
je     160d <_prompt_loop_rpc3_de+0x48d>
mov    -0x4(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jl     1676 <_prompt_loop_rpc3_de+0x4f6>
mov    -0x4(%rbp),%eax
mov    -0x94(%rbp),%ecx
add    -0xc4(%rbp),%ecx
cmp    %ecx,%eax
jge    1676 <_prompt_loop_rpc3_de+0x4f6>
lea    0x14c5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x9,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1663 <_prompt_loop_rpc3_de+0x4e3>
mov    -0x4(%rbp),%esi
lea    0x14b4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x299c(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1622 <_prompt_loop_rpc3_de+0x4a2>
lea    0xa1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    167b <_prompt_loop_rpc3_de+0x4fb>
jmp    16bc <_prompt_loop_rpc3_de+0x53c>
jmp    1685 <_prompt_loop_rpc3_de+0x505>
jmp    16bc <_prompt_loop_rpc3_de+0x53c>
jmp    168a <_prompt_loop_rpc3_de+0x50a>
jmp    168f <_prompt_loop_rpc3_de+0x50f>
jmp    1694 <_prompt_loop_rpc3_de+0x514>
jmp    1699 <_prompt_loop_rpc3_de+0x519>
jmp    169e <_prompt_loop_rpc3_de+0x51e>
jmp    16a3 <_prompt_loop_rpc3_de+0x523>
jmp    16a8 <_prompt_loop_rpc3_de+0x528>
jmp    16ad <_prompt_loop_rpc3_de+0x52d>
jmp    16b2 <_prompt_loop_rpc3_de+0x532>
jmp    16b7 <_prompt_loop_rpc3_de+0x537>
jmp    11f9 <_prompt_loop_rpc3_de+0x79>
lea    0x142b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f9 <_prompt_loop_rpc3_de+0x79>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_prompt_loop_rpc3_de>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
lea    0xe6e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cltq
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    0xc(%rsp),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x7,%ecx
jl     11a0 <_prompt_loop_rpc3_de+0x30>
lea    0x1275(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2f(%rip),%rdi
lea    0x30(%rsp),%rsi
mov    $0x80,%edx
call   1060 <xreadline@plt>
test   %rax,%rax
je     154b <_prompt_loop_rpc3_de+0x3db>
lea    0xe10(%rip),%r14
lea    0x30(%rsp),%r15
mov    $0x6f676f6c,%r12d
mov    $0x66666f,%r13d
mov    $0x74756f,%ebp
mov    $0x74697865,%ebx
jmp    1245 <_prompt_loop_rpc3_de+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x129d(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x80,%edx
call   1060 <xreadline@plt>
test   %rax,%rax
je     154b <_prompt_loop_rpc3_de+0x3db>
cmpb   $0x0,0x30(%rsp)
je     122c <_prompt_loop_rpc3_de+0xbc>
mov    0x30(%rsp),%eax
xor    %r12d,%eax
mov    0x33(%rsp),%ecx
xor    %r13d,%ecx
or     %eax,%ecx
je     154b <_prompt_loop_rpc3_de+0x3db>
mov    0x30(%rsp),%eax
xor    %r12d,%eax
mov    0x33(%rsp),%ecx
xor    %ebp,%ecx
or     %eax,%ecx
je     154b <_prompt_loop_rpc3_de+0x3db>
mov    0x30(%rsp),%eax
xor    %ebx,%eax
movzbl 0x34(%rsp),%ecx
or     %eax,%ecx
je     154b <_prompt_loop_rpc3_de+0x3db>
mov    0x30(%rsp),%eax
mov    $0x706c6568,%ecx
xor    %ecx,%eax
movzbl 0x34(%rsp),%ecx
or     %eax,%ecx
je     1220 <_prompt_loop_rpc3_de+0xb0>
mov    0x30(%rsp),%eax
mov    $0x706d6574,%ecx
xor    %ecx,%eax
movzbl 0x34(%rsp),%ecx
or     %eax,%ecx
je     12e1 <_prompt_loop_rpc3_de+0x171>
mov    0x30(%rsp),%rax
movabs $0x746e6572727563,%rcx
cmp    %rcx,%rax
je     12ed <_prompt_loop_rpc3_de+0x17d>
movabs $0x656761746c6f76,%rcx
cmp    %rcx,%rax
jne    12f9 <_prompt_loop_rpc3_de+0x189>
lea    0x1581(%rip),%rdi
jmp    1227 <_prompt_loop_rpc3_de+0xb7>
lea    0x152c(%rip),%rdi
jmp    1227 <_prompt_loop_rpc3_de+0xb7>
lea    0x1683(%rip),%rdi
jmp    1227 <_prompt_loop_rpc3_de+0xb7>
mov    0x30(%rsp),%eax
mov    $0x65776f70,%ecx
xor    %ecx,%eax
movzwl 0x34(%rsp),%ecx
xor    $0x72,%ecx
or     %eax,%ecx
lea    0xc(%rsp),%rbp
je     1370 <_prompt_loop_rpc3_de+0x200>
mov    0x30(%rsp),%eax
mov    $0x74617473,%ecx
xor    %ecx,%eax
mov    0x33(%rsp),%ecx
mov    $0x737574,%edx
xor    %edx,%ecx
or     %eax,%ecx
je     1386 <_prompt_loop_rpc3_de+0x216>
mov    %r15,%rdi
lea    0x10d5(%rip),%rsi
mov    %rbp,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    13d6 <_prompt_loop_rpc3_de+0x266>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x7,%ecx
ja     141d <_prompt_loop_rpc3_de+0x2ad>
mov    %ecx,%eax
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
lea    0x10a9(%rip),%rsi
jmp    140e <_prompt_loop_rpc3_de+0x29e>
lea    0x1600(%rip),%rdi
call   1040 <puts@plt>
mov    $0x74756f,%ebp
jmp    122c <_prompt_loop_rpc3_de+0xbc>
sub    $0x8,%rsp
lea    0xca4(%rip),%rdi
lea    0x18(%rsp),%rsi
lea    0x1c(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x24(%rsp),%r8
lea    0x28(%rsp),%r9
xor    %eax,%eax
lea    0x34(%rsp),%rbx
push   %rbx
lea    0x38(%rsp),%rbx
push   %rbx
lea    0x3c(%rsp),%rbx
push   %rbx
mov    $0x74697865,%ebx
call   1050 <printf@plt>
add    $0x20,%rsp
mov    $0x74756f,%ebp
jmp    122c <_prompt_loop_rpc3_de+0xbc>
mov    %r15,%rdi
lea    0x1038(%rip),%rsi
mov    %rbp,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    146b <_prompt_loop_rpc3_de+0x2fb>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x7,%ecx
ja     14f7 <_prompt_loop_rpc3_de+0x387>
mov    %ecx,%eax
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
lea    0xbf2(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x74756f,%ebp
jmp    122c <_prompt_loop_rpc3_de+0xbc>
test   %eax,%eax
mov    $0x74756f,%ebp
jne    1500 <_prompt_loop_rpc3_de+0x390>
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltq
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
lea    0xfc3(%rip),%rsi
call   1030 <strcpy@plt>
mov    0xc(%rsp),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x7,%ecx
jl     1440 <_prompt_loop_rpc3_de+0x2d0>
jmp    122c <_prompt_loop_rpc3_de+0xbc>
mov    %r15,%rdi
lea    0xfaa(%rip),%rsi
mov    %rbp,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
mov    $0x74756f,%ebp
jne    1500 <_prompt_loop_rpc3_de+0x390>
cmpl   $0x8,0xc(%rsp)
ja     1500 <_prompt_loop_rpc3_de+0x390>
lea    0xf94(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x9,0xc(%rsp)
mov    $0x9,%esi
mov    0x2b30(%rip),%r13
lea    0xf83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%esi
mov    %esi,0xc(%rsp)
test   %eax,%eax
jg     14b0 <_prompt_loop_rpc3_de+0x340>
lea    0xfdb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x66666f,%r13d
jmp    122c <_prompt_loop_rpc3_de+0xbc>
test   %eax,%eax
mov    $0x74756f,%ebp
je     150c <_prompt_loop_rpc3_de+0x39c>
lea    0x15d2(%rip),%rdi
jmp    1227 <_prompt_loop_rpc3_de+0xb7>
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cltq
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
lea    0xacf(%rip),%rsi
call   1030 <strcpy@plt>
mov    0xc(%rsp),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x7,%ecx
jl     1520 <_prompt_loop_rpc3_de+0x3b0>
jmp    122c <_prompt_loop_rpc3_de+0xbc>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"Off\00"
@.str.1 = [135 x i8] c"\0D\0A\0D\0ARPC-3/4(A)DE Series\0D\0A(C) 2004 BayTech\0D\0AF1.08\0D\0A\0D\0AOption(s) Installed:\0D\0ATrue RMS Voltage\0D\0ATrue RMS Current\0D\0AInternal Temperature\0D\0A\0D\0A\00"
@.str.2 = [7 x i8] c"RPC-4>\00"
@.str.3 = [7 x i8] c"logoff\00"
@.str.4 = [7 x i8] c"logout\00"
@.str.5 = [5 x i8] c"exit\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [849 x i8] c"\0D\0A\0D\0AOn n <cr> --Turn on an Outlet, n=0,1...8,all\0D\0AOff n <cr> --Turn off an Outlet, n=0,1...8,all\0D\0AReboot n <cr> --Reboot an Outlet, n=0,1...8,all\0D\0AStatus <cr> --RPC-4 Status\0D\0AConfig <cr> --Enter configuration mode\0D\0ARC <cr> --Powerup/watchdog reset counts\0D\0ALock n <cr> --Locks Outlet(s) state, n=0,1...8,all\0D\0AUnlock n <cr> --Unlock Outlet(s) state, n=0,1...8,all\0D\0ACurrent <cr> --Display True RMS Current\0D\0AVoltage <cr> --Display True RMS Voltage\0D\0APower <cr> --Display Average Power\0D\0AClear <cr> --Reset the maximum detected current\0D\0ATemp <cr> --Read current temperature\0D\0ALogout <cr> --Logoff\0D\0ALogoff <cr> --Logoff\0D\0AExit <cr> --Logoff\0D\0APassword <cr> --Changes the current user password\0D\0AWhoami <cr> --Displays the current user name\0D\0AUnitid <cr> --Displays the unit ID\0D\0A\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\0A\00"
@.str.8 = [5 x i8] c"temp\00"
@.str.9 = [74 x i8] c"\0D\0A\0D\0AInternal Temperature: 77.9 F\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\0A\00"
@.str.10 = [8 x i8] c"voltage\00"
@.str.11 = [283 x i8] c"\0D\0A\0D\0A--------------------------------\0D\0A| Outlet | True RMS |\0D\0A| Group | Voltage |\0D\0A--------------------------------\0D\0A| Outlet 1-4 | 122.4 Volts | \0D\0A| Outlet 5-8 | 122.3 Volts | \0D\0A--------------------------------\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\0A\00"
@.str.12 = [8 x i8] c"current\00"
@.str.13 = [355 x i8] c"\0D\0A\0D\0A------------------------------------------\0D\0A| Outlet | True RMS | Peak RMS |\0D\0A| Group | Current | Current |\0D\0A------------------------------------------\0D\0A| Outlet 1-4 | 1.8 Amps | 2.3 Amps |\0D\0A| Outlet 5-8 | 2.3 Amps | 5.0 Amps |\0D\0A------------------------------------------\0D\0A\0D\0A\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\0A\00"
@.str.14 = [6 x i8] c"power\00"
@.str.15 = [7 x i8] c"status\00"
@.str.16 = [985 x i8] c"\0D\0A\0D\0A-------------------------------------------------------------------------------\0D\0A| Outlet | True RMS | Peak RMS | True RMS | Average | Volt- |\0D\0A| Group | Current | Current | Voltage | Power | Amps |\0D\0A-------------------------------------------------------------------------------\0D\0A| Outlet 1-4 | 1.8 Amps | 2.3 Amps | 122.5 Volts | 216 Watts | 220 VA |\0D\0A| Outlet 5-8 | 2.4 Amps | 5.0 Amps | 122.1 Volts | 269 Watts | 277 VA |\0D\0A-------------------------------------------------------------------------------\0D\0A\0D\0AInternal Temperature: 78.8 F\0D\0A\0D\0ASwitch 1: Open 2: Open\0D\0A\0D\0A 1)...Outlet 1 : %s \0D\0A 2)...Outlet 2 : %s \0D\0A 3)...Outlet 3 : %s \0D\0A 4)...Outlet 4 : %s \0D\0A 5)...Outlet 5 : %s \0D\0A 6)...Outlet 6 : %s \0D\0A 7)...Outlet 7 : %s \0D\0A 8)...Outlet 8 : %s \0D\0A\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\0A\00"
@.str.17 = [6 x i8] c"on %d\00"
@.str.18 = [4 x i8] c"On \00"
@.str.19 = [7 x i8] c"off %d\00"
@.str.20 = [10 x i8] c"reboot %d\00"
@.str.21 = [17 x i8] c"\0D\0ARebooting... \00"
@.str.22 = [4 x i8] c"\08%d\00"
@stdout = global i32 0
@.str.23 = [3 x i8] c"\0D\0A\00"
@.str.24 = [16 x i8] c"Input error\0D\0A\0D\0A\00"
define void @_prompt_loop_rpc3_de() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = alloca [8 x [4 x i8]]
%5 = alloca i32
%6 = alloca i32
store i32 8, i32* %3
store i32 1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %1
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 %13
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %11
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
store i32 %19, i32* %1
br label %7
20: ; preds = %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %233, %232, %34, %20
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %235
25: ; preds = %22
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%27 = call i32* @xreadline(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %26, i32 128)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %30
29: ; preds = %25
br label %235
30: ; preds = %25
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
br label %22
35: ; preds = %30
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %43, %39, %35
br label %235
48: ; preds = %43
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %48
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([849 x i8], [849 x i8]* @.str.7, i64 0, i64 0))
br label %230
54: ; preds = %48
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %54
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.9, i64 0, i64 0))
br label %229
60: ; preds = %54
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%62 = call i32 @strcmp(i8* %61, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%63 = icmp ne i32 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([283 x i8], [283 x i8]* @.str.11, i64 0, i64 0))
br label %228
66: ; preds = %60
%67 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %66
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([355 x i8], [355 x i8]* @.str.13, i64 0, i64 0))
br label %227
72: ; preds = %66
%73 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%74 = call i32 @strcmp(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%75 = icmp ne i32 %74, 0
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([355 x i8], [355 x i8]* @.str.13, i64 0, i64 0))
br label %226
78: ; preds = %72
%79 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %100, label %82
82: ; preds = %78
%83 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 0
%84 = getelementptr inbounds [4 x i8], [4 x i8]* %83, i64 0, i64 0
%85 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 1
%86 = getelementptr inbounds [4 x i8], [4 x i8]* %85, i64 0, i64 0
%87 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 2
%88 = getelementptr inbounds [4 x i8], [4 x i8]* %87, i64 0, i64 0
%89 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 3
%90 = getelementptr inbounds [4 x i8], [4 x i8]* %89, i64 0, i64 0
%91 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 4
%92 = getelementptr inbounds [4 x i8], [4 x i8]* %91, i64 0, i64 0
%93 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 5
%94 = getelementptr inbounds [4 x i8], [4 x i8]* %93, i64 0, i64 0
%95 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 6
%96 = getelementptr inbounds [4 x i8], [4 x i8]* %95, i64 0, i64 0
%97 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 7
%98 = getelementptr inbounds [4 x i8], [4 x i8]* %97, i64 0, i64 0
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([985 x i8], [985 x i8]* @.str.16, i64 0, i64 0), i8* %84, i8* %86, i8* %88, i8* %90, i8* %92, i8* %94, i8* %96, i8* %98)
br label %225
100: ; preds = %78
%101 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%102 = call i32 @sscanf(i8* %101, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32* %1)
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %143
104: ; preds = %100
%105 = load i32, i32* %1
%106 = load i32, i32* %5
%107 = icmp sge i32 %105, %106
br i1 %107, label %108, label %122
108: ; preds = %104
%109 = load i32, i32* %1
%110 = load i32, i32* %3
%111 = load i32, i32* %5
%112 = add nsw i32 %110, %111
%113 = icmp slt i32 %109, %112
br i1 %113, label %114, label %122
114: ; preds = %108
%115 = load i32, i32* %1
%116 = load i32, i32* %5
%117 = sub nsw i32 %115, %116
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 %118
%120 = getelementptr inbounds [4 x i8], [4 x i8]* %119, i64 0, i64 0
%121 = call i32 @strcpy(i8* %120, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0))
br label %142
122: ; preds = %108, %104
%123 = load i32, i32* %1
%124 = icmp eq i32 %123, 0
br i1 %124, label %125, label %140
125: ; preds = %122
store i32 0, i32* %1
br label %126
126: ; preds = %136, %125
%127 = load i32, i32* %1
%128 = load i32, i32* %3
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %139
130: ; preds = %126
%131 = load i32, i32* %1
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 %132
%134 = getelementptr inbounds [4 x i8], [4 x i8]* %133, i64 0, i64 0
%135 = call i32 @strcpy(i8* %134, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0))
br label %136
136: ; preds = %130
%137 = load i32, i32* %1
%138 = add nsw i32 %137, 1
store i32 %138, i32* %1
br label %126
139: ; preds = %126
br label %141
140: ; preds = %122
br label %233
141: ; preds = %139
br label %142
142: ; preds = %141, %114
br label %224
143: ; preds = %100
%144 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%145 = call i32 @sscanf(i8* %144, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i32* %1)
%146 = icmp eq i32 %145, 1
br i1 %146, label %147, label %186
147: ; preds = %143
%148 = load i32, i32* %1
%149 = load i32, i32* %5
%150 = icmp sge i32 %148, %149
br i1 %150, label %151, label %165
151: ; preds = %147
%152 = load i32, i32* %1
%153 = load i32, i32* %3
%154 = load i32, i32* %5
%155 = add nsw i32 %153, %154
%156 = icmp slt i32 %152, %155
br i1 %156, label %157, label %165
157: ; preds = %151
%158 = load i32, i32* %1
%159 = load i32, i32* %5
%160 = sub nsw i32 %158, %159
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 %161
%163 = getelementptr inbounds [4 x i8], [4 x i8]* %162, i64 0, i64 0
%164 = call i32 @strcpy(i8* %163, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %185
165: ; preds = %151, %147
%166 = load i32, i32* %1
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %183
168: ; preds = %165
store i32 0, i32* %1
br label %169
169: ; preds = %179, %168
%170 = load i32, i32* %1
%171 = load i32, i32* %3
%172 = icmp slt i32 %170, %171
br i1 %172, label %173, label %182
173: ; preds = %169
%174 = load i32, i32* %1
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %4, i64 0, i64 %175
%177 = getelementptr inbounds [4 x i8], [4 x i8]* %176, i64 0, i64 0
%178 = call i32 @strcpy(i8* %177, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %179
179: ; preds = %173
%180 = load i32, i32* %1
%181 = add nsw i32 %180, 1
store i32 %181, i32* %1
br label %169
182: ; preds = %169
br label %184
183: ; preds = %165
br label %233
184: ; preds = %182
br label %185
185: ; preds = %184, %157
br label %223
186: ; preds = %143
%187 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%188 = call i32 @sscanf(i8* %187, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0), i32* %1)
%189 = icmp eq i32 %188, 1
br i1 %189, label %190, label %221
190: ; preds = %186
%191 = load i32, i32* %1
%192 = icmp eq i32 %191, 0
br i1 %192, label %203, label %193
193: ; preds = %190
%194 = load i32, i32* %1
%195 = load i32, i32* %5
%196 = icmp sge i32 %194, %195
br i1 %196, label %197, label %219
197: ; preds = %193
%198 = load i32, i32* %1
%199 = load i32, i32* %3
%200 = load i32, i32* %5
%201 = add nsw i32 %199, %200
%202 = icmp slt i32 %198, %201
br i1 %202, label %203, label %219
203: ; preds = %197, %190
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i64 0, i64 0))
store i32 9, i32* %1
br label %205
205: ; preds = %214, %203
%206 = load i32, i32* %1
%207 = icmp sge i32 %206, 0
br i1 %207, label %208, label %217
208: ; preds = %205
%209 = load i32, i32* %1
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i32 %209)
%211 = load i32, i32* @stdout
%212 = call i32 @fflush(i32 %211)
%213 = call i32 @sleep(i32 1)
br label %214
214: ; preds = %208
%215 = load i32, i32* %1
%216 = add nsw i32 %215, -1
store i32 %216, i32* %1
br label %205
217: ; preds = %205
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0))
br label %220
219: ; preds = %197, %193
br label %233
220: ; preds = %217
br label %222
221: ; preds = %186
br label %233
222: ; preds = %220
br label %223
223: ; preds = %222, %185
br label %224
224: ; preds = %223, %142
br label %225
225: ; preds = %224, %82
br label %226
226: ; preds = %225, %76
br label %227
227: ; preds = %226, %70
br label %228
228: ; preds = %227, %64
br label %229
229: ; preds = %228, %58
br label %230
230: ; preds = %229, %52
br label %231
231: ; preds = %230
br label %232
232: ; preds = %231
br label %22
233: ; preds = %221, %219, %183, %140
%234 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.24, i64 0, i64 0))
br label %22
235: ; preds = %47, %29, %22
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"Off\00"
@.str.2 = [7 x i8] c"RPC-4>\00"
@.str.3 = [7 x i8] c"logoff\00"
@.str.4 = [7 x i8] c"logout\00"
@.str.5 = [5 x i8] c"exit\00"
@.str.6 = [5 x i8] c"help\00"
@.str.8 = [5 x i8] c"temp\00"
@.str.14 = [6 x i8] c"power\00"
@.str.15 = [7 x i8] c"status\00"
@.str.16 = [985 x i8] c"\0D\0A\0D\0A-------------------------------------------------------------------------------\0D\0A| Outlet | True RMS | Peak RMS | True RMS | Average | Volt- |\0D\0A| Group | Current | Current | Voltage | Power | Amps |\0D\0A-------------------------------------------------------------------------------\0D\0A| Outlet 1-4 | 1.8 Amps | 2.3 Amps | 122.5 Volts | 216 Watts | 220 VA |\0D\0A| Outlet 5-8 | 2.4 Amps | 5.0 Amps | 122.1 Volts | 269 Watts | 277 VA |\0D\0A-------------------------------------------------------------------------------\0D\0A\0D\0AInternal Temperature: 78.8 F\0D\0A\0D\0ASwitch 1: Open 2: Open\0D\0A\0D\0A 1)...Outlet 1 : %s \0D\0A 2)...Outlet 2 : %s \0D\0A 3)...Outlet 3 : %s \0D\0A 4)...Outlet 4 : %s \0D\0A 5)...Outlet 5 : %s \0D\0A 6)...Outlet 6 : %s \0D\0A 7)...Outlet 7 : %s \0D\0A 8)...Outlet 8 : %s \0D\0A\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\0A\00"
@.str.17 = [6 x i8] c"on %d\00"
@.str.18 = [4 x i8] c"On \00"
@.str.19 = [7 x i8] c"off %d\00"
@.str.20 = [10 x i8] c"reboot %d\00"
@.str.21 = [17 x i8] c"\0D\0ARebooting... \00"
@.str.22 = [4 x i8] c"\08%d\00"
@stdout = global i32 0
@str = [134 x i8] c"\0D\0A\0D\0ARPC-3/4(A)DE Series\0D\0A(C) 2004 BayTech\0D\0AF1.08\0D\0A\0D\0AOption(s) Installed:\0D\0ATrue RMS Voltage\0D\0ATrue RMS Current\0D\0AInternal Temperature\0D\0A\0D\00"
@str.25 = [848 x i8] c"\0D\0A\0D\0AOn n <cr> --Turn on an Outlet, n=0,1...8,all\0D\0AOff n <cr> --Turn off an Outlet, n=0,1...8,all\0D\0AReboot n <cr> --Reboot an Outlet, n=0,1...8,all\0D\0AStatus <cr> --RPC-4 Status\0D\0AConfig <cr> --Enter configuration mode\0D\0ARC <cr> --Powerup/watchdog reset counts\0D\0ALock n <cr> --Locks Outlet(s) state, n=0,1...8,all\0D\0AUnlock n <cr> --Unlock Outlet(s) state, n=0,1...8,all\0D\0ACurrent <cr> --Display True RMS Current\0D\0AVoltage <cr> --Display True RMS Voltage\0D\0APower <cr> --Display Average Power\0D\0AClear <cr> --Reset the maximum detected current\0D\0ATemp <cr> --Read current temperature\0D\0ALogout <cr> --Logoff\0D\0ALogoff <cr> --Logoff\0D\0AExit <cr> --Logoff\0D\0APassword <cr> --Changes the current user password\0D\0AWhoami <cr> --Displays the current user name\0D\0AUnitid <cr> --Displays the unit ID\0D\0A\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\00"
@str.26 = [73 x i8] c"\0D\0A\0D\0AInternal Temperature: 77.9 F\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\00"
@str.27 = [282 x i8] c"\0D\0A\0D\0A--------------------------------\0D\0A| Outlet | True RMS |\0D\0A| Group | Voltage |\0D\0A--------------------------------\0D\0A| Outlet 1-4 | 122.4 Volts | \0D\0A| Outlet 5-8 | 122.3 Volts | \0D\0A--------------------------------\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\00"
@str.29 = [354 x i8] c"\0D\0A\0D\0A------------------------------------------\0D\0A| Outlet | True RMS | Peak RMS |\0D\0A| Group | Current | Current |\0D\0A------------------------------------------\0D\0A| Outlet 1-4 | 1.8 Amps | 2.3 Amps |\0D\0A| Outlet 5-8 | 2.3 Amps | 5.0 Amps |\0D\0A------------------------------------------\0D\0A\0D\0A\0D\0A\0D\0AType Help for a list of commands\0D\0A\0D\00"
@str.30 = [15 x i8] c"Input error\0D\0A\0D\00"
@str.31 = [2 x i8] c"\0D\00"
define void @_prompt_loop_rpc3_de() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca [8 x [4 x i8]]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 0, i64 0
store i32 0, i32* %1
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %13, %7 ]
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 %9, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
%14 = icmp slt i32 %12, 7
br i1 %14, label %7, label %15
15: ; preds = %7
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([134 x i8], [134 x i8]* @str, i64 0, i64 0))
%17 = call i32* @xreadline(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 128)
%18 = icmp eq i32* %17, null
br i1 %18, label %134, label %19
19: ; preds = %15
%20 = bitcast [128 x i8]* %2 to i64*
%21 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 1, i64 0
%22 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 2, i64 0
%23 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 3, i64 0
%24 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 4, i64 0
%25 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 5, i64 0
%26 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 6, i64 0
%27 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 7, i64 0
br label %28
28: ; preds = %19, %129
%29 = load i8, i8* %5
%30 = icmp eq i8 %29, 0
br i1 %30, label %129, label %31
31: ; preds = %28
%32 = call i32 @bcmp(i8* dereferenceable(7) %5, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 7)
%33 = icmp eq i32 %32, 0
br i1 %33, label %134, label %34
34: ; preds = %31
%35 = call i32 @bcmp(i8* dereferenceable(7) %5, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 7)
%36 = icmp eq i32 %35, 0
br i1 %36, label %134, label %37
37: ; preds = %34
%38 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 5)
%39 = icmp eq i32 %38, 0
br i1 %39, label %134, label %40
40: ; preds = %37
%41 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 5)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([848 x i8], [848 x i8]* @str.25, i64 0, i64 0))
br label %129
45: ; preds = %40
%46 = call i32 @bcmp(i8* dereferenceable(5) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i64 5)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.26, i64 0, i64 0))
br label %129
50: ; preds = %45
%51 = load i64, i64* %20
switch i64 %51, label %56 [
i64 28542640910528374, label %52
i64 32772479289292131, label %54
]
52: ; preds = %50
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([282 x i8], [282 x i8]* @str.27, i64 0, i64 0))
br label %129
54: ; preds = %50
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([354 x i8], [354 x i8]* @str.29, i64 0, i64 0))
br label %129
56: ; preds = %50
%57 = call i32 @bcmp(i8* dereferenceable(6) %5, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i64 6)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([354 x i8], [354 x i8]* @str.29, i64 0, i64 0))
br label %129
61: ; preds = %56
%62 = call i32 @bcmp(i8* dereferenceable(7) %5, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i64 7)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([985 x i8], [985 x i8]* @.str.16, i64 0, i64 0), i8* %6, i8* %21, i8* %22, i8* %23, i8* %24, i8* %25, i8* %26, i8* %27)
br label %129
66: ; preds = %61
%67 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32* %1)
%68 = icmp eq i32 %67, 1
br i1 %68, label %69, label %88
69: ; preds = %66
%70 = load i32, i32* %1
%71 = add i32 %70, -1
%72 = icmp ult i32 %71, 8
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = zext i32 %71 to i64
%75 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 %74, i64 0
%76 = call i32 @strcpy(i8* %75, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0))
br label %129
77: ; preds = %69
%78 = icmp eq i32 %70, 0
br i1 %78, label %79, label %132
79: ; preds = %77
store i32 0, i32* %1
br label %80
80: ; preds = %79, %80
%81 = phi i32 [ 0, %79 ], [ %86, %80 ]
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 %82, i64 0
%84 = call i32 @strcpy(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0))
%85 = load i32, i32* %1
%86 = add nsw i32 %85, 1
store i32 %86, i32* %1
%87 = icmp slt i32 %85, 7
br i1 %87, label %80, label %129
88: ; preds = %66
%89 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i32* %1)
%90 = icmp eq i32 %89, 1
br i1 %90, label %91, label %110
91: ; preds = %88
%92 = load i32, i32* %1
%93 = add i32 %92, -1
%94 = icmp ult i32 %93, 8
br i1 %94, label %95, label %99
95: ; preds = %91
%96 = zext i32 %93 to i64
%97 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 %96, i64 0
%98 = call i32 @strcpy(i8* %97, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %129
99: ; preds = %91
%100 = icmp eq i32 %92, 0
br i1 %100, label %101, label %132
101: ; preds = %99
store i32 0, i32* %1
br label %102
102: ; preds = %101, %102
%103 = phi i32 [ 0, %101 ], [ %108, %102 ]
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [8 x [4 x i8]], [8 x [4 x i8]]* %3, i64 0, i64 %104, i64 0
%106 = call i32 @strcpy(i8* %105, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%107 = load i32, i32* %1
%108 = add nsw i32 %107, 1
store i32 %108, i32* %1
%109 = icmp slt i32 %107, 7
br i1 %109, label %102, label %129
110: ; preds = %88
%111 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0), i32* %1)
%112 = icmp eq i32 %111, 1
%113 = load i32, i32* %1
%114 = icmp ult i32 %113, 9
%115 = select i1 %112, i1 %114, i1 false
br i1 %115, label %116, label %132
116: ; preds = %110
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i64 0, i64 0))
store i32 9, i32* %1
br label %118
118: ; preds = %116, %118
%119 = phi i32 [ 9, %116 ], [ %125, %118 ]
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i32 %119)
%121 = load i32, i32* @stdout
%122 = call i32 @fflush(i32 %121)
%123 = call i32 @sleep(i32 1)
%124 = load i32, i32* %1
%125 = add nsw i32 %124, -1
store i32 %125, i32* %1
%126 = icmp sgt i32 %124, 0
br i1 %126, label %118, label %127
127: ; preds = %118
%128 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.31, i64 0, i64 0))
br label %129
129: ; preds = %102, %80, %43, %52, %59, %73, %95, %127, %64, %54, %48, %132, %28
%130 = call i32* @xreadline(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 128)
%131 = icmp eq i32* %130, null
br i1 %131, label %134, label %28
132: ; preds = %110, %99, %77
%133 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.30, i64 0, i64 0))
br label %129
134: ; preds = %129, %37, %34, %31, %15
ret void
}