#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 scalar_t__ timeout_minutes;
typedef scalar_t__ time_t;

/* Variables and functions */
char *crypt(char *, char *);
int /*<<< orphan*/ free(char *);
char *get_admin_hash(char *);
char *get_cookie_time(scalar_t__);
char *get_sha256_hash_hex_str(char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
char *safe_strcat(int, char *, char *, char *, char *);
char *safe_strdup(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int sscanf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time(scalar_t__ *);
int main(int argc, char **argv) {
  char *password = NULL;
  char *username = NULL;
  char *cookie_hash = NULL;
  char *cookie_exp = NULL;
  char *user_agent = NULL;
  char *src_ip = NULL;
  char *redirect = NULL;
  int timeout_minutes = 15;
  unsigned long browser_time = 0;
  int loggedout = 0;
  int next_opt;
  int read;
  while ((next_opt = getopt(argc, argv,
                            "p:P:u:U:c:C:e:E:a:A:i:I:r:R:t:T:b:B:lL")) != -1) {
    switch (next_opt) {
    case 'p':
    case 'P':
      password = safe_strdup(optarg);
      break;
    case 'u':
    case 'U':
      username = safe_strdup(optarg);
      break;
    case 'c':
    case 'C':
      cookie_hash = safe_strdup(optarg);
      break;
    case 'e':
    case 'E':
      cookie_exp = safe_strdup(optarg);
      break;
    case 'a':
    case 'A':
      user_agent = safe_strdup(optarg);
      break;
    case 'i':
    case 'I':
      src_ip = safe_strdup(optarg);
      break;
    case 'r':
    case 'R':
      redirect = safe_strdup(optarg);
      break;
    case 't':
    case 'T':
      read = sscanf(optarg, "%d", &timeout_minutes);
      if (read > 0) {
        timeout_minutes = timeout_minutes > 0 ? timeout_minutes : 15;
      } else {
        timeout_minutes = 15;
      }
      timeout_minutes *= 60;
      break;
    case 'b':
    case 'B':
      read = sscanf(optarg, "%ld", &browser_time);
      browser_time = read > 0 ? browser_time : 0;
      break;
    case 'l':
    case 'L':
      loggedout = 1;
      break;
    }
  }
  int expired = 0;
  int valid = 0;
  char *admin_hash = get_admin_hash(username);
  if (loggedout == 1) {
    printf("echo \"Set-Cookie:kagera_sid=loggedout;\"; echo "
           "\"Set-Cookie:kagera_usr=loggedout;\"; ");
  } else if (admin_hash != NULL) {
    time_t now;
    time(&now);
    if (password != NULL) {
      valid = strcmp(crypt(password, admin_hash), admin_hash) == 0 ? 1 : 0;
      if (valid) {
        printf("logger -t webui \"Kagera Administration Interface "
               "authorization succeeded from ${REMOTE_ADDR}\"; ");
      }
    } else if (cookie_hash != NULL && cookie_exp != NULL &&
               user_agent != NULL && src_ip != NULL) {
      time_t exp_time;
      int read = sscanf(cookie_exp, "%ld", &exp_time);
      if (read > 0) {
        expired = 1;
        if (exp_time > now && (exp_time - (timeout_minutes)-2) <= now) {
          expired = 0;
        }
      }
      char *combined =
          safe_strcat(4, admin_hash, cookie_exp, user_agent, src_ip);
      char *hashed = get_sha256_hash_hex_str(combined);
      if (strcmp(hashed, cookie_hash) == 0) {
        if (expired == 0 && read > 0) {
          valid = 1;
        }
      } else {
        expired = 0;
      }
      free(hashed);
      free(combined);
    }
    if (valid == 1 && src_ip != NULL && user_agent != NULL) {
      char *new_hash;
      char *combined;
      char new_exp[100] = "";
      time_t new_exp_t = now + (timeout_minutes);
      sprintf(new_exp, "%ld", new_exp_t);
      char *cookie_exp;
      if (browser_time > 0 && ((browser_time - now) < (-5 * 60) ||
                               (browser_time - now) > (5 * 60))) {
        time_t cookie_exp_t = browser_time + (timeout_minutes);
        cookie_exp = get_cookie_time(cookie_exp_t);
      } else {
        cookie_exp = get_cookie_time(new_exp_t);
      }
      combined = safe_strcat(4, admin_hash, new_exp, user_agent, src_ip);
      new_hash = get_sha256_hash_hex_str(combined);
      if (browser_time == 0) {
        printf("echo \"Set-Cookie:kagera_sid=%s; Path=/;\"; echo "
               "\"Set-Cookie:kagera_usr=%s; Path=/;\"; echo "
               "\"Set-Cookie:kagera_exp=%s; Path=/;\"; ",
               new_hash, username, new_exp);
      } else {
        printf("echo \"Set-Cookie:kagera_sid=%s; Expires=%s; Path=/;\"; echo "
               "\"Set-Cookie:kagera_usr=%s; Expires=%s; Path=/;\"; echo "
               "\"Set-Cookie:kagera_exp=%s; Expires=%s; Path=/;\"; ",
               new_hash, cookie_exp, username, cookie_exp, new_exp, cookie_exp);
      }
      free(new_hash);
      free(combined);
      free(cookie_exp);
      printf("VALIDSESS=1\n");
    }
    free(admin_hash);
  }
  if (redirect != NULL) {
    char str[20] = "";
    if (expired == 1) {
      sprintf(str, "&expired=1");
    } else if (loggedout == 1) {
      sprintf(str, "&loggedout=1");
    }
    printf("echo \"HTTP/1.1 301 Moved Permanently;\"; echo \"Location: %s%s\"; "
           "exit",
           redirect, str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0xf,-0x4c(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdx
call   10f0 <getopt@plt>
mov    %eax,-0x60(%rbp)
cmp    $0xffffffff,%eax
je     1412 <main+0x232>
mov    -0x60(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x158(%rbp)
sub    $0x34,%eax
ja     140d <main+0x22d>
mov    -0x158(%rbp),%rax
lea    0xd74(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d5c(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    140d <main+0x22d>
mov    0x2d44(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    140d <main+0x22d>
mov    0x2d2c(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    140d <main+0x22d>
mov    0x2d14(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x30(%rbp)
jmp    140d <main+0x22d>
mov    0x2cfc(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x38(%rbp)
jmp    140d <main+0x22d>
mov    0x2ce4(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x40(%rbp)
jmp    140d <main+0x22d>
mov    0x2ccc(%rip),%rax
mov    (%rax),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,-0x48(%rbp)
jmp    140d <main+0x22d>
mov    0x2cb4(%rip),%rax
mov    (%rax),%rdi
lea    0xdad(%rip),%rsi
lea    -0x4c(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    139c <main+0x1bc>
cmpl   $0x0,-0x4c(%rbp)
jle    137e <main+0x19e>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x15c(%rbp)
jmp    138e <main+0x1ae>
mov    $0xf,%eax
mov    %eax,-0x15c(%rbp)
jmp    138e <main+0x1ae>
mov    -0x15c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    13a3 <main+0x1c3>
movl   $0xf,-0x4c(%rbp)
imul   $0x3c,-0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    140d <main+0x22d>
mov    0x2c42(%rip),%rax
mov    (%rax),%rdi
lea    0xd3e(%rip),%rsi
lea    -0x58(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    13e8 <main+0x208>
mov    -0x58(%rbp),%rax
mov    %rax,-0x168(%rbp)
jmp    13f6 <main+0x216>
xor    %eax,%eax
mov    %rax,-0x168(%rbp)
jmp    13f6 <main+0x216>
mov    -0x168(%rbp),%rax
mov    %rax,-0x58(%rbp)
jmp    140d <main+0x22d>
movl   $0x1,-0x5c(%rbp)
jmp    1247 <main+0x67>
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <get_admin_hash@plt>
mov    %rax,-0x78(%rbp)
cmpl   $0x1,-0x5c(%rbp)
jne    144a <main+0x26a>
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1791 <main+0x5b1>
cmpq   $0x0,-0x78(%rbp)
je     178c <main+0x5ac>
lea    -0x80(%rbp),%rdi
call   10b0 <time@plt>
cmpq   $0x0,-0x18(%rbp)
je     14b3 <main+0x2d3>
mov    -0x18(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1070 <crypt@plt>
mov    %rax,%rdi
mov    -0x78(%rbp),%rsi
call   10a0 <strcmp@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     14ae <main+0x2ce>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    15e0 <main+0x400>
cmpq   $0x0,-0x28(%rbp)
je     15db <main+0x3fb>
cmpq   $0x0,-0x30(%rbp)
je     15db <main+0x3fb>
cmpq   $0x0,-0x38(%rbp)
je     15db <main+0x3fb>
cmpq   $0x0,-0x40(%rbp)
je     15db <main+0x3fb>
mov    -0x30(%rbp),%rdi
lea    0xc14(%rip),%rsi
lea    -0x88(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x0,-0x8c(%rbp)
jle    154b <main+0x36b>
movl   $0x1,-0x68(%rbp)
mov    -0x88(%rbp),%rax
cmp    -0x80(%rbp),%rax
jle    1546 <main+0x366>
mov    -0x88(%rbp),%rax
movslq -0x4c(%rbp),%rcx
sub    %rcx,%rax
sub    $0x2,%rax
cmp    -0x80(%rbp),%rax
jg     1546 <main+0x366>
movl   $0x0,-0x68(%rbp)
jmp    154b <main+0x36b>
mov    -0x78(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    $0x4,%edi
call   1050 <safe_strcat@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1060 <get_sha256_hash_hex_str@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    15bc <main+0x3dc>
cmpl   $0x0,-0x68(%rbp)
jne    15b7 <main+0x3d7>
cmpl   $0x0,-0x8c(%rbp)
jle    15b7 <main+0x3d7>
movl   $0x1,-0x6c(%rbp)
jmp    15c3 <main+0x3e3>
movl   $0x0,-0x68(%rbp)
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
jmp    15e0 <main+0x400>
cmpl   $0x1,-0x6c(%rbp)
jne    1783 <main+0x5a3>
cmpq   $0x0,-0x40(%rbp)
je     1783 <main+0x5a3>
cmpq   $0x0,-0x38(%rbp)
je     1783 <main+0x5a3>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1090 <memset@plt>
mov    -0x80(%rbp),%rax
movslq -0x4c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rdx
lea    0xac4(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
cmpq   $0x0,-0x58(%rbp)
jbe    169e <main+0x4be>
mov    -0x58(%rbp),%rax
sub    -0x80(%rbp),%rax
cmp    $0xfffffffffffffed4,%rax
jb     1674 <main+0x494>
mov    -0x58(%rbp),%rax
sub    -0x80(%rbp),%rax
cmp    $0x12c,%rax
jbe    169e <main+0x4be>
mov    -0x58(%rbp),%rax
movslq -0x4c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rdi
call   10e0 <get_cookie_time@plt>
mov    %rax,-0x130(%rbp)
jmp    16b1 <main+0x4d1>
mov    -0x128(%rbp),%rdi
call   10e0 <get_cookie_time@plt>
mov    %rax,-0x130(%rbp)
mov    -0x78(%rbp),%rsi
lea    -0x120(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    $0x4,%edi
call   1050 <safe_strcat@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rdi
call   1060 <get_sha256_hash_hex_str@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1718 <main+0x538>
mov    -0xa8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xaa9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1751 <main+0x571>
mov    -0xa8(%rbp),%rsi
mov    -0x130(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x130(%rbp),%r8
lea    -0x120(%rbp),%r9
mov    -0x130(%rbp),%rax
lea    0xaee(%rip),%rdi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xb0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x130(%rbp),%rdi
call   1030 <free@plt>
lea    0xb5b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
jmp    1791 <main+0x5b1>
cmpq   $0x0,-0x48(%rbp)
je     1810 <main+0x630>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1090 <memset@plt>
cmpl   $0x1,-0x68(%rbp)
jne    17d3 <main+0x5f3>
lea    -0x150(%rbp),%rdi
lea    0xb1d(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
jmp    17f7 <main+0x617>
cmpl   $0x1,-0x5c(%rbp)
jne    17f2 <main+0x612>
lea    -0x150(%rbp),%rdi
lea    0xb04(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
jmp    17f7 <main+0x617>
mov    -0x48(%rbp),%rsi
lea    -0x150(%rbp),%rdx
lea    0xaf3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
movl   $0xf,0x14(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xfcd(%rip),%r13
lea    0xdea(%rip),%rbx
mov    0x2ddb(%rip),%rbp
movl   $0x0,0x1c(%rsp)
xor    %eax,%eax
mov    %rax,0x40(%rsp)
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
mov    %rax,0x38(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x50(%rsp)
xor    %eax,%eax
mov    %rax,0x48(%rsp)
xor    %r12d,%r12d
jmp    1260 <main+0x80>
movl   $0x1,0x1c(%rsp)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r13,%rdx
call   10f0 <getopt@plt>
add    $0x1,%eax
cmp    $0x76,%eax
ja     1260 <main+0x80>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,0x38(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
lea    0xf6c(%rip),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
test   %eax,%eax
jle    135a <main+0x17a>
mov    0x30(%rsp),%rax
mov    %rax,0x30(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,0x50(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,0x20(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,0x28(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,%r12
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,0x40(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
lea    0xee7(%rip),%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
mov    0x14(%rsp),%ecx
imul   $0x3c,%ecx,%edx
test   %ecx,%ecx
mov    $0x384,%ecx
cmovle %ecx,%edx
test   %eax,%eax
cmovle %ecx,%edx
mov    %edx,0x14(%rsp)
jmp    1260 <main+0x80>
mov    0x0(%rbp),%rdi
call   10d0 <safe_strdup@plt>
mov    %rax,0x48(%rsp)
jmp    1260 <main+0x80>
xor    %eax,%eax
mov    %rax,0x30(%rsp)
jmp    1260 <main+0x80>
mov    0x48(%rsp),%rdi
call   1040 <get_admin_hash@plt>
mov    0x1c(%rsp),%r14d
cmp    $0x1,%r14d
jne    1391 <main+0x1b1>
lea    0xe88(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1090 <printf@plt>
jmp    163b <main+0x45b>
mov    %rax,%rbp
test   %rax,%rax
je     13ea <main+0x20a>
lea    0x58(%rsp),%rdi
call   10b0 <time@plt>
test   %r12,%r12
je     13f2 <main+0x212>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1080 <crypt@plt>
mov    %rax,%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    1633 <main+0x453>
lea    0xe8c(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%bl
test   %bl,%bl
jne    1505 <main+0x325>
jmp    1633 <main+0x453>
xor    %r15d,%r15d
jmp    163b <main+0x45b>
xor    %r15d,%r15d
mov    0x50(%rsp),%r13
test   %r13,%r13
je     1633 <main+0x453>
mov    0x20(%rsp),%rbx
test   %rbx,%rbx
je     1633 <main+0x453>
cmpq   $0x0,0x38(%rsp)
je     1633 <main+0x453>
cmpq   $0x0,0x28(%rsp)
je     1633 <main+0x453>
lea    0xdd6(%rip),%rsi
lea    0x60(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   10c0 <sscanf@plt>
test   %eax,%eax
jle    1471 <main+0x291>
mov    0x60(%rsp),%rcx
mov    0x58(%rsp),%rdx
cmp    %rdx,%rcx
jle    147c <main+0x29c>
movslq 0x14(%rsp),%rsi
sub    %rsi,%rcx
add    $0xfffffffffffffffe,%rcx
xor    %r15d,%r15d
cmp    %rdx,%rcx
setle  %cl
mov    %ecx,0x18(%rsp)
setg   %r15b
jmp    148a <main+0x2aa>
mov    $0x1,%cl
mov    %ecx,0x18(%rsp)
xor    %r15d,%r15d
jmp    148a <main+0x2aa>
mov    $0x1,%r15d
movl   $0x0,0x18(%rsp)
test   %eax,%eax
setg   %r12b
mov    $0x4,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    0x38(%rsp),%rcx
mov    0x28(%rsp),%r8
call   1050 <safe_strcat@plt>
mov    %rbp,0x20(%rsp)
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <get_sha256_hash_hex_str@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13,%rsi
call   10a0 <strcmp@plt>
and    0x18(%rsp),%r12b
mov    $0x0,%ecx
cmovne %ecx,%r15d
test   %rax,%rax
sete   %bl
cmovne %ecx,%r15d
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    0x20(%rsp),%rbp
call   1030 <free@plt>
and    %r12b,%bl
mov    0x1c(%rsp),%r14d
test   %bl,%bl
je     1633 <main+0x453>
cmpq   $0x0,0x28(%rsp)
je     1633 <main+0x453>
mov    0x38(%rsp),%r13
test   %r13,%r13
je     1633 <main+0x453>
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movl   $0x0,0xc0(%rsp)
movslq 0x14(%rsp),%rbx
add    0x58(%rsp),%rbx
lea    0xc9e(%rip),%rsi
lea    0x60(%rsp),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1100 <sprintf@plt>
mov    0x30(%rsp),%rax
movslq 0x14(%rsp),%rdi
add    %rax,%rdi
test   %rax,%rax
cmove  %rbx,%rdi
call   10e0 <get_cookie_time@plt>
mov    %rax,%r12
mov    $0x4,%edi
mov    %rbp,0x20(%rsp)
mov    %rbp,%rsi
lea    0x60(%rsp),%rdx
mov    %r13,%rcx
mov    0x28(%rsp),%r8
call   1050 <safe_strcat@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1060 <get_sha256_hash_hex_str@plt>
mov    %rax,%rbx
cmpq   $0x0,0x30(%rsp)
je     15ef <main+0x40f>
mov    %r12,(%rsp)
lea    0xd69(%rip),%rdi
lea    0x60(%rsp),%r9
mov    %rbx,%rsi
mov    %r12,%rdx
mov    0x48(%rsp),%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1090 <printf@plt>
jmp    160a <main+0x42a>
lea    0xcc7(%rip),%rdi
lea    0x60(%rsp),%rcx
mov    %rbx,%rsi
mov    0x48(%rsp),%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
lea    0xe12(%rip),%rdi
call   1070 <puts@plt>
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x40(%rsp),%rsi
test   %rsi,%rsi
je     16aa <main+0x4ca>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movl   $0x0,0x70(%rsp)
test   %r15d,%r15d
je     1673 <main+0x493>
movabs $0x6465726970786526,%rax
72 65 64
mov    %rax,0x60(%rsp)
movl   $0x313d64,0x67(%rsp)
jmp    1697 <main+0x4b7>
cmp    $0x1,%r14d
jne    1697 <main+0x4b7>
movabs $0x313d74756f6465,%rax
mov    %rax,0x65(%rsp)
movabs $0x6f646567676f6c26,%rax
65 64 6f
mov    %rax,0x60(%rsp)
lea    0xd59(%rip),%rdi
lea    0x60(%rsp),%rdx
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"p:P:u:U:c:C:e:E:a:A:i:I:r:R:t:T:b:B:lL\00"
@optarg = global i8* null
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [83 x i8] c"echo \22Set-Cookie:kagera_sid=loggedout;\22; echo \22Set-Cookie:kagera_usr=loggedout;\22; \00"
@.str.4 = [96 x i8] c"logger -t webui \22Kagera Administration Interface authorization succeeded from ${REMOTE_ADDR}\22; \00"
@.str.5 = [127 x i8] c"echo \22Set-Cookie:kagera_sid=%s; Path=/;\22; echo \22Set-Cookie:kagera_usr=%s; Path=/;\22; echo \22Set-Cookie:kagera_exp=%s; Path=/;\22; \00"
@.str.6 = [163 x i8] c"echo \22Set-Cookie:kagera_sid=%s; Expires=%s; Path=/;\22; echo \22Set-Cookie:kagera_usr=%s; Expires=%s; Path=/;\22; echo \22Set-Cookie:kagera_exp=%s; Expires=%s; Path=/;\22; \00"
@.str.7 = [13 x i8] c"VALIDSESS=1\0A\00"
@.str.8 = [11 x i8] c"&expired=1\00"
@.str.9 = [13 x i8] c"&loggedout=1\00"
@.str.10 = [68 x i8] c"echo \22HTTP/1.1 301 Moved Permanently;\22; echo \22Location: %s%s\22; exit\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 i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i64
%23 = alloca i32
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca [100 x i8]
%29 = alloca i64
%30 = alloca i8*
%31 = alloca i64
%32 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32 15, i32* %13
store i64 0, i64* %14
store i32 0, i32* %15
br label %33
33: ; preds = %89, %2
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = call i32 @getopt(i32 %34, i8** %35, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 %36, i32* %16
%37 = icmp ne i32 %36, -1
br i1 %37, label %38, label %90
38: ; preds = %33
%39 = load i32, i32* %16
switch i32 %39, label %89 [
i32 112, label %40
i32 80, label %40
i32 117, label %43
i32 85, label %43
i32 99, label %46
i32 67, label %46
i32 101, label %49
i32 69, label %49
i32 97, label %52
i32 65, label %52
i32 105, label %55
i32 73, label %55
i32 114, label %58
i32 82, label %58
i32 116, label %61
i32 84, label %61
i32 98, label %78
i32 66, label %78
i32 108, label %88
i32 76, label %88
]
40: ; preds = %38, %38
%41 = load i8*, i8** @optarg
%42 = call i8* @safe_strdup(i8* %41)
store i8* %42, i8** %6
br label %89
43: ; preds = %38, %38
%44 = load i8*, i8** @optarg
%45 = call i8* @safe_strdup(i8* %44)
store i8* %45, i8** %7
br label %89
46: ; preds = %38, %38
%47 = load i8*, i8** @optarg
%48 = call i8* @safe_strdup(i8* %47)
store i8* %48, i8** %8
br label %89
49: ; preds = %38, %38
%50 = load i8*, i8** @optarg
%51 = call i8* @safe_strdup(i8* %50)
store i8* %51, i8** %9
br label %89
52: ; preds = %38, %38
%53 = load i8*, i8** @optarg
%54 = call i8* @safe_strdup(i8* %53)
store i8* %54, i8** %10
br label %89
55: ; preds = %38, %38
%56 = load i8*, i8** @optarg
%57 = call i8* @safe_strdup(i8* %56)
store i8* %57, i8** %11
br label %89
58: ; preds = %38, %38
%59 = load i8*, i8** @optarg
%60 = call i8* @safe_strdup(i8* %59)
store i8* %60, i8** %12
br label %89
61: ; preds = %38, %38
%62 = load i8*, i8** @optarg
%63 = call i32 (i8*, i8*, ...) @sscanf(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
store i32 %63, i32* %17
%64 = load i32, i32* %17
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %61
%67 = load i32, i32* %13
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = load i32, i32* %13
br label %72
71: ; preds = %66
br label %72
72: ; preds = %71, %69
%73 = phi i32 [ %70, %69 ], [ 15, %71 ]
store i32 %73, i32* %13
br label %75
74: ; preds = %61
store i32 15, i32* %13
br label %75
75: ; preds = %74, %72
%76 = load i32, i32* %13
%77 = mul nsw i32 %76, 60
store i32 %77, i32* %13
br label %89
78: ; preds = %38, %38
%79 = load i8*, i8** @optarg
%80 = call i32 (i8*, i8*, ...) @sscanf(i8* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %14)
store i32 %80, i32* %17
%81 = load i32, i32* %17
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = load i64, i64* %14
br label %86
85: ; preds = %78
br label %86
86: ; preds = %85, %83
%87 = phi i64 [ %84, %83 ], [ 0, %85 ]
store i64 %87, i64* %14
br label %89
88: ; preds = %38, %38
store i32 1, i32* %15
br label %89
89: ; preds = %38, %88, %86, %75, %58, %55, %52, %49, %46, %43, %40
br label %33
90: ; preds = %33
store i32 0, i32* %18
store i32 0, i32* %19
%91 = load i8*, i8** %7
%92 = call i8* @get_admin_hash(i8* %91)
store i8* %92, i8** %20
%93 = load i32, i32* %15
%94 = icmp eq i32 %93, 1
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
br label %251
97: ; preds = %90
%98 = load i8*, i8** %20
%99 = icmp ne i8* %98, null
br i1 %99, label %100, label %250
100: ; preds = %97
%101 = call i32 @time(i64* %21)
%102 = load i8*, i8** %6
%103 = icmp ne i8* %102, null
br i1 %103, label %104, label %118
104: ; preds = %100
%105 = load i8*, i8** %6
%106 = load i8*, i8** %20
%107 = call i8* @crypt(i8* %105, i8* %106)
%108 = load i8*, i8** %20
%109 = call i64 @strcmp(i8* %107, i8* %108)
%110 = icmp eq i64 %109, 0
%111 = zext i1 %110 to i64
%112 = select i1 %110, i32 1, i32 0
store i32 %112, i32* %19
%113 = load i32, i32* %19
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %104
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0))
br label %117
117: ; preds = %115, %104
br label %176
118: ; preds = %100
%119 = load i8*, i8** %8
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %175
121: ; preds = %118
%122 = load i8*, i8** %9
%123 = icmp ne i8* %122, null
br i1 %123, label %124, label %175
124: ; preds = %121
%125 = load i8*, i8** %10
%126 = icmp ne i8* %125, null
br i1 %126, label %127, label %175
127: ; preds = %124
%128 = load i8*, i8** %11
%129 = icmp ne i8* %128, null
br i1 %129, label %130, label %175
130: ; preds = %127
%131 = load i8*, i8** %9
%132 = call i32 (i8*, i8*, ...) @sscanf(i8* %131, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %22)
store i32 %132, i32* %23
%133 = load i32, i32* %23
%134 = icmp sgt i32 %133, 0
br i1 %134, label %135, label %149
135: ; preds = %130
store i32 1, i32* %18
%136 = load i64, i64* %22
%137 = load i64, i64* %21
%138 = icmp sgt i64 %136, %137
br i1 %138, label %139, label %148
139: ; preds = %135
%140 = load i64, i64* %22
%141 = load i32, i32* %13
%142 = sext i32 %141 to i64
%143 = sub nsw i64 %140, %142
%144 = sub nsw i64 %143, 2
%145 = load i64, i64* %21
%146 = icmp sle i64 %144, %145
br i1 %146, label %147, label %148
147: ; preds = %139
store i32 0, i32* %18
br label %148
148: ; preds = %147, %139, %135
br label %149
149: ; preds = %148, %130
%150 = load i8*, i8** %20
%151 = load i8*, i8** %9
%152 = load i8*, i8** %10
%153 = load i8*, i8** %11
%154 = call i8* @safe_strcat(i32 4, i8* %150, i8* %151, i8* %152, i8* %153)
store i8* %154, i8** %24
%155 = load i8*, i8** %24
%156 = call i8* @get_sha256_hash_hex_str(i8* %155)
store i8* %156, i8** %25
%157 = load i8*, i8** %25
%158 = load i8*, i8** %8
%159 = call i64 @strcmp(i8* %157, i8* %158)
%160 = icmp eq i64 %159, 0
br i1 %160, label %161, label %169
161: ; preds = %149
%162 = load i32, i32* %18
%163 = icmp eq i32 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %161
%165 = load i32, i32* %23
%166 = icmp sgt i32 %165, 0
br i1 %166, label %167, label %168
167: ; preds = %164
store i32 1, i32* %19
br label %168
168: ; preds = %167, %164, %161
br label %170
169: ; preds = %149
store i32 0, i32* %18
br label %170
170: ; preds = %169, %168
%171 = load i8*, i8** %25
%172 = call i32 @free(i8* %171)
%173 = load i8*, i8** %24
%174 = call i32 @free(i8* %173)
br label %175
175: ; preds = %170, %127, %124, %121, %118
br label %176
176: ; preds = %175, %117
%177 = load i32, i32* %19
%178 = icmp eq i32 %177, 1
br i1 %178, label %179, label %247
179: ; preds = %176
%180 = load i8*, i8** %11
%181 = icmp ne i8* %180, null
br i1 %181, label %182, label %247
182: ; preds = %179
%183 = load i8*, i8** %10
%184 = icmp ne i8* %183, null
br i1 %184, label %185, label %247
185: ; preds = %182
%186 = bitcast [100 x i8]* %28 to i8*
%187 = load i64, i64* %21
%188 = load i32, i32* %13
%189 = sext i32 %188 to i64
%190 = add nsw i64 %187, %189
store i64 %190, i64* %29
%191 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%192 = load i64, i64* %29
%193 = call i32 (i8*, i8*, ...) @sprintf(i8* %191, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %192)
%194 = load i64, i64* %14
%195 = icmp ugt i64 %194, 0
br i1 %195, label %196, label %213
196: ; preds = %185
%197 = load i64, i64* %14
%198 = load i64, i64* %21
%199 = sub i64 %197, %198
%200 = icmp ult i64 %199, -300
br i1 %200, label %206, label %201
201: ; preds = %196
%202 = load i64, i64* %14
%203 = load i64, i64* %21
%204 = sub i64 %202, %203
%205 = icmp ugt i64 %204, 300
br i1 %205, label %206, label %213
206: ; preds = %201, %196
%207 = load i64, i64* %14
%208 = load i32, i32* %13
%209 = sext i32 %208 to i64
%210 = add i64 %207, %209
store i64 %210, i64* %31
%211 = load i64, i64* %31
%212 = call i8* @get_cookie_time(i64 %211)
store i8* %212, i8** %30
br label %216
213: ; preds = %201, %185
%214 = load i64, i64* %29
%215 = call i8* @get_cookie_time(i64 %214)
store i8* %215, i8** %30
br label %216
216: ; preds = %213, %206
%217 = load i8*, i8** %20
%218 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%219 = load i8*, i8** %10
%220 = load i8*, i8** %11
%221 = call i8* @safe_strcat(i32 4, i8* %217, i8* %218, i8* %219, i8* %220)
store i8* %221, i8** %27
%222 = load i8*, i8** %27
%223 = call i8* @get_sha256_hash_hex_str(i8* %222)
store i8* %223, i8** %26
%224 = load i64, i64* %14
%225 = icmp eq i64 %224, 0
br i1 %225, label %226, label %231
226: ; preds = %216
%227 = load i8*, i8** %26
%228 = load i8*, i8** %7
%229 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.5, i64 0, i64 0), i8* %227, i8* %228, i8* %229)
br label %239
231: ; preds = %216
%232 = load i8*, i8** %26
%233 = load i8*, i8** %30
%234 = load i8*, i8** %7
%235 = load i8*, i8** %30
%236 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%237 = load i8*, i8** %30
%238 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.6, i64 0, i64 0), i8* %232, i8* %233, i8* %234, i8* %235, i8* %236, i8* %237)
br label %239
239: ; preds = %231, %226
%240 = load i8*, i8** %26
%241 = call i32 @free(i8* %240)
%242 = load i8*, i8** %27
%243 = call i32 @free(i8* %242)
%244 = load i8*, i8** %30
%245 = call i32 @free(i8* %244)
%246 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %247
247: ; preds = %239, %182, %179, %176
%248 = load i8*, i8** %20
%249 = call i32 @free(i8* %248)
br label %250
250: ; preds = %247, %97
br label %251
251: ; preds = %250, %95
%252 = load i8*, i8** %12
%253 = icmp ne i8* %252, null
br i1 %253, label %254, label %272
254: ; preds = %251
%255 = bitcast [20 x i8]* %32 to i8*
%256 = load i32, i32* %18
%257 = icmp eq i32 %256, 1
br i1 %257, label %258, label %261
258: ; preds = %254
%259 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%260 = call i32 (i8*, i8*, ...) @sprintf(i8* %259, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %268
261: ; preds = %254
%262 = load i32, i32* %15
%263 = icmp eq i32 %262, 1
br i1 %263, label %264, label %267
264: ; preds = %261
%265 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%266 = call i32 (i8*, i8*, ...) @sprintf(i8* %265, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %267
267: ; preds = %264, %261
br label %268
268: ; preds = %267, %258
%269 = load i8*, i8** %12
%270 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%271 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.10, i64 0, i64 0), i8* %269, i8* %270)
br label %272
272: ; preds = %268, %251
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"p:P:u:U:c:C:e:E:a:A:i:I:r:R:t:T:b:B:lL\00"
@optarg = global i8* null
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [83 x i8] c"echo \22Set-Cookie:kagera_sid=loggedout;\22; echo \22Set-Cookie:kagera_usr=loggedout;\22; \00"
@.str.4 = [96 x i8] c"logger -t webui \22Kagera Administration Interface authorization succeeded from ${REMOTE_ADDR}\22; \00"
@.str.5 = [127 x i8] c"echo \22Set-Cookie:kagera_sid=%s; Path=/;\22; echo \22Set-Cookie:kagera_usr=%s; Path=/;\22; echo \22Set-Cookie:kagera_exp=%s; Path=/;\22; \00"
@.str.6 = [163 x i8] c"echo \22Set-Cookie:kagera_sid=%s; Expires=%s; Path=/;\22; echo \22Set-Cookie:kagera_usr=%s; Expires=%s; Path=/;\22; echo \22Set-Cookie:kagera_exp=%s; Expires=%s; Path=/;\22; \00"
@.str.8 = [11 x i8] c"&expired=1\00"
@.str.9 = [13 x i8] c"&loggedout=1\00"
@.str.10 = [68 x i8] c"echo \22HTTP/1.1 301 Moved Permanently;\22; echo \22Location: %s%s\22; exit\00"
@str = [12 x i8] c"VALIDSESS=1\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca [100 x i8]
%8 = alloca [20 x i8]
%9 = bitcast i32* %3 to i8*
store i32 15, i32* %3
%10 = bitcast i64* %4 to i8*
store i64 0, i64* %4
br label %11
11: ; preds = %21, %2
%12 = phi i32 [ 0, %2 ], [ %22, %21 ]
%13 = phi i8* [ null, %2 ], [ %23, %21 ]
%14 = phi i8* [ null, %2 ], [ %24, %21 ]
%15 = phi i8* [ null, %2 ], [ %25, %21 ]
%16 = phi i8* [ null, %2 ], [ %26, %21 ]
%17 = phi i8* [ null, %2 ], [ %27, %21 ]
%18 = phi i8* [ null, %2 ], [ %28, %21 ]
%19 = phi i8* [ null, %2 ], [ %29, %21 ]
%20 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
switch i32 %20, label %21 [
i32 -1, label %67
i32 112, label %30
i32 80, label %30
i32 117, label %33
i32 85, label %33
i32 99, label %36
i32 67, label %36
i32 101, label %39
i32 69, label %39
i32 97, label %42
i32 65, label %42
i32 105, label %45
i32 73, label %45
i32 114, label %48
i32 82, label %48
i32 116, label %51
i32 84, label %51
i32 98, label %60
i32 66, label %60
i32 108, label %66
i32 76, label %66
]
21: ; preds = %11, %66, %60, %51, %48, %45, %42, %39, %36, %33, %30
%22 = phi i32 [ 1, %66 ], [ %12, %60 ], [ %12, %51 ], [ %12, %48 ], [ %12, %45 ], [ %12, %42 ], [ %12, %39 ], [ %12, %36 ], [ %12, %33 ], [ %12, %30 ], [ %12, %11 ]
%23 = phi i8* [ %13, %66 ], [ %13, %60 ], [ %13, %51 ], [ %50, %48 ], [ %13, %45 ], [ %13, %42 ], [ %13, %39 ], [ %13, %36 ], [ %13, %33 ], [ %13, %30 ], [ %13, %11 ]
%24 = phi i8* [ %14, %66 ], [ %14, %60 ], [ %14, %51 ], [ %14, %48 ], [ %47, %45 ], [ %14, %42 ], [ %14, %39 ], [ %14, %36 ], [ %14, %33 ], [ %14, %30 ], [ %14, %11 ]
%25 = phi i8* [ %15, %66 ], [ %15, %60 ], [ %15, %51 ], [ %15, %48 ], [ %15, %45 ], [ %44, %42 ], [ %15, %39 ], [ %15, %36 ], [ %15, %33 ], [ %15, %30 ], [ %15, %11 ]
%26 = phi i8* [ %16, %66 ], [ %16, %60 ], [ %16, %51 ], [ %16, %48 ], [ %16, %45 ], [ %16, %42 ], [ %41, %39 ], [ %16, %36 ], [ %16, %33 ], [ %16, %30 ], [ %16, %11 ]
%27 = phi i8* [ %17, %66 ], [ %17, %60 ], [ %17, %51 ], [ %17, %48 ], [ %17, %45 ], [ %17, %42 ], [ %17, %39 ], [ %38, %36 ], [ %17, %33 ], [ %17, %30 ], [ %17, %11 ]
%28 = phi i8* [ %18, %66 ], [ %18, %60 ], [ %18, %51 ], [ %18, %48 ], [ %18, %45 ], [ %18, %42 ], [ %18, %39 ], [ %18, %36 ], [ %35, %33 ], [ %18, %30 ], [ %18, %11 ]
%29 = phi i8* [ %19, %66 ], [ %19, %60 ], [ %19, %51 ], [ %19, %48 ], [ %19, %45 ], [ %19, %42 ], [ %19, %39 ], [ %19, %36 ], [ %19, %33 ], [ %32, %30 ], [ %19, %11 ]
br label %11
30: ; preds = %11, %11
%31 = load i8*, i8** @optarg
%32 = call i8* @safe_strdup(i8* %31)
br label %21
33: ; preds = %11, %11
%34 = load i8*, i8** @optarg
%35 = call i8* @safe_strdup(i8* %34)
br label %21
36: ; preds = %11, %11
%37 = load i8*, i8** @optarg
%38 = call i8* @safe_strdup(i8* %37)
br label %21
39: ; preds = %11, %11
%40 = load i8*, i8** @optarg
%41 = call i8* @safe_strdup(i8* %40)
br label %21
42: ; preds = %11, %11
%43 = load i8*, i8** @optarg
%44 = call i8* @safe_strdup(i8* %43)
br label %21
45: ; preds = %11, %11
%46 = load i8*, i8** @optarg
%47 = call i8* @safe_strdup(i8* %46)
br label %21
48: ; preds = %11, %11
%49 = load i8*, i8** @optarg
%50 = call i8* @safe_strdup(i8* %49)
br label %21
51: ; preds = %11, %11
%52 = load i8*, i8** @optarg
%53 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%54 = icmp sgt i32 %53, 0
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 0
%57 = select i1 %54, i1 %56, i1 false
%58 = mul nsw i32 %55, 60
%59 = select i1 %57, i32 %58, i32 900
store i32 %59, i32* %3
br label %21
60: ; preds = %11, %11
%61 = load i8*, i8** @optarg
%62 = call i32 (i8*, i8*, ...) @sscanf(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %4)
%63 = icmp sgt i32 %62, 0
%64 = load i64, i64* %4
%65 = select i1 %63, i64 %64, i64 0
store i64 %65, i64* %4
br label %21
66: ; preds = %11, %11
br label %21
67: ; preds = %11
%68 = call i8* @get_admin_hash(i8* %18)
%69 = icmp eq i32 %12, 1
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
br label %158
72: ; preds = %67
%73 = icmp eq i8* %68, null
br i1 %73, label %158, label %74
74: ; preds = %72
%75 = bitcast i64* %5 to i8*
%76 = call i32 @time(i64* %5)
%77 = icmp eq i8* %19, null
br i1 %77, label %84, label %78
78: ; preds = %74
%79 = call i8* @crypt(i8* %19, i8* %68)
%80 = call i64 @strcmp(i8* %79, i8* %68)
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %155
82: ; preds = %78
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0))
br label %121
84: ; preds = %74
%85 = icmp ne i8* %17, null
%86 = icmp ne i8* %16, null
%87 = select i1 %85, i1 %86, i1 false
%88 = icmp ne i8* %15, null
%89 = select i1 %87, i1 %88, i1 false
%90 = icmp ne i8* %14, null
%91 = select i1 %89, i1 %90, i1 false
br i1 %91, label %92, label %155
92: ; preds = %84
%93 = bitcast i64* %6 to i8*
%94 = call i32 (i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %6)
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %108
96: ; preds = %92
%97 = load i64, i64* %6
%98 = load i64, i64* %5
%99 = icmp sgt i64 %97, %98
br i1 %99, label %100, label %108
100: ; preds = %96
%101 = load i32, i32* %3
%102 = sext i32 %101 to i64
%103 = add i64 %97, -2
%104 = sub i64 %103, %102
%105 = icmp sgt i64 %104, %98
%106 = xor i1 %105, true
%107 = zext i1 %105 to i32
br label %108
108: ; preds = %100, %96, %92
%109 = phi i1 [ false, %96 ], [ true, %92 ], [ %106, %100 ]
%110 = phi i32 [ 1, %96 ], [ 0, %92 ], [ %107, %100 ]
%111 = call i8* @safe_strcat(i32 4, i8* %68, i8* %16, i8* %15, i8* %14)
%112 = call i8* @get_sha256_hash_hex_str(i8* %111)
%113 = call i64 @strcmp(i8* %112, i8* %17)
%114 = icmp eq i64 %113, 0
%115 = and i1 %95, %109
%116 = select i1 %115, i32 0, i32 %110
%117 = select i1 %114, i32 %116, i32 0
%118 = call i32 @free(i8* %112)
%119 = call i32 @free(i8* %111)
%120 = select i1 %114, i1 %115, i1 false
br label %121
121: ; preds = %108, %82
%122 = phi i32 [ 0, %82 ], [ %117, %108 ]
%123 = phi i1 [ true, %82 ], [ %120, %108 ]
%124 = icmp ne i8* %14, null
%125 = select i1 %123, i1 %124, i1 false
%126 = icmp ne i8* %15, null
%127 = select i1 %125, i1 %126, i1 false
br i1 %127, label %128, label %155
128: ; preds = %121
%129 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%130 = load i64, i64* %5
%131 = load i32, i32* %3
%132 = sext i32 %131 to i64
%133 = add nsw i64 %130, %132
%134 = call i32 (i8*, i8*, ...) @sprintf(i8* %129, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %133)
%135 = load i64, i64* %4
%136 = icmp eq i64 %135, 0
%137 = load i32, i32* %3
%138 = sext i32 %137 to i64
%139 = add i64 %135, %138
%140 = select i1 %136, i64 %133, i64 %139
%141 = call i8* @get_cookie_time(i64 %140)
%142 = call i8* @safe_strcat(i32 4, i8* %68, i8* %129, i8* %15, i8* %14)
%143 = call i8* @get_sha256_hash_hex_str(i8* %142)
%144 = load i64, i64* %4
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %148
146: ; preds = %128
%147 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([127 x i8], [127 x i8]* @.str.5, i64 0, i64 0), i8* %143, i8* %18, i8* %129)
br label %150
148: ; preds = %128
%149 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([163 x i8], [163 x i8]* @.str.6, i64 0, i64 0), i8* %143, i8* %141, i8* %18, i8* %141, i8* %129, i8* %141)
br label %150
150: ; preds = %148, %146
%151 = call i32 @free(i8* %143)
%152 = call i32 @free(i8* %142)
%153 = call i32 @free(i8* %141)
%154 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %155
155: ; preds = %78, %84, %150, %121
%156 = phi i32 [ %122, %150 ], [ %122, %121 ], [ 0, %84 ], [ 0, %78 ]
%157 = call i32 @free(i8* %68)
br label %158
158: ; preds = %72, %155, %70
%159 = phi i32 [ 0, %70 ], [ %156, %155 ], [ 0, %72 ]
%160 = icmp eq i8* %13, null
br i1 %160, label %169, label %161
161: ; preds = %158
%162 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%163 = icmp eq i32 %159, 1
br i1 %163, label %164, label %165
164: ; preds = %161
br label %167
165: ; preds = %161
br i1 %69, label %166, label %167
166: ; preds = %165
br label %167
167: ; preds = %165, %166, %164
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.10, i64 0, i64 0), i8* %13, i8* %162)
br label %169
169: ; preds = %167, %158
ret i32 0
}