#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*/ _IOLBF;
char *calloc(int /*<<< orphan*/, int);
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rfc1738_unescape(char *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(int /*<<< orphan*/);
char *strtok(char *, char *);
int /*<<< orphan*/ usage(char *);
scalar_t__ validate_user_gr(char *, char *);
scalar_t__ validate_user_pw(char *, char *);
int /*<<< orphan*/ xisprint(int);
int main(int argc, char *argv[]) {
  char *user, *suser, *p;
  char buf[8192];
  char *grents[10];
  int check_pw = 0, ch, i = 0, j = 0, strip_dm = 0;
  setvbuf(stdout, NULL, _IOLBF, 0);
  while ((ch = getopt(argc, argv, "spg:")) != -1) {
    switch (ch) {
    case 's':
      strip_dm = 1;
      break;
    case 'p':
      check_pw = 1;
      break;
    case 'g':
      grents[i] = calloc(strlen(optarg) + 1, sizeof(char));
      strcpy(grents[i], optarg);
      if (i < 10) {
        i++;
      } else {
        fprintf(stderr, "Exceeded maximum number of allowed groups (%i)\n", i);
        exit(1);
      }
      break;
    case '?':
      if (xisprint(optopt)) {
        fprintf(stderr, "Unknown option '-%c'.\n", optopt);
      } else {
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      }
    default:
      usage(argv[0]);
      exit(1);
    }
  }
  if (optind < argc) {
    fprintf(stderr, "Unknown option '%s'\n", argv[optind]);
    usage(argv[0]);
    exit(1);
  }
  while (fgets(buf, sizeof(buf), stdin)) {
    j = 0;
    if ((p = strchr(buf, '\n')) == NULL) {
      fprintf(stderr, "%s: ERROR: Too large: %s\n", argv[0], buf);
      while (fgets(buf, sizeof(buf), stdin)) {
        fprintf(stderr, "%s: ERROR: Too large..: %s\n", argv[0], buf);
        if (strchr(buf, '\n') != NULL)
          break;
      }
      goto error;
    }
    *p = '\0';
    if ((p = strtok(buf, " ")) == NULL) {
      goto error;
    } else {
      user = p;
      rfc1738_unescape(user);
      if (user && strip_dm) {
        suser = strchr(user, '\\');
        if (!suser)
          suser = strchr(user, '/');
        if (suser && suser[1])
          user = suser + 1;
      }
      while ((p = strtok(NULL, " ")) != NULL) {
        rfc1738_unescape(p);
        if (check_pw == 1)
          j += validate_user_pw(user, p);
        j += validate_user_gr(user, p);
      }
    }
    for (i = 0; grents[i] != NULL; i++) {
      if (check_pw == 1) {
        j += validate_user_pw(user, grents[i]);
      }
      j += validate_user_gr(user, grents[i]);
    }
    if (j > 0) {
      printf("OK\n");
    } else {
    error:
      printf("ERR\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2084(%rbp)
movl   $0x0,-0x208c(%rbp)
movl   $0x0,-0x2090(%rbp)
movl   $0x0,-0x2094(%rbp)
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10e0 <setvbuf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd94(%rip),%rdx
call   1100 <getopt@plt>
mov    %eax,-0x2088(%rbp)
cmp    $0xffffffff,%eax
je     1409 <main+0x209>
mov    -0x2088(%rbp),%eax
mov    %eax,-0x2098(%rbp)
sub    $0x3f,%eax
je     138d <main+0x18d>
jmp    129a <main+0x9a>
mov    -0x2098(%rbp),%eax
sub    $0x67,%eax
je     12f4 <main+0xf4>
jmp    12ae <main+0xae>
mov    -0x2098(%rbp),%eax
sub    $0x70,%eax
je     12e5 <main+0xe5>
jmp    12c2 <main+0xc2>
mov    -0x2098(%rbp),%eax
sub    $0x73,%eax
jne    13ee <main+0x1ee>
jmp    12d6 <main+0xd6>
movl   $0x1,-0x2094(%rbp)
jmp    1404 <main+0x204>
movl   $0x1,-0x2084(%rbp)
jmp    1404 <main+0x204>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
call   1070 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,%rcx
movslq -0x208c(%rbp),%rax
mov    %rcx,-0x2080(%rbp,%rax,8)
ff
movslq -0x208c(%rbp),%rax
mov    -0x2080(%rbp,%rax,8),%rdi
ff
mov    0x2cbf(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
cmpl   $0xa,-0x208c(%rbp)
jge    1361 <main+0x161>
mov    -0x208c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208c(%rbp)
jmp    1388 <main+0x188>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
mov    -0x208c(%rbp),%edx
lea    0xc8e(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1404 <main+0x204>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
call   1040 <xisprint@plt>
cmp    $0x0,%eax
je     13c9 <main+0x1c9>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
mov    0x2c24(%rip),%rax
mov    (%rax),%edx
lea    0xc78(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    13e9 <main+0x1e9>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
mov    0x2bff(%rip),%rax
mov    (%rax),%edx
lea    0xc6a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    13ee <main+0x1ee>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    125e <main+0x5e>
mov    0x2bc0(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    145a <main+0x25a>
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2ba1(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc31(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    145f <main+0x25f>
lea    -0x2030(%rbp),%rdi
mov    0x2b73(%rip),%rax
mov    (%rax),%edx
mov    $0x2000,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1744 <main+0x544>
movl   $0x0,-0x2090(%rbp)
lea    -0x2030(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1544 <main+0x344>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x2030(%rbp),%rcx
lea    0xbb9(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
lea    -0x2030(%rbp),%rdi
mov    0x2b01(%rip),%rax
mov    (%rax),%edx
mov    $0x2000,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     153f <main+0x33f>
mov    0x2ac4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x2030(%rbp),%rcx
lea    0xb8a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
lea    -0x2030(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
cmp    $0x0,%rax
je     153a <main+0x33a>
jmp    153f <main+0x33f>
jmp    14d1 <main+0x2d1>
jmp    1733 <main+0x533>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2030(%rbp),%rdi
lea    0xb60(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1571 <main+0x371>
jmp    1733 <main+0x533>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <rfc1738_unescape@plt>
cmpq   $0x0,-0x18(%rbp)
je     15f6 <main+0x3f6>
cmpl   $0x0,-0x2094(%rbp)
je     15f6 <main+0x3f6>
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1080 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    15c9 <main+0x3c9>
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     15f1 <main+0x3f1>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     15f1 <main+0x3f1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    15f6 <main+0x3f6>
jmp    15fb <main+0x3fb>
xor    %eax,%eax
mov    %eax,%edi
lea    0xab3(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1674 <main+0x474>
mov    -0x28(%rbp),%rdi
call   1050 <rfc1738_unescape@plt>
cmpl   $0x1,-0x2084(%rbp)
jne    164f <main+0x44f>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <validate_user_pw@plt>
mov    %rax,%rcx
movslq -0x2090(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2090(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1120 <validate_user_gr@plt>
mov    %rax,%rcx
movslq -0x2090(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2090(%rbp)
jmp    15fb <main+0x3fb>
jmp    1679 <main+0x479>
movl   $0x0,-0x208c(%rbp)
movslq -0x208c(%rbp),%rax
cmpq   $0x0,-0x2080(%rbp,%rax,8)
je     1710 <main+0x510>
cmpl   $0x1,-0x2084(%rbp)
jne    16d1 <main+0x4d1>
mov    -0x18(%rbp),%rdi
movslq -0x208c(%rbp),%rax
mov    -0x2080(%rbp,%rax,8),%rsi
ff
call   1060 <validate_user_pw@plt>
mov    %rax,%rcx
movslq -0x2090(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2090(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x208c(%rbp),%rax
mov    -0x2080(%rbp,%rax,8),%rsi
ff
call   1120 <validate_user_gr@plt>
mov    %rax,%rcx
movslq -0x2090(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2090(%rbp)
mov    -0x208c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208c(%rbp)
jmp    1683 <main+0x483>
cmpl   $0x0,-0x2090(%rbp)
jle    172e <main+0x52e>
lea    0x997(%rip),%rdi
call   1090 <printf@plt>
jmp    173f <main+0x53f>
jmp    1733 <main+0x533>
lea    0x985(%rip),%rdi
call   1090 <printf@plt>
jmp    145f <main+0x25f>
xor    %eax,%eax
add    $0x20a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2078,%rsp
mov    %rsi,0x8(%rsp)
mov    %edi,%r15d
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    0x2d8f(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
xor    %esi,%esi
xor    %ecx,%ecx
call   10e0 <setvbuf@plt>
lea    0xdc2(%rip),%r12
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    %ebx,%ecx
mov    0x8(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %ecx,%ebx
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1100 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x73,%eax
je     1250 <main+0x50>
cmp    $0x66,%eax
jle    12d8 <main+0xd8>
cmp    $0x70,%eax
je     12d0 <main+0xd0>
cmp    $0x67,%eax
jne    1599 <main+0x399>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   1080 <strlen@plt>
lea    0x1(%rax),%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %r13d,%ebp
movslq %r13d,%r13
mov    %rax,0x20(%rsp,%r13,8)
mov    0x2d4e(%rip),%rcx
mov    (%rcx),%esi
mov    %rax,%rdi
call   1030 <strcpy@plt>
cmp    $0x9,%r13d
jg     15b0 <main+0x3b0>
add    $0x1,%ebp
mov    %ebp,%r13d
jmp    1243 <main+0x43>
nopl   0x0(%rax)
mov    $0x1,%r14b
jmp    1243 <main+0x43>
cmp    $0xffffffff,%eax
jne    1560 <main+0x360>
mov    %ebx,0x14(%rsp)
mov    0x2ce4(%rip),%rax
movslq (%rax),%rax
cmp    %r15d,%eax
jl     15d3 <main+0x3d3>
mov    0x2ce1(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x70(%rsp),%rdi
mov    $0x2000,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
mov    0x8(%rsp),%r15
je     154c <main+0x34c>
mov    0x20(%rsp),%rax
mov    %rax,0x18(%rsp)
lea    0x70(%rsp),%rbx
mov    0x2c8b(%rip),%r12
jmp    1365 <main+0x165>
nopw   0x0(%rax,%rax,1)
lea    0xd74(%rip),%rdi
call   1050 <puts@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x2000,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     154c <main+0x34c>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     13f0 <main+0x1f0>
movb   $0x0,(%rax)
mov    %rbx,%rdi
lea    0xd35(%rip),%rsi
call   10f0 <strtok@plt>
test   %rax,%rax
je     1340 <main+0x140>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <rfc1738_unescape@plt>
cmpl   $0x0,0x14(%rsp)
je     1458 <main+0x258>
mov    %r13,%rdi
mov    $0x5c,%esi
call   1090 <strchr@plt>
test   %rax,%rax
lea    0xcfe(%rip),%rbp
jne    13d3 <main+0x1d3>
mov    %r13,%rdi
mov    $0x2f,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     145f <main+0x25f>
lea    0x1(%rax),%rcx
cmpb   $0x0,0x1(%rax)
cmovne %rcx,%r13
jmp    145f <main+0x25f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    (%r15),%rdx
lea    0xc85(%rip),%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x2000,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     1340 <main+0x140>
mov    (%r12),%edi
mov    (%r15),%rdx
lea    0xc66(%rip),%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     1410 <main+0x210>
jmp    1340 <main+0x140>
lea    0xc5a(%rip),%rbp
xor    %r15d,%r15d
xor    %edi,%edi
mov    %rbp,%rsi
call   10f0 <strtok@plt>
test   %rax,%rax
je     14d0 <main+0x2d0>
mov    %rax,%r12
xor    %ebx,%ebx
jmp    14a6 <main+0x2a6>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12,%rsi
call   1120 <validate_user_gr@plt>
mov    %rax,%r15
add    %ebx,%r15d
xor    %edi,%edi
mov    %rbp,%rsi
call   10f0 <strtok@plt>
mov    %rax,%r12
mov    %r15d,%ebx
test   %rax,%rax
je     14d0 <main+0x2d0>
mov    %r12,%rdi
call   1060 <rfc1738_unescape@plt>
test   $0x1,%r14b
je     1480 <main+0x280>
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <validate_user_pw@plt>
add    %eax,%ebx
jmp    1480 <main+0x280>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x18(%rsp),%rbx
test   %rbx,%rbx
mov    0x2ae1(%rip),%r12
je     1524 <main+0x324>
lea    0x28(%rsp),%rbp
jmp    150e <main+0x30e>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1120 <validate_user_gr@plt>
add    %r15d,%eax
mov    0x0(%rbp),%rbx
add    $0x8,%rbp
mov    %eax,%r15d
test   %rbx,%rbx
je     1527 <main+0x327>
test   $0x1,%r14b
je     14f0 <main+0x2f0>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <validate_user_pw@plt>
add    %eax,%r15d
jmp    14f0 <main+0x2f0>
mov    %r15d,%eax
lea    0xb91(%rip),%rdi
test   %eax,%eax
mov    0x8(%rsp),%r15
mov    0x2aa4(%rip),%rbp
lea    0x70(%rsp),%rbx
jg     1347 <main+0x147>
jmp    1340 <main+0x140>
xor    %eax,%eax
add    $0x2078,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x3f,%eax
jne    1599 <main+0x399>
mov    0x2a6c(%rip),%rbx
mov    (%rbx),%edi
call   1040 <xisprint@plt>
test   %eax,%eax
mov    0x2a44(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%edx
lea    0xac5(%rip),%rax
lea    0xaa7(%rip),%rsi
cmove  %rax,%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
call   10d0 <usage@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2a09(%rip),%rax
mov    (%rax),%edi
lea    0xa45(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x29e6(%rip),%rcx
mov    (%rcx),%edi
mov    0x8(%rsp),%rbx
mov    (%rbx,%rax,8),%rdx
lea    0xa82(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    (%rbx),%rdi
jmp    15a1 <main+0x3a1>

LLVM IR (-O0):
@stdout = global i32 0
@_IOLBF = global i32 0
@.str = [5 x i8] c"spg:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [48 x i8] c"Exceeded maximum number of allowed groups (%i)\0A\00"
@optopt = global i32 0
@.str.2 = [23 x i8] c"Unknown option '-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [21 x i8] c"Unknown option '%s'\0A\00"
@stdin = global i32 0
@.str.5 = [26 x i8] c"%s: ERROR: Too large: %s\0A\00"
@.str.6 = [28 x i8] c"%s: ERROR: Too large..: %s\0A\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [4 x i8] c"OK\0A\00"
@.str.9 = [5 x i8] c"ERR\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [8192 x i8]
%10 = alloca [10 x i8*]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
%16 = load i32, i32* @stdout
%17 = load i32, i32* @_IOLBF
%18 = call i32 @setvbuf(i32 %16, i32* null, i32 %17, i32 0)
br label %19
19: ; preds = %72, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %22, i32* %12
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %73
24: ; preds = %19
%25 = load i32, i32* %12
switch i32 %25, label %66 [
i32 115, label %26
i32 112, label %27
i32 103, label %28
i32 63, label %53
]
26: ; preds = %24
store i32 1, i32* %15
br label %72
27: ; preds = %24
store i32 1, i32* %11
br label %72
28: ; preds = %24
%29 = load i32, i32* @optarg
%30 = call i32 @strlen(i32 %29)
%31 = add nsw i32 %30, 1
%32 = call i8* @calloc(i32 %31, i32 1)
%33 = load i32, i32* %13
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %34
store i8* %32, i8** %35
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* @optarg
%41 = call i32 @strcpy(i8* %39, i32 %40)
%42 = load i32, i32* %13
%43 = icmp slt i32 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %28
%45 = load i32, i32* %13
%46 = add nsw i32 %45, 1
store i32 %46, i32* %13
br label %52
47: ; preds = %28
%48 = load i32, i32* @stderr
%49 = load i32, i32* %13
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %44
br label %72
53: ; preds = %24
%54 = load i32, i32* @optopt
%55 = call i32 @xisprint(i32 %54)
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = load i32, i32* @optopt
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %59)
br label %65
61: ; preds = %53
%62 = load i32, i32* @stderr
%63 = load i32, i32* @optopt
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %61, %57
br label %66
66: ; preds = %24, %65
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 0
%69 = load i8*, i8** %68
%70 = call i32 @usage(i8* %69)
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %52, %27, %26
br label %19
73: ; preds = %19
%74 = load i32, i32* @optind
%75 = load i32, i32* %4
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %90
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = load i8**, i8*** %5
%80 = load i32, i32* @optind
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %83)
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 0
%87 = load i8*, i8** %86
%88 = call i32 @usage(i8* %87)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %73
br label %91
91: ; preds = %230, %90
%92 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%93 = load i32, i32* @stdin
%94 = call i64 @fgets(i8* %92, i32 8192, i32 %93)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %231
96: ; preds = %91
store i32 0, i32* %14
%97 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%98 = call i8* @strchr(i8* %97, i8 signext 10)
store i8* %98, i8** %8
%99 = icmp eq i8* %98, null
br i1 %99, label %100, label %125
100: ; preds = %96
%101 = load i32, i32* @stderr
%102 = load i8**, i8*** %5
%103 = getelementptr inbounds i8*, i8** %102, i64 0
%104 = load i8*, i8** %103
%105 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %104, i8* %105)
br label %107
107: ; preds = %123, %100
%108 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%109 = load i32, i32* @stdin
%110 = call i64 @fgets(i8* %108, i32 8192, i32 %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %124
112: ; preds = %107
%113 = load i32, i32* @stderr
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 0
%116 = load i8*, i8** %115
%117 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %116, i8* %117)
%119 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%120 = call i8* @strchr(i8* %119, i8 signext 10)
%121 = icmp ne i8* %120, null
br i1 %121, label %122, label %123
122: ; preds = %112
br label %124
123: ; preds = %112
br label %107
124: ; preds = %122, %107
br label %228
125: ; preds = %96
%126 = load i8*, i8** %8
store i8 0, i8* %126
%127 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%128 = call i8* @strtok(i8* %127, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %128, i8** %8
%129 = icmp eq i8* %128, null
br i1 %129, label %130, label %131
130: ; preds = %125
br label %228
131: ; preds = %125
%132 = load i8*, i8** %8
store i8* %132, i8** %6
%133 = load i8*, i8** %6
%134 = call i32 @rfc1738_unescape(i8* %133)
%135 = load i8*, i8** %6
%136 = icmp ne i8* %135, null
br i1 %136, label %137, label %161
137: ; preds = %131
%138 = load i32, i32* %15
%139 = icmp ne i32 %138, 0
br i1 %139, label %140, label %161
140: ; preds = %137
%141 = load i8*, i8** %6
%142 = call i8* @strchr(i8* %141, i8 signext 92)
store i8* %142, i8** %7
%143 = load i8*, i8** %7
%144 = icmp ne i8* %143, null
br i1 %144, label %148, label %145
145: ; preds = %140
%146 = load i8*, i8** %6
%147 = call i8* @strchr(i8* %146, i8 signext 47)
store i8* %147, i8** %7
br label %148
148: ; preds = %145, %140
%149 = load i8*, i8** %7
%150 = icmp ne i8* %149, null
br i1 %150, label %151, label %160
151: ; preds = %148
%152 = load i8*, i8** %7
%153 = getelementptr inbounds i8, i8* %152, i64 1
%154 = load i8, i8* %153
%155 = sext i8 %154 to i32
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %160
157: ; preds = %151
%158 = load i8*, i8** %7
%159 = getelementptr inbounds i8, i8* %158, i64 1
store i8* %159, i8** %6
br label %160
160: ; preds = %157, %151, %148
br label %161
161: ; preds = %160, %137, %131
br label %162
162: ; preds = %178, %161
%163 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %163, i8** %8
%164 = icmp ne i8* %163, null
br i1 %164, label %165, label %186
165: ; preds = %162
%166 = load i8*, i8** %8
%167 = call i32 @rfc1738_unescape(i8* %166)
%168 = load i32, i32* %11
%169 = icmp eq i32 %168, 1
br i1 %169, label %170, label %178
170: ; preds = %165
%171 = load i8*, i8** %6
%172 = load i8*, i8** %8
%173 = call i64 @validate_user_pw(i8* %171, i8* %172)
%174 = load i32, i32* %14
%175 = sext i32 %174 to i64
%176 = add nsw i64 %175, %173
%177 = trunc i64 %176 to i32
store i32 %177, i32* %14
br label %178
178: ; preds = %170, %165
%179 = load i8*, i8** %6
%180 = load i8*, i8** %8
%181 = call i64 @validate_user_gr(i8* %179, i8* %180)
%182 = load i32, i32* %14
%183 = sext i32 %182 to i64
%184 = add nsw i64 %183, %181
%185 = trunc i64 %184 to i32
store i32 %185, i32* %14
br label %162
186: ; preds = %162
br label %187
187: ; preds = %186
store i32 0, i32* %13
br label %188
188: ; preds = %219, %187
%189 = load i32, i32* %13
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %190
%192 = load i8*, i8** %191
%193 = icmp ne i8* %192, null
br i1 %193, label %194, label %222
194: ; preds = %188
%195 = load i32, i32* %11
%196 = icmp eq i32 %195, 1
br i1 %196, label %197, label %208
197: ; preds = %194
%198 = load i8*, i8** %6
%199 = load i32, i32* %13
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %200
%202 = load i8*, i8** %201
%203 = call i64 @validate_user_pw(i8* %198, i8* %202)
%204 = load i32, i32* %14
%205 = sext i32 %204 to i64
%206 = add nsw i64 %205, %203
%207 = trunc i64 %206 to i32
store i32 %207, i32* %14
br label %208
208: ; preds = %197, %194
%209 = load i8*, i8** %6
%210 = load i32, i32* %13
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %211
%213 = load i8*, i8** %212
%214 = call i64 @validate_user_gr(i8* %209, i8* %213)
%215 = load i32, i32* %14
%216 = sext i32 %215 to i64
%217 = add nsw i64 %216, %214
%218 = trunc i64 %217 to i32
store i32 %218, i32* %14
br label %219
219: ; preds = %208
%220 = load i32, i32* %13
%221 = add nsw i32 %220, 1
store i32 %221, i32* %13
br label %188
222: ; preds = %188
%223 = load i32, i32* %14
%224 = icmp sgt i32 %223, 0
br i1 %224, label %225, label %227
225: ; preds = %222
%226 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %230
227: ; preds = %222
br label %228
228: ; preds = %227, %130, %124
%229 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %230
230: ; preds = %228, %225
br label %91
231: ; preds = %91
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IOLBF = global i32 0
@.str = [5 x i8] c"spg:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [48 x i8] c"Exceeded maximum number of allowed groups (%i)\0A\00"
@optopt = global i32 0
@.str.2 = [23 x i8] c"Unknown option '-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [21 x i8] c"Unknown option '%s'\0A\00"
@stdin = global i32 0
@.str.5 = [26 x i8] c"%s: ERROR: Too large: %s\0A\00"
@.str.6 = [28 x i8] c"%s: ERROR: Too large..: %s\0A\00"
@.str.7 = [2 x i8] c" \00"
@str = [4 x i8] c"ERR\00"
@str.10 = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [8192 x i8]
%4 = alloca [10 x i8*]
%5 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%6 = bitcast [10 x i8*]* %4 to i8*
%7 = load i32, i32* @stdout
%8 = load i32, i32* @_IOLBF
%9 = tail call i32 @setvbuf(i32 %7, i32* null, i32 %8, i32 0)
br label %10
10: ; preds = %17, %2
%11 = phi i1 [ false, %2 ], [ true, %17 ]
%12 = phi i32 [ 0, %2 ], [ %15, %17 ]
%13 = phi i32 [ 0, %2 ], [ %18, %17 ]
br label %14
14: ; preds = %10, %30
%15 = phi i32 [ %12, %10 ], [ %31, %30 ]
%16 = phi i32 [ %13, %10 ], [ %18, %30 ]
br label %17
17: ; preds = %14, %17
%18 = phi i32 [ 1, %17 ], [ %16, %14 ]
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %19, label %44 [
i32 -1, label %48
i32 115, label %17
i32 112, label %10
i32 103, label %20
i32 63, label %36
]
20: ; preds = %17
%21 = load i32, i32* @optarg
%22 = tail call i32 @strlen(i32 %21)
%23 = add nsw i32 %22, 1
%24 = tail call i8* @calloc(i32 %23, i32 1)
%25 = sext i32 %15 to i64
%26 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %25
store i8* %24, i8** %26
%27 = load i32, i32* @optarg
%28 = tail call i32 @strcpy(i8* %24, i32 %27)
%29 = icmp slt i32 %15, 10
br i1 %29, label %30, label %32
30: ; preds = %20
%31 = add nsw i32 %15, 1
br label %14
32: ; preds = %20
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %17
%37 = load i32, i32* @optopt
%38 = tail call i32 @xisprint(i32 %37)
%39 = icmp eq i32 %38, 0
%40 = load i32, i32* @stderr
%41 = load i32, i32* @optopt
%42 = select i1 %39, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0)
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* %42, i32 %41)
br label %44
44: ; preds = %17, %36
%45 = load i8*, i8** %1
%46 = tail call i32 @usage(i8* %45)
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %17
%49 = load i32, i32* @optind
%50 = icmp slt i32 %49, %0
br i1 %50, label %60, label %51
51: ; preds = %48
%52 = load i32, i32* @stdin
%53 = call i64 @fgets(i8* %5, i32 8192, i32 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %151, label %55
55: ; preds = %51
%56 = icmp eq i32 %18, 0
%57 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
%58 = load i8*, i8** %57
%59 = icmp eq i8* %58, null
br label %69
60: ; preds = %48
%61 = load i32, i32* @stderr
%62 = sext i32 %49 to i64
%63 = getelementptr inbounds i8*, i8** %1, i64 %62
%64 = load i8*, i8** %63
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = load i8*, i8** %1
%67 = tail call i32 @usage(i8* %66)
%68 = tail call i32 @exit(i32 1)
unreachable
69: ; preds = %55, %145
%70 = call i8* @strchr(i8* %5, i8 signext 10)
%71 = icmp eq i8* %70, null
br i1 %71, label %72, label %86
72: ; preds = %69
%73 = load i32, i32* @stderr
%74 = load i8*, i8** %1
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %74, i8* %5)
br label %76
76: ; preds = %80, %72
%77 = load i32, i32* @stdin
%78 = call i64 @fgets(i8* %5, i32 8192, i32 %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %144, label %80
80: ; preds = %76
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %1
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %82, i8* %5)
%84 = call i8* @strchr(i8* %5, i8 signext 10)
%85 = icmp eq i8* %84, null
br i1 %85, label %76, label %144
86: ; preds = %69
store i8 0, i8* %70
%87 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%88 = icmp eq i8* %87, null
br i1 %88, label %144, label %89
89: ; preds = %86
%90 = call i32 @rfc1738_unescape(i8* %87)
br i1 %56, label %103, label %91
91: ; preds = %89
%92 = call i8* @strchr(i8* %87, i8 signext 92)
%93 = icmp eq i8* %92, null
br i1 %93, label %94, label %97
94: ; preds = %91
%95 = call i8* @strchr(i8* %87, i8 signext 47)
%96 = icmp eq i8* %95, null
br i1 %96, label %103, label %97
97: ; preds = %91, %94
%98 = phi i8* [ %95, %94 ], [ %92, %91 ]
%99 = getelementptr inbounds i8, i8* %98, i64 1
%100 = load i8, i8* %99
%101 = icmp eq i8 %100, 0
%102 = select i1 %101, i8* %87, i8* %99
br label %103
103: ; preds = %97, %94, %89
%104 = phi i8* [ %87, %94 ], [ %87, %89 ], [ %102, %97 ]
%105 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%106 = icmp eq i8* %105, null
br i1 %106, label %107, label %109
107: ; preds = %117, %103
%108 = phi i32 [ 0, %103 ], [ %121, %117 ]
br i1 %59, label %141, label %124
109: ; preds = %103, %117
%110 = phi i8* [ %122, %117 ], [ %105, %103 ]
%111 = phi i32 [ %121, %117 ], [ 0, %103 ]
%112 = call i32 @rfc1738_unescape(i8* %110)
br i1 %11, label %113, label %117
113: ; preds = %109
%114 = call i64 @validate_user_pw(i8* %104, i8* %110)
%115 = trunc i64 %114 to i32
%116 = add i32 %111, %115
br label %117
117: ; preds = %113, %109
%118 = phi i32 [ %116, %113 ], [ %111, %109 ]
%119 = call i64 @validate_user_gr(i8* %104, i8* %110)
%120 = trunc i64 %119 to i32
%121 = add i32 %118, %120
%122 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%123 = icmp eq i8* %122, null
br i1 %123, label %107, label %109
124: ; preds = %107, %132
%125 = phi i64 [ %137, %132 ], [ 0, %107 ]
%126 = phi i8* [ %139, %132 ], [ %58, %107 ]
%127 = phi i32 [ %136, %132 ], [ %108, %107 ]
br i1 %11, label %128, label %132
128: ; preds = %124
%129 = call i64 @validate_user_pw(i8* %104, i8* %126)
%130 = trunc i64 %129 to i32
%131 = add i32 %127, %130
br label %132
132: ; preds = %128, %124
%133 = phi i32 [ %131, %128 ], [ %127, %124 ]
%134 = call i64 @validate_user_gr(i8* %104, i8* %126)
%135 = trunc i64 %134 to i32
%136 = add i32 %133, %135
%137 = add nuw i64 %125, 1
%138 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %137
%139 = load i8*, i8** %138
%140 = icmp eq i8* %139, null
br i1 %140, label %141, label %124
141: ; preds = %132, %107
%142 = phi i32 [ %108, %107 ], [ %136, %132 ]
%143 = icmp sgt i32 %142, 0
br i1 %143, label %145, label %144
144: ; preds = %76, %80, %141, %86
br label %145
145: ; preds = %141, %144
%146 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %144 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0), %141 ]
%147 = call i32 @puts(i8* dereferenceable(1) %146)
%148 = load i32, i32* @stdin
%149 = call i64 @fgets(i8* %5, i32 8192, i32 %148)
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %69
151: ; preds = %145, %51
ret i32 0
}