#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*/ szVariableName;

/* Variables and functions */
int /*<<< orphan*/ getBit(int, int, int);
int getopt(int, char **, char *);
char *optarg;
int piControlReset();
int /*<<< orphan*/ piControlResetCounter(int, unsigned int);
int piControlStopIO(int);
int piControlUpdateFirmware(int /*<<< orphan*/);
int piControlWaitForEvent();
int /*<<< orphan*/ printHelp(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ readData(int, int, int, char, int);
int /*<<< orphan*/ readVariableValue(char *, int, char, int);
int /*<<< orphan*/ setBit(int, int, unsigned long);
int /*<<< orphan*/ showDeviceList();
int /*<<< orphan*/ showVariableInfo(char *);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
char *strtok(char *, char *);
unsigned long strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ writeData(int, int, unsigned long);
int /*<<< orphan*/ writeVariableValue(char *, unsigned long);
int main(int argc, char *argv[]) {
  int c;
  int rc;
  int offset;
  int length;
  int address;
  unsigned int val;
  char format;
  int bit;
  bool cyclic = true;
  bool quiet = false;
  unsigned long value;
  char szVariableName[256];
  char *pszTok, *progname;
  progname = strrchr(argv[0], '/');
  if (!progname) {
    progname = argv[0];
  } else {
    progname++;
  }
  if (!strcmp(progname, "piControlReset")) {
    rc = piControlReset();
    if (rc) {
      printf("Cannot reset: %s\n", strerror(-rc));
    }
    return rc;
  }
  if (argc == 1) {
    printHelp(progname);
    return 0;
  }
  while ((c = getopt(argc, argv, "dv:1qr:w:s:R:g:xlfS")) != -1) {
    switch (c) {
    case 'd':
      showDeviceList();
      break;
    case 'v':
      if (strlen(optarg) > 0) {
        showVariableInfo(optarg);
      } else {
        printf("No variable name\n");
      }
      break;
    case '1':
      cyclic = false;
      break;
    case 'q':
      quiet = true;
      break;
    case 'r':
      format = 'd';
      rc = sscanf(optarg, "%d,%d,%c", &offset, &length, &format);
      if (rc == 3) {
        readData(offset, length, cyclic, format, quiet);
        return 0;
      }
      rc = sscanf(optarg, "%d,%d", &offset, &length);
      if (rc == 2) {
        readData(offset, length, cyclic, format, quiet);
        return 0;
      }
      rc = sscanf(optarg, "%s", szVariableName);
      if (rc == 1) {
        pszTok = strtok(szVariableName, ",");
        if (pszTok != NULL) {
          pszTok = strtok(NULL, ",");
          if (pszTok != NULL) {
            format = *pszTok;
          }
        }
        readVariableValue(szVariableName, cyclic, format, quiet);
        return 0;
      }
      printf("Wrong arguments for read function\n");
      printf("1.) Try '-r variablename'\n");
      printf("2.) Try '-r offset,length' (without spaces)\n");
      break;
    case 'w':
      rc = sscanf(optarg, "%d,%d,%lu", &offset, &length, &value);
      if (rc == 3) {
        writeData(offset, length, value);
        return 0;
      }
      pszTok = strtok(optarg, ",");
      if (pszTok != NULL) {
        strncpy(szVariableName, pszTok, sizeof(szVariableName));
        pszTok = strtok(NULL, ",");
        if (pszTok != NULL) {
          value = strtol(pszTok, NULL, 10);
          writeVariableValue(szVariableName, value);
          return 0;
        }
      }
      printf("Wrong arguments for write function\n");
      printf("1.) Try '-w variablename,value' (without spaces)\n");
      printf("2.) Try '-w offset,length,value' (without spaces)\n");
      break;
    case 's':
      rc = sscanf(optarg, "%d,%d,%lu", &offset, &bit, &value);
      if (rc != 3) {
        printf("Wrong arguments for set bit function\n");
        printf("Try '-s offset,bit,value' (without spaces)\n");
        return 0;
      }
      setBit(offset, bit, value);
      break;
    case 'R':
      rc = sscanf(optarg, "%d,0x%x", &address, &val);
      if (rc != 2) {
        rc = sscanf(optarg, "%d,%u", &address, &val);
        if (rc != 2) {
          printf("Wrong arguments for counter reset function\n");
          printf("Try '-R address,value' (without spaces)\n");
          return 0;
        }
      }
      piControlResetCounter(address, val);
      break;
    case 'g':
      rc = sscanf(optarg, "%d,%d", &offset, &bit);
      if (rc != 2) {
        printf("Wrong arguments for get bit function\n");
        printf("Try '-g offset,bit' (without spaces)\n");
        return 0;
      }
      getBit(offset, bit, quiet);
      break;
    case 'x':
      rc = piControlReset();
      if (rc) {
        printf("Cannot reset: %s\n", strerror(-rc));
        return rc;
      }
      break;
    case 'l':
      rc = piControlWaitForEvent();
      if (rc < 0) {
        printf("WaitForEvent returned: %d (%s)\n", rc, strerror(-rc));
        return rc;
      } else if (rc == 1) {
        printf("WaitForEvent returned: Reset\n");
        return rc;
      } else {
        printf("WaitForEvent returned: %d\n", rc);
        return rc;
      }
      break;
    case 'f':
      rc = piControlUpdateFirmware(0);
      if (rc) {
        printf("piControlUpdateFirmware returned: %d (%s)\n", rc,
               strerror(-rc));
        return rc;
      }
      break;
    case 'S':
      rc = piControlStopIO(2);
      if (rc < 0) {
        printf("error in setting I/O update mode: %d\n", rc);
      } else if (rc == 0) {
        printf("I/Os and process image are updated\n");
      } else {
        printf("update of I/Os and process image is stopped\n");
      }
      break;
    case 'h':
    default:
      printHelp(progname);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x150(%rbp)
jne    12e0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x150(%rbp)
jmp    12f2 <main+0x72>
mov    -0x150(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x150(%rbp)
mov    -0x150(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    1348 <main+0xc8>
mov    $0x0,%al
call   1070 <piControlReset@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     133d <main+0xbd>
xor    %edi,%edi
sub    -0x18(%rbp),%edi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    19c4 <main+0x744>
cmpl   $0x1,-0x8(%rbp)
jne    136a <main+0xea>
mov    -0x150(%rbp),%rdi
call   1030 <printHelp@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
jmp    136f <main+0xef>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdc4(%rip),%rdx
call   1160 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     19bd <main+0x73d>
mov    -0x14(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x158(%rbp)
sub    $0x47,%eax
ja     19ac <main+0x72c>
mov    -0x158(%rbp),%rax
lea    0xc4c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1140 <showDeviceList@plt>
jmp    19b8 <main+0x738>
mov    0x2c28(%rip),%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%eax
jle    13f5 <main+0x175>
mov    0x2c10(%rip),%rax
mov    (%rax),%rdi
call   1180 <showVariableInfo@plt>
jmp    1403 <main+0x183>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    19b8 <main+0x738>
movl   $0x0,-0x34(%rbp)
jmp    19b8 <main+0x738>
movl   $0x1,-0x38(%rbp)
jmp    19b8 <main+0x738>
movb   $0x64,-0x29(%rbp)
mov    0x2bcd(%rip),%rax
mov    (%rax),%rdi
lea    0xd32(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x29(%rbp),%r8
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jne    1479 <main+0x1f9>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x29(%rbp),%al
mov    -0x38(%rbp),%r8d
movsbl %al,%ecx
call   10a0 <readData@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
mov    0x2b78(%rip),%rax
mov    (%rax),%rdi
lea    0xce6(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    14ca <main+0x24a>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x29(%rbp),%al
mov    -0x38(%rbp),%r8d
movsbl %al,%ecx
call   10a0 <readData@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
mov    0x2b27(%rip),%rax
mov    (%rax),%rdi
lea    -0x140(%rbp),%rdx
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1578 <main+0x2f8>
lea    -0x140(%rbp),%rdi
lea    0xc75(%rip),%rsi
call   1150 <strtok@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
je     1554 <main+0x2d4>
xor    %eax,%eax
mov    %eax,%edi
lea    0xc50(%rip),%rsi
call   1150 <strtok@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
je     154f <main+0x2cf>
mov    -0x148(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
jmp    1554 <main+0x2d4>
lea    -0x140(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x29(%rbp),%al
mov    -0x38(%rbp),%ecx
movsbl %al,%edx
call   1100 <readVariableValue@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xc11(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    19b8 <main+0x738>
mov    0x2a4a(%rip),%rax
mov    (%rax),%rdi
lea    0xc2e(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x40(%rbp),%r8
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jne    15f3 <main+0x373>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x40(%rbp),%rdx
call   1190 <writeData@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
mov    0x29fe(%rip),%rax
mov    (%rax),%rdi
lea    0xb75(%rip),%rsi
call   1150 <strtok@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
je     1695 <main+0x415>
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xb38(%rip),%rsi
call   1150 <strtok@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
je     1690 <main+0x410>
mov    -0x148(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10d0 <strtol@plt>
mov    %rax,-0x40(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10e0 <writeVariableValue@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
jmp    1695 <main+0x415>
lea    0xb54(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb6a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb8e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    19b8 <main+0x738>
mov    0x292d(%rip),%rax
mov    (%rax),%rdi
lea    0xb11(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x40(%rbp),%r8
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
je     171d <main+0x49d>
lea    0xb7d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb95(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x40(%rbp),%rdx
call   1130 <setBit@plt>
jmp    19b8 <main+0x738>
mov    0x28c0(%rip),%rax
mov    (%rax),%rdi
lea    0xb89(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
je     17b8 <main+0x538>
mov    0x2893(%rip),%rax
mov    (%rax),%rdi
lea    0xb64(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
je     17b3 <main+0x533>
lea    0xb47(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb65(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
jmp    17b8 <main+0x538>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1120 <piControlResetCounter@plt>
jmp    19b8 <main+0x738>
mov    0x2829(%rip),%rax
mov    (%rax),%rdi
lea    0x997(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1110 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
je     181d <main+0x59d>
lea    0xb32(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb4a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    19c4 <main+0x744>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%edx
call   10f0 <getBit@plt>
jmp    19b8 <main+0x738>
mov    $0x0,%al
call   1070 <piControlReset@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     186a <main+0x5ea>
xor    %edi,%edi
sub    -0x18(%rbp),%edi
call   11a0 <strerror@plt>
mov    %rax,%rsi
lea    0x8d7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    19c4 <main+0x744>
jmp    19b8 <main+0x738>
mov    $0x0,%al
call   1170 <piControlWaitForEvent@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    18b8 <main+0x638>
mov    -0x18(%rbp),%eax
mov    %eax,-0x15c(%rbp)
xor    %edi,%edi
sub    -0x18(%rbp),%edi
call   11a0 <strerror@plt>
mov    -0x15c(%rbp),%esi
mov    %rax,%rdx
lea    0xad4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    19c4 <main+0x744>
cmpl   $0x1,-0x18(%rbp)
jne    18db <main+0x65b>
lea    0xad1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    19c4 <main+0x744>
mov    -0x18(%rbp),%esi
lea    0xad3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    19c4 <main+0x744>
xor    %edi,%edi
call   10c0 <piControlUpdateFirmware@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1940 <main+0x6c0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x160(%rbp)
xor    %edi,%edi
sub    -0x18(%rbp),%edi
call   11a0 <strerror@plt>
mov    -0x160(%rbp),%esi
mov    %rax,%rdx
lea    0xaa5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    19c4 <main+0x744>
jmp    19b8 <main+0x738>
mov    $0x2,%edi
call   1050 <piControlStopIO@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1972 <main+0x6f2>
mov    -0x18(%rbp),%esi
lea    0xa98(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    19a2 <main+0x722>
cmpl   $0x0,-0x18(%rbp)
jne    198f <main+0x70f>
lea    0xaa1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    199d <main+0x71d>
lea    0xab2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    19a2 <main+0x722>
jmp    19b8 <main+0x738>
jmp    19ac <main+0x72c>
mov    -0x150(%rbp),%rdi
call   1030 <printHelp@plt>
jmp    136f <main+0xef>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %rsi,%r12
mov    %edi,%r14d
mov    (%rsi),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   10a0 <strrchr@plt>
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %rbp,%rbx
lea    0xf1f(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     12e8 <main+0x58>
cmp    $0x1,%r14d
jne    132a <main+0x9a>
mov    %rbx,%rdi
call   1030 <printHelp@plt>
xor    %r13d,%r13d
jmp    1315 <main+0x85>
xor    %r13d,%r13d
xor    %eax,%eax
call   1080 <piControlReset@plt>
test   %eax,%eax
je     1315 <main+0x85>
mov    %eax,%ebx
mov    %eax,%edi
neg    %edi
call   11b0 <strerror@plt>
lea    0xeef(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %ebx,%r13d
mov    %r13d,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,0x38(%rsp)
mov    $0x1,%eax
lea    0xece(%rip),%rbx
lea    0xcbe(%rip),%rbp
movl   $0x0,0x14(%rsp)
mov    %r12,0x30(%rsp)
jmp    1360 <main+0xd0>
movl   $0x1,0x14(%rsp)
mov    %r15d,%eax
nopl   0x0(%rax)
mov    %eax,%r15d
mov    %r14d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1170 <getopt@plt>
add    $0x1,%eax
cmp    $0x79,%eax
ja     13f5 <main+0x165>
movslq 0x0(%rbp,%rax,4),%rcx
add    %rbp,%rcx
xor    %eax,%eax
jmp    *%rcx
mov    0x2c6c(%rip),%rbx
mov    (%rbx),%rdi
lea    0xea5(%rip),%rsi
lea    0x2c(%rsp),%rbp
mov    %rbp,%rdx
lea    0x28(%rsp),%r13
mov    %r13,%rcx
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x2,%eax
je     13d2 <main+0x142>
mov    (%rbx),%rdi
lea    0xe87(%rip),%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x2,%eax
jne    17fd <main+0x56d>
mov    0x2c(%rsp),%edi
mov    0x28(%rsp),%esi
call   1130 <piControlResetCounter@plt>
mov    %r15d,%eax
lea    0xe20(%rip),%rbx
lea    0xc10(%rip),%rbp
jmp    1360 <main+0xd0>
mov    0x38(%rsp),%rdi
call   1030 <printHelp@plt>
mov    %r15d,%eax
jmp    1360 <main+0xd0>
mov    $0x2,%edi
call   1060 <piControlStopIO@plt>
test   %eax,%eax
js     166a <main+0x3da>
je     169d <main+0x40d>
lea    0xeaf(%rip),%rdi
jmp    16a4 <main+0x414>
xor    %eax,%eax
call   1150 <showDeviceList@plt>
mov    %r15d,%eax
jmp    1360 <main+0xd0>
xor    %edi,%edi
call   10d0 <piControlUpdateFirmware@plt>
mov    %eax,%r13d
mov    %r15d,%eax
test   %r13d,%r13d
je     1360 <main+0xd0>
jmp    1703 <main+0x473>
mov    0x2b9c(%rip),%rax
mov    (%rax),%rdi
lea    0xdc0(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x1c(%rsp),%rcx
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x2,%eax
jne    1719 <main+0x489>
mov    0x10(%rsp),%edi
mov    0x1c(%rsp),%esi
mov    0x14(%rsp),%edx
call   1100 <getBit@plt>
mov    %r15d,%eax
jmp    1360 <main+0xd0>
mov    %r14d,%r12d
movb   $0x64,0xf(%rsp)
mov    0x2b50(%rip),%r13
mov    0x0(%r13),%rdi
lea    0xd6a(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
lea    0x18(%rsp),%r14
mov    %r14,%rcx
lea    0xf(%rsp),%r8
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x3,%eax
je     16b1 <main+0x421>
mov    0x0(%r13),%rdi
lea    0xd43(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x2,%eax
je     16b1 <main+0x421>
mov    0x0(%r13),%rdi
lea    0xd28(%rip),%rsi
lea    0x40(%rsp),%rdx
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x1,%eax
je     178a <main+0x4fa>
lea    0xf94(%rip),%rdi
call   1050 <puts@plt>
lea    0xfaa(%rip),%rdi
call   1050 <puts@plt>
lea    0xfb8(%rip),%rdi
call   1050 <puts@plt>
mov    %r15d,%eax
lea    0xcc2(%rip),%rbx
mov    %r12d,%r14d
mov    0x30(%rsp),%r12
jmp    1360 <main+0xd0>
mov    0x2a9d(%rip),%rax
mov    (%rax),%rdi
lea    0xccc(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0x20(%rsp),%r8
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x3,%eax
jne    1736 <main+0x4a6>
mov    0x10(%rsp),%edi
mov    0x1c(%rsp),%esi
mov    0x20(%rsp),%rdx
call   1140 <setBit@plt>
mov    %r15d,%eax
jmp    1360 <main+0xd0>
mov    0x2a53(%rip),%rbx
mov    (%rbx),%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    1682 <main+0x3f2>
mov    (%rbx),%rdi
call   1190 <showVariableInfo@plt>
jmp    168e <main+0x3fe>
mov    0x2a2f(%rip),%rbx
mov    (%rbx),%rdi
lea    0xc5e(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x20(%rsp),%r8
xor    %eax,%eax
call   1120 <sscanf@plt>
cmp    $0x3,%eax
je     1753 <main+0x4c3>
mov    (%rbx),%rdi
lea    0xc33(%rip),%rbx
mov    %rbx,%rsi
call   1160 <strtok@plt>
test   %rax,%rax
je     162e <main+0x39e>
lea    0x40(%rsp),%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1160 <strtok@plt>
test   %rax,%rax
jne    17d4 <main+0x544>
lea    0xdf9(%rip),%rdi
call   1050 <puts@plt>
lea    0xe10(%rip),%rdi
call   1050 <puts@plt>
lea    0xe35(%rip),%rdi
jmp    1689 <main+0x3f9>
xor    %eax,%eax
call   1080 <piControlReset@plt>
mov    %eax,%r13d
mov    %r15d,%eax
test   %r13d,%r13d
je     1360 <main+0xd0>
jmp    176a <main+0x4da>
lea    0xc3e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15d,%eax
jmp    1360 <main+0xd0>
lea    0xe93(%rip),%rdi
call   1050 <puts@plt>
mov    %r15d,%eax
lea    0xb71(%rip),%rbx
jmp    1360 <main+0xd0>
lea    0xc5d(%rip),%rdi
call   1050 <puts@plt>
mov    %r15d,%eax
jmp    1360 <main+0xd0>
mov    0x10(%rsp),%edi
mov    0x18(%rsp),%esi
movsbl 0xf(%rsp),%ecx
mov    %r15d,%edx
mov    0x14(%rsp),%r8d
call   10b0 <readData@plt>
jmp    12e3 <main+0x53>
xor    %eax,%eax
call   1180 <piControlWaitForEvent@plt>
mov    %eax,%r13d
test   %eax,%eax
js     181a <main+0x58a>
cmp    $0x1,%r13d
jne    183d <main+0x5ad>
lea    0xc31(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%r13d
jmp    1315 <main+0x85>
mov    %r13d,%edi
neg    %edi
call   11b0 <strerror@plt>
lea    0xb70(%rip),%rdi
jmp    182b <main+0x59b>
lea    0xc21(%rip),%rdi
call   1050 <puts@plt>
lea    0xc3a(%rip),%rdi
call   1050 <puts@plt>
jmp    12e3 <main+0x53>
lea    0xca1(%rip),%rdi
call   1050 <puts@plt>
lea    0xcba(%rip),%rdi
call   1050 <puts@plt>
jmp    12e3 <main+0x53>
mov    0x10(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x20(%rsp),%rdx
call   11a0 <writeData@plt>
jmp    12e3 <main+0x53>
mov    %r13d,%edi
neg    %edi
call   11b0 <strerror@plt>
lea    0xa7c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1315 <main+0x85>
lea    0xa9e(%rip),%rsi
lea    0x40(%rsp),%rdi
call   1160 <strtok@plt>
test   %rax,%rax
je     17b9 <main+0x529>
lea    0xa88(%rip),%rsi
xor    %edi,%edi
call   1160 <strtok@plt>
test   %rax,%rax
je     17b9 <main+0x529>
mov    (%rax),%al
mov    %al,0xf(%rsp)
movsbl 0xf(%rsp),%edx
lea    0x40(%rsp),%rdi
mov    %r15d,%esi
mov    0x14(%rsp),%ecx
call   1110 <readVariableValue@plt>
jmp    12e3 <main+0x53>
xor    %r13d,%r13d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10e0 <strtol@plt>
mov    %rax,0x20(%rsp)
lea    0x40(%rsp),%rdi
mov    %rax,%rsi
call   10f0 <writeVariableValue@plt>
jmp    1315 <main+0x85>
lea    0xb87(%rip),%rdi
call   1050 <puts@plt>
lea    0xba6(%rip),%rdi
call   1050 <puts@plt>
jmp    12e3 <main+0x53>
mov    %r13d,%edi
neg    %edi
call   11b0 <strerror@plt>
lea    0xa1e(%rip),%rdi
mov    %r13d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1315 <main+0x85>
lea    0xa25(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1315 <main+0x85>

LLVM IR (-O0):
@.str = [15 x i8] c"piControlReset\00"
@.str.1 = [18 x i8] c"Cannot reset: %s\0A\00"
@.str.2 = [20 x i8] c"dv:1qr:w:s:R:g:xlfS\00"
@optarg = global i8* null
@.str.3 = [18 x i8] c"No variable name\0A\00"
@.str.4 = [9 x i8] c"%d,%d,%c\00"
@.str.5 = [6 x i8] c"%d,%d\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [2 x i8] c",\00"
@.str.8 = [35 x i8] c"Wrong arguments for read function\0A\00"
@.str.9 = [27 x i8] c"1.) Try '-r variablename'\0A\00"
@.str.10 = [45 x i8] c"2.) Try '-r offset,length' (without spaces)\0A\00"
@.str.11 = [10 x i8] c"%d,%d,%lu\00"
@.str.12 = [36 x i8] c"Wrong arguments for write function\0A\00"
@.str.13 = [50 x i8] c"1.) Try '-w variablename,value' (without spaces)\0A\00"
@.str.14 = [51 x i8] c"2.) Try '-w offset,length,value' (without spaces)\0A\00"
@.str.15 = [38 x i8] c"Wrong arguments for set bit function\0A\00"
@.str.16 = [44 x i8] c"Try '-s offset,bit,value' (without spaces)\0A\00"
@.str.17 = [8 x i8] c"%d,0x%x\00"
@.str.18 = [6 x i8] c"%d,%u\00"
@.str.19 = [44 x i8] c"Wrong arguments for counter reset function\0A\00"
@.str.20 = [41 x i8] c"Try '-R address,value' (without spaces)\0A\00"
@.str.21 = [38 x i8] c"Wrong arguments for get bit function\0A\00"
@.str.22 = [38 x i8] c"Try '-g offset,bit' (without spaces)\0A\00"
@.str.23 = [32 x i8] c"WaitForEvent returned: %d (%s)\0A\00"
@.str.24 = [30 x i8] c"WaitForEvent returned: Reset\0A\00"
@.str.25 = [27 x i8] c"WaitForEvent returned: %d\0A\00"
@.str.26 = [43 x i8] c"piControlUpdateFirmware returned: %d (%s)\0A\00"
@.str.27 = [38 x i8] c"error in setting I/O update mode: %d\0A\00"
@.str.28 = [36 x i8] c"I/Os and process image are updated\0A\00"
@.str.29 = [45 x i8] c"update of I/Os and process image is stopped\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca [256 x i8]
%18 = alloca i8*
%19 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %14
store i32 0, i32* %15
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i8* @strrchr(i8* %22, i8 signext 47)
store i8* %23, i8** %19
%24 = load i8*, i8** %19
%25 = icmp ne i8* %24, null
br i1 %25, label %30, label %26
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
store i8* %29, i8** %19
br label %33
30: ; preds = %2
%31 = load i8*, i8** %19
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %19
br label %33
33: ; preds = %30, %26
%34 = load i8*, i8** %19
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %48, label %37
37: ; preds = %33
%38 = call i32 (...) @piControlReset()
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i32, i32* %7
%43 = sub nsw i32 0, %42
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %41, %37
%47 = load i32, i32* %7
store i32 %47, i32* %3
br label %272
48: ; preds = %33
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i8*, i8** %19
%53 = call i32 @printHelp(i8* %52)
store i32 0, i32* %3
br label %272
54: ; preds = %48
br label %55
55: ; preds = %270, %54
%56 = load i32, i32* %4
%57 = load i8**, i8*** %5
%58 = call i32 @getopt(i32 %56, i8** %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 %58, i32* %6
%59 = icmp ne i32 %58, -1
br i1 %59, label %60, label %271
60: ; preds = %55
%61 = load i32, i32* %6
switch i32 %61, label %267 [
i32 100, label %62
i32 118, label %64
i32 49, label %74
i32 113, label %75
i32 114, label %76
i32 119, label %129
i32 115, label %162
i32 82, label %175
i32 103, label %193
i32 120, label %206
i32 108, label %217
i32 102, label %238
i32 83, label %250
i32 104, label %266
]
62: ; preds = %60
%63 = call i32 (...) @showDeviceList()
br label %270
64: ; preds = %60
%65 = load i8*, i8** @optarg
%66 = call i32 @strlen(i8* %65)
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = load i8*, i8** @optarg
%70 = call i32 @showVariableInfo(i8* %69)
br label %73
71: ; preds = %64
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %71, %68
br label %270
74: ; preds = %60
store i32 0, i32* %14
br label %270
75: ; preds = %60
store i32 1, i32* %15
br label %270
76: ; preds = %60
store i8 100, i8* %12
%77 = load i8*, i8** @optarg
%78 = call i32 (i8*, i8*, ...) @sscanf(i8* %77, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %8, i32* %9, i8* %12)
store i32 %78, i32* %7
%79 = load i32, i32* %7
%80 = icmp eq i32 %79, 3
br i1 %80, label %81, label %88
81: ; preds = %76
%82 = load i32, i32* %8
%83 = load i32, i32* %9
%84 = load i32, i32* %14
%85 = load i8, i8* %12
%86 = load i32, i32* %15
%87 = call i32 @readData(i32 %82, i32 %83, i32 %84, i8 signext %85, i32 %86)
store i32 0, i32* %3
br label %272
88: ; preds = %76
%89 = load i8*, i8** @optarg
%90 = call i32 (i8*, i8*, ...) @sscanf(i8* %89, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %8, i32* %9)
store i32 %90, i32* %7
%91 = load i32, i32* %7
%92 = icmp eq i32 %91, 2
br i1 %92, label %93, label %100
93: ; preds = %88
%94 = load i32, i32* %8
%95 = load i32, i32* %9
%96 = load i32, i32* %14
%97 = load i8, i8* %12
%98 = load i32, i32* %15
%99 = call i32 @readData(i32 %94, i32 %95, i32 %96, i8 signext %97, i32 %98)
store i32 0, i32* %3
br label %272
100: ; preds = %88
%101 = load i8*, i8** @optarg
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%103 = call i32 (i8*, i8*, ...) @sscanf(i8* %101, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %102)
store i32 %103, i32* %7
%104 = load i32, i32* %7
%105 = icmp eq i32 %104, 1
br i1 %105, label %106, label %125
106: ; preds = %100
%107 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%108 = call i8* @strtok(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %108, i8** %18
%109 = load i8*, i8** %18
%110 = icmp ne i8* %109, null
br i1 %110, label %111, label %119
111: ; preds = %106
%112 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %112, i8** %18
%113 = load i8*, i8** %18
%114 = icmp ne i8* %113, null
br i1 %114, label %115, label %118
115: ; preds = %111
%116 = load i8*, i8** %18
%117 = load i8, i8* %116
store i8 %117, i8* %12
br label %118
118: ; preds = %115, %111
br label %119
119: ; preds = %118, %106
%120 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%121 = load i32, i32* %14
%122 = load i8, i8* %12
%123 = load i32, i32* %15
%124 = call i32 @readVariableValue(i8* %120, i32 %121, i8 signext %122, i32 %123)
store i32 0, i32* %3
br label %272
125: ; preds = %100
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
br label %270
129: ; preds = %60
%130 = load i8*, i8** @optarg
%131 = call i32 (i8*, i8*, ...) @sscanf(i8* %130, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32* %8, i32* %9, i64* %16)
store i32 %131, i32* %7
%132 = load i32, i32* %7
%133 = icmp eq i32 %132, 3
br i1 %133, label %134, label %139
134: ; preds = %129
%135 = load i32, i32* %8
%136 = load i32, i32* %9
%137 = load i64, i64* %16
%138 = call i32 @writeData(i32 %135, i32 %136, i64 %137)
store i32 0, i32* %3
br label %272
139: ; preds = %129
%140 = load i8*, i8** @optarg
%141 = call i8* @strtok(i8* %140, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %141, i8** %18
%142 = load i8*, i8** %18
%143 = icmp ne i8* %142, null
br i1 %143, label %144, label %158
144: ; preds = %139
%145 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%146 = load i8*, i8** %18
%147 = call i32 @strncpy(i8* %145, i8* %146, i32 256)
%148 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %148, i8** %18
%149 = load i8*, i8** %18
%150 = icmp ne i8* %149, null
br i1 %150, label %151, label %157
151: ; preds = %144
%152 = load i8*, i8** %18
%153 = call i64 @strtol(i8* %152, i32* null, i32 10)
store i64 %153, i64* %16
%154 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%155 = load i64, i64* %16
%156 = call i32 @writeVariableValue(i8* %154, i64 %155)
store i32 0, i32* %3
br label %272
157: ; preds = %144
br label %158
158: ; preds = %157, %139
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0))
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.13, i64 0, i64 0))
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0))
br label %270
162: ; preds = %60
%163 = load i8*, i8** @optarg
%164 = call i32 (i8*, i8*, ...) @sscanf(i8* %163, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32* %8, i32* %13, i64* %16)
store i32 %164, i32* %7
%165 = load i32, i32* %7
%166 = icmp ne i32 %165, 3
br i1 %166, label %167, label %170
167: ; preds = %162
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0))
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.16, i64 0, i64 0))
store i32 0, i32* %3
br label %272
170: ; preds = %162
%171 = load i32, i32* %8
%172 = load i32, i32* %13
%173 = load i64, i64* %16
%174 = call i32 @setBit(i32 %171, i32 %172, i64 %173)
br label %270
175: ; preds = %60
%176 = load i8*, i8** @optarg
%177 = call i32 (i8*, i8*, ...) @sscanf(i8* %176, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i32* %10, i32* %11)
store i32 %177, i32* %7
%178 = load i32, i32* %7
%179 = icmp ne i32 %178, 2
br i1 %179, label %180, label %189
180: ; preds = %175
%181 = load i8*, i8** @optarg
%182 = call i32 (i8*, i8*, ...) @sscanf(i8* %181, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i32* %10, i32* %11)
store i32 %182, i32* %7
%183 = load i32, i32* %7
%184 = icmp ne i32 %183, 2
br i1 %184, label %185, label %188
185: ; preds = %180
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0))
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0))
store i32 0, i32* %3
br label %272
188: ; preds = %180
br label %189
189: ; preds = %188, %175
%190 = load i32, i32* %10
%191 = load i32, i32* %11
%192 = call i32 @piControlResetCounter(i32 %190, i32 %191)
br label %270
193: ; preds = %60
%194 = load i8*, i8** @optarg
%195 = call i32 (i8*, i8*, ...) @sscanf(i8* %194, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %8, i32* %13)
store i32 %195, i32* %7
%196 = load i32, i32* %7
%197 = icmp ne i32 %196, 2
br i1 %197, label %198, label %201
198: ; preds = %193
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.21, i64 0, i64 0))
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0))
store i32 0, i32* %3
br label %272
201: ; preds = %193
%202 = load i32, i32* %8
%203 = load i32, i32* %13
%204 = load i32, i32* %15
%205 = call i32 @getBit(i32 %202, i32 %203, i32 %204)
br label %270
206: ; preds = %60
%207 = call i32 (...) @piControlReset()
store i32 %207, i32* %7
%208 = load i32, i32* %7
%209 = icmp ne i32 %208, 0
br i1 %209, label %210, label %216
210: ; preds = %206
%211 = load i32, i32* %7
%212 = sub nsw i32 0, %211
%213 = call i8* @strerror(i32 %212)
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %213)
%215 = load i32, i32* %7
store i32 %215, i32* %3
br label %272
216: ; preds = %206
br label %270
217: ; preds = %60
%218 = call i32 (...) @piControlWaitForEvent()
store i32 %218, i32* %7
%219 = load i32, i32* %7
%220 = icmp slt i32 %219, 0
br i1 %220, label %221, label %228
221: ; preds = %217
%222 = load i32, i32* %7
%223 = load i32, i32* %7
%224 = sub nsw i32 0, %223
%225 = call i8* @strerror(i32 %224)
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.23, i64 0, i64 0), i32 %222, i8* %225)
%227 = load i32, i32* %7
store i32 %227, i32* %3
br label %272
228: ; preds = %217
%229 = load i32, i32* %7
%230 = icmp eq i32 %229, 1
br i1 %230, label %231, label %234
231: ; preds = %228
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0))
%233 = load i32, i32* %7
store i32 %233, i32* %3
br label %272
234: ; preds = %228
%235 = load i32, i32* %7
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.25, i64 0, i64 0), i32 %235)
%237 = load i32, i32* %7
store i32 %237, i32* %3
br label %272
238: ; preds = %60
%239 = call i32 @piControlUpdateFirmware(i32 0)
store i32 %239, i32* %7
%240 = load i32, i32* %7
%241 = icmp ne i32 %240, 0
br i1 %241, label %242, label %249
242: ; preds = %238
%243 = load i32, i32* %7
%244 = load i32, i32* %7
%245 = sub nsw i32 0, %244
%246 = call i8* @strerror(i32 %245)
%247 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.26, i64 0, i64 0), i32 %243, i8* %246)
%248 = load i32, i32* %7
store i32 %248, i32* %3
br label %272
249: ; preds = %238
br label %270
250: ; preds = %60
%251 = call i32 @piControlStopIO(i32 2)
store i32 %251, i32* %7
%252 = load i32, i32* %7
%253 = icmp slt i32 %252, 0
br i1 %253, label %254, label %257
254: ; preds = %250
%255 = load i32, i32* %7
%256 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.27, i64 0, i64 0), i32 %255)
br label %265
257: ; preds = %250
%258 = load i32, i32* %7
%259 = icmp eq i32 %258, 0
br i1 %259, label %260, label %262
260: ; preds = %257
%261 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.28, i64 0, i64 0))
br label %264
262: ; preds = %257
%263 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.29, i64 0, i64 0))
br label %264
264: ; preds = %262, %260
br label %265
265: ; preds = %264, %254
br label %270
266: ; preds = %60
br label %267
267: ; preds = %60, %266
%268 = load i8*, i8** %19
%269 = call i32 @printHelp(i8* %268)
br label %270
270: ; preds = %267, %265, %249, %216, %201, %189, %170, %158, %125, %75, %74, %73, %62
br label %55
271: ; preds = %55
store i32 0, i32* %3
br label %272
272: ; preds = %271, %242, %234, %231, %221, %210, %198, %185, %167, %151, %134, %119, %93, %81, %51, %46
%273 = load i32, i32* %3
ret i32 %273
}

LLVM IR (-O2):
@.str = [15 x i8] c"piControlReset\00"
@.str.1 = [18 x i8] c"Cannot reset: %s\0A\00"
@.str.2 = [20 x i8] c"dv:1qr:w:s:R:g:xlfS\00"
@optarg = global i8* null
@.str.4 = [9 x i8] c"%d,%d,%c\00"
@.str.5 = [6 x i8] c"%d,%d\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [2 x i8] c",\00"
@.str.11 = [10 x i8] c"%d,%d,%lu\00"
@.str.17 = [8 x i8] c"%d,0x%x\00"
@.str.18 = [6 x i8] c"%d,%u\00"
@.str.23 = [32 x i8] c"WaitForEvent returned: %d (%s)\0A\00"
@.str.25 = [27 x i8] c"WaitForEvent returned: %d\0A\00"
@.str.26 = [43 x i8] c"piControlUpdateFirmware returned: %d (%s)\0A\00"
@.str.27 = [38 x i8] c"error in setting I/O update mode: %d\0A\00"
@str = [44 x i8] c"update of I/Os and process image is stopped\00"
@str.30 = [35 x i8] c"I/Os and process image are updated\00"
@str.31 = [29 x i8] c"WaitForEvent returned: Reset\00"
@str.32 = [37 x i8] c"Wrong arguments for get bit function\00"
@str.33 = [37 x i8] c"Try '-g offset,bit' (without spaces)\00"
@str.34 = [43 x i8] c"Wrong arguments for counter reset function\00"
@str.35 = [40 x i8] c"Try '-R address,value' (without spaces)\00"
@str.36 = [37 x i8] c"Wrong arguments for set bit function\00"
@str.37 = [43 x i8] c"Try '-s offset,bit,value' (without spaces)\00"
@str.38 = [35 x i8] c"Wrong arguments for write function\00"
@str.39 = [49 x i8] c"1.) Try '-w variablename,value' (without spaces)\00"
@str.40 = [50 x i8] c"2.) Try '-w offset,length,value' (without spaces)\00"
@str.41 = [34 x i8] c"Wrong arguments for read function\00"
@str.42 = [26 x i8] c"1.) Try '-r variablename'\00"
@str.43 = [44 x i8] c"2.) Try '-r offset,length' (without spaces)\00"
@str.44 = [17 x i8] c"No variable name\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i64
%10 = alloca [256 x i8]
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %8 to i8*
%16 = bitcast i64* %9 to i8*
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%18 = load i8*, i8** %1
%19 = tail call i8* @strrchr(i8* dereferenceable(1) %18, i8 signext 47)
%20 = icmp eq i8* %19, null
%21 = getelementptr inbounds i8, i8* %19, i64 1
%22 = select i1 %20, i8* %18, i8* %21
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %22, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %2
%26 = tail call i32 (...) @piControlReset()
%27 = icmp eq i32 %26, 0
br i1 %27, label %194, label %28
28: ; preds = %25
%29 = sub nsw i32 0, %26
%30 = tail call i8* @strerror(i32 %29)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %194
32: ; preds = %2
%33 = icmp eq i32 %0, 1
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = tail call i32 @printHelp(i8* %22)
br label %194
36: ; preds = %32, %40
%37 = phi i32 [ %41, %40 ], [ 1, %32 ]
%38 = phi i32 [ %42, %40 ], [ 0, %32 ]
%39 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
switch i32 %39, label %192 [
i32 -1, label %194
i32 100, label %43
i32 118, label %45
i32 49, label %40
i32 113, label %54
i32 114, label %55
i32 119, label %92
i32 115, label %116
i32 82, label %128
i32 103, label %143
i32 120, label %154
i32 108, label %161
i32 102, label %174
i32 83, label %181
]
40: ; preds = %36, %184, %190, %188, %174, %154, %49, %52, %192, %150, %139, %123, %112, %88, %54, %43
%41 = phi i32 [ %37, %192 ], [ %37, %184 ], [ %37, %188 ], [ %37, %190 ], [ %37, %174 ], [ %37, %154 ], [ %37, %150 ], [ %37, %139 ], [ %37, %123 ], [ %37, %112 ], [ %37, %88 ], [ %37, %54 ], [ %37, %49 ], [ %37, %52 ], [ %37, %43 ], [ 0, %36 ]
%42 = phi i32 [ %38, %192 ], [ %38, %184 ], [ %38, %188 ], [ %38, %190 ], [ %38, %174 ], [ %38, %154 ], [ %38, %150 ], [ %38, %139 ], [ %38, %123 ], [ %38, %112 ], [ %38, %88 ], [ 1, %54 ], [ %38, %49 ], [ %38, %52 ], [ %38, %43 ], [ %38, %36 ]
br label %36
43: ; preds = %36
%44 = call i32 (...) @showDeviceList()
br label %40
45: ; preds = %36
%46 = load i8*, i8** @optarg
%47 = call i32 @strlen(i8* %46)
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i8*, i8** @optarg
%51 = call i32 @showVariableInfo(i8* %50)
br label %40
52: ; preds = %45
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.44, i64 0, i64 0))
br label %40
54: ; preds = %36
br label %40
55: ; preds = %36
store i8 100, i8* %7
%56 = load i8*, i8** @optarg
%57 = call i32 (i8*, i8*, ...) @sscanf(i8* %56, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4, i8* %7)
%58 = icmp eq i32 %57, 3
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = load i32, i32* %3
%61 = load i32, i32* %4
%62 = load i8, i8* %7
%63 = call i32 @readData(i32 %60, i32 %61, i32 %37, i8 signext %62, i32 %38)
br label %194
64: ; preds = %55
%65 = load i8*, i8** @optarg
%66 = call i32 (i8*, i8*, ...) @sscanf(i8* %65, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %3, i32* %4)
%67 = icmp eq i32 %66, 2
br i1 %67, label %68, label %73
68: ; preds = %64
%69 = load i32, i32* %3
%70 = load i32, i32* %4
%71 = load i8, i8* %7
%72 = call i32 @readData(i32 %69, i32 %70, i32 %37, i8 signext %71, i32 %38)
br label %194
73: ; preds = %64
%74 = load i8*, i8** @optarg
%75 = call i32 (i8*, i8*, ...) @sscanf(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %17)
%76 = icmp eq i32 %75, 1
br i1 %76, label %77, label %88
77: ; preds = %73
%78 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp eq i8* %78, null
br i1 %79, label %85, label %80
80: ; preds = %77
%81 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%82 = icmp eq i8* %81, null
br i1 %82, label %85, label %83
83: ; preds = %80
%84 = load i8, i8* %81
store i8 %84, i8* %7
br label %85
85: ; preds = %80, %83, %77
%86 = load i8, i8* %7
%87 = call i32 @readVariableValue(i8* %17, i32 %37, i8 signext %86, i32 %38)
br label %194
88: ; preds = %73
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.41, i64 0, i64 0))
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.42, i64 0, i64 0))
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.43, i64 0, i64 0))
br label %40
92: ; preds = %36
%93 = load i8*, i8** @optarg
%94 = call i32 (i8*, i8*, ...) @sscanf(i8* %93, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32* %3, i32* %4, i64* %9)
%95 = icmp eq i32 %94, 3
br i1 %95, label %96, label %101
96: ; preds = %92
%97 = load i32, i32* %3
%98 = load i32, i32* %4
%99 = load i64, i64* %9
%100 = call i32 @writeData(i32 %97, i32 %98, i64 %99)
br label %194
101: ; preds = %92
%102 = load i8*, i8** @optarg
%103 = call i8* @strtok(i8* %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%104 = icmp eq i8* %103, null
br i1 %104, label %112, label %105
105: ; preds = %101
%106 = call i32 @strncpy(i8* %17, i8* %103, i32 256)
%107 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%108 = icmp eq i8* %107, null
br i1 %108, label %112, label %109
109: ; preds = %105
%110 = call i64 @strtol(i8* nocapture %107, i32* null, i32 10)
store i64 %110, i64* %9
%111 = call i32 @writeVariableValue(i8* %17, i64 %110)
br label %194
112: ; preds = %105, %101
%113 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.38, i64 0, i64 0))
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.39, i64 0, i64 0))
%115 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.40, i64 0, i64 0))
br label %40
116: ; preds = %36
%117 = load i8*, i8** @optarg
%118 = call i32 (i8*, i8*, ...) @sscanf(i8* %117, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32* %3, i32* %8, i64* %9)
%119 = icmp eq i32 %118, 3
br i1 %119, label %123, label %120
120: ; preds = %116
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.36, i64 0, i64 0))
%122 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.37, i64 0, i64 0))
br label %194
123: ; preds = %116
%124 = load i32, i32* %3
%125 = load i32, i32* %8
%126 = load i64, i64* %9
%127 = call i32 @setBit(i32 %124, i32 %125, i64 %126)
br label %40
128: ; preds = %36
%129 = load i8*, i8** @optarg
%130 = call i32 (i8*, i8*, ...) @sscanf(i8* %129, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i32* %5, i32* %6)
%131 = icmp eq i32 %130, 2
br i1 %131, label %139, label %132
132: ; preds = %128
%133 = load i8*, i8** @optarg
%134 = call i32 (i8*, i8*, ...) @sscanf(i8* %133, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i32* %5, i32* %6)
%135 = icmp eq i32 %134, 2
br i1 %135, label %139, label %136
136: ; preds = %132
%137 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.34, i64 0, i64 0))
%138 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.35, i64 0, i64 0))
br label %194
139: ; preds = %132, %128
%140 = load i32, i32* %5
%141 = load i32, i32* %6
%142 = call i32 @piControlResetCounter(i32 %140, i32 %141)
br label %40
143: ; preds = %36
%144 = load i8*, i8** @optarg
%145 = call i32 (i8*, i8*, ...) @sscanf(i8* %144, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %3, i32* %8)
%146 = icmp eq i32 %145, 2
br i1 %146, label %150, label %147
147: ; preds = %143
%148 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.32, i64 0, i64 0))
%149 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.33, i64 0, i64 0))
br label %194
150: ; preds = %143
%151 = load i32, i32* %3
%152 = load i32, i32* %8
%153 = call i32 @getBit(i32 %151, i32 %152, i32 %38)
br label %40
154: ; preds = %36
%155 = call i32 (...) @piControlReset()
%156 = icmp eq i32 %155, 0
br i1 %156, label %40, label %157
157: ; preds = %154
%158 = sub nsw i32 0, %155
%159 = call i8* @strerror(i32 %158)
%160 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %159)
br label %194
161: ; preds = %36
%162 = call i32 (...) @piControlWaitForEvent()
%163 = icmp slt i32 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %161
%165 = sub nsw i32 0, %162
%166 = call i8* @strerror(i32 %165)
%167 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.23, i64 0, i64 0), i32 %162, i8* %166)
br label %194
168: ; preds = %161
%169 = icmp eq i32 %162, 1
br i1 %169, label %170, label %172
170: ; preds = %168
%171 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.31, i64 0, i64 0))
br label %194
172: ; preds = %168
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.25, i64 0, i64 0), i32 %162)
br label %194
174: ; preds = %36
%175 = call i32 @piControlUpdateFirmware(i32 0)
%176 = icmp eq i32 %175, 0
br i1 %176, label %40, label %177
177: ; preds = %174
%178 = sub nsw i32 0, %175
%179 = call i8* @strerror(i32 %178)
%180 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.26, i64 0, i64 0), i32 %175, i8* %179)
br label %194
181: ; preds = %36
%182 = call i32 @piControlStopIO(i32 2)
%183 = icmp slt i32 %182, 0
br i1 %183, label %184, label %186
184: ; preds = %181
%185 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.27, i64 0, i64 0), i32 %182)
br label %40
186: ; preds = %181
%187 = icmp eq i32 %182, 0
br i1 %187, label %188, label %190
188: ; preds = %186
%189 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.30, i64 0, i64 0))
br label %40
190: ; preds = %186
%191 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %40
192: ; preds = %36
%193 = call i32 @printHelp(i8* %22)
br label %40
194: ; preds = %36, %25, %28, %177, %172, %170, %164, %157, %147, %136, %120, %109, %96, %85, %68, %59, %34
%195 = phi i32 [ 0, %34 ], [ %175, %177 ], [ %162, %164 ], [ 1, %170 ], [ %162, %172 ], [ %155, %157 ], [ 0, %147 ], [ 0, %136 ], [ 0, %120 ], [ 0, %96 ], [ 0, %109 ], [ 0, %59 ], [ 0, %68 ], [ 0, %85 ], [ %26, %28 ], [ 0, %25 ], [ 0, %36 ]
ret i32 %195
}