#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*/ usalt;
typedef int /*<<< orphan*/ salt;
typedef int /*<<< orphan*/ pass;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ STDIN_FILENO;
char *crypt(char *, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char *generate_salt(int);
int getopt(int const, char *const *, char *);
char *getpass(char *);
char *optarg;
int const optind;
int /*<<< orphan*/ printf(char *, char *);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ usage();
scalar_t__ validate_password(char *);
int main(const int argc, const char **argv) {
  int opt;
  int method = 0x36;
  char usalt[64] = {
      0,
  };
  char salt[32] = {
      0,
  };
  char *pass1 = NULL;
  char *pass2 = NULL;
  char *pass = NULL;
  int stdin_flag = 0;
  while ((opt = getopt(argc, (char *const *)argv, "him:s:")) != EOF) {
    switch (opt) {
    case 'i':
      stdin_flag = 1;
      break;
    case 'm':
      if (strcasecmp(optarg, "md5") == 0) {
        method = 0x31;
      } else if (strcasecmp(optarg, "sha256") == 0) {
        method = 0x35;
      } else if (strcasecmp(optarg, "sha512") == 0) {
        method = 0x36;
      } else {
        fprintf(stderr, ("ERROR: invalid value of -m (%s)\n\n"), optarg);
        usage();
      }
      break;
    case 's':
      (strlen(optarg) >= sizeof(usalt))
          ? strncpy(usalt, optarg, sizeof(usalt) - 1)
          : strcpy(usalt, optarg);
      break;
    default:
      usage();
    }
  }
  if ((argc - optind) > 0)
    usage();
  if (strlen(usalt) > 0) {
    char salt_prefix[4] = {
        0,
    };
    sprintf(salt_prefix, "$%c$", method);
    if (usalt[0] == '$' && usalt[2] == '$') {
      if (strncmp(salt_prefix, usalt, 3) != 0) {
        char *algo;
        fprintf(stderr, ("The given salt is invalid. "));
        if (method == 0x31)
          algo = "md5";
        else if (method == 0x35)
          algo = "sha256";
        else
          algo = "sha512";
        fprintf(stderr, ("The salt of %s is started by '$%c$'\n"), algo,
                method);
        exit(1);
      }
      {
        char *ptr = strchr(usalt + 3, '$');
        if (ptr != NULL)
          *ptr = 0;
        (strlen(usalt) >= sizeof(salt)) ? strncpy(salt, usalt, sizeof(salt) - 1)
                                        : strcpy(salt, usalt);
      }
    } else {
      strcpy(salt, salt_prefix);
      (strlen(usalt) >= (sizeof(salt) - strlen(salt)))
          ? strncat(salt, usalt, sizeof(salt) - 1)
          : strcat(salt, usalt);
    }
  } else {
    char *rsalt = generate_salt(method);
    strcpy(salt, rsalt);
    do {
      if (rsalt) {
        free(rsalt);
        rsalt = NULL;
      }
    } while (0);
  }
  if (stdin_flag) {
    int i;
    char pass[256] = {
        0,
    };
    char *ptr;
    i = read(STDIN_FILENO, pass, sizeof(pass));
    if (i < 0) {
      fprintf(stderr, ("Error: error reading from stdin: %s\n"),
              strerror(errno));
      exit(1);
    }
    if (i == sizeof(pass)) {
      if (pass[i - 1] != '\n') {
        fprintf(stderr, ("Error: password too long, maximum is %u\n"), 255);
        exit(1);
      }
      i--;
    }
    pass[i] = 0;
    ptr = strchr(pass, '\n');
    if (ptr)
      *ptr = 0;
    if (validate_password(pass))
      exit(1);
    pass1 = strdup(pass);
  } else {
    pass = getpass(("Password: "));
    if (validate_password(pass))
      exit(1);
    pass1 = strdup(pass);
    pass = getpass(("Retype Password: "));
    pass2 = strdup(pass);
    if (strcmp(pass1, pass2) != 0) {
      fprintf(stderr, ("Error: Sorry, passwords are not match.\n"));
      do {
        if (pass1) {
          free(pass1);
          pass1 = NULL;
        }
      } while (0);
      do {
        if (pass2) {
          free(pass2);
          pass2 = NULL;
        }
      } while (0);
      exit(1);
    }
    do {
      if (pass2) {
        free(pass2);
        pass2 = NULL;
      }
    } while (0);
  }
  printf("%s\n", crypt(pass1, (char *)salt));
  do {
    if (pass1) {
      free(pass1);
      pass1 = NULL;
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x36,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   10e0 <memset@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10e0 <memset@plt>
movq   $0x0,-0x88(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd07(%rip),%rdx
call   1150 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    0x2cd8(%rip),%rcx
cmp    (%rcx),%eax
je     1472 <main+0x1f2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1cc(%rbp)
sub    $0x69,%eax
je     134f <main+0xcf>
jmp    1327 <main+0xa7>
mov    -0x1cc(%rbp),%eax
sub    $0x6d,%eax
je     135e <main+0xde>
jmp    133b <main+0xbb>
mov    -0x1cc(%rbp),%eax
sub    $0x73,%eax
je     1416 <main+0x196>
jmp    1466 <main+0x1e6>
movl   $0x1,-0x9c(%rbp)
jmp    146d <main+0x1ed>
mov    0x2c93(%rip),%rax
mov    (%rax),%rdi
lea    0xc98(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1389 <main+0x109>
movl   $0x31,-0x18(%rbp)
jmp    1411 <main+0x191>
mov    0x2c68(%rip),%rax
mov    (%rax),%rdi
lea    0xc71(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    13b4 <main+0x134>
movl   $0x35,-0x18(%rbp)
jmp    140c <main+0x18c>
mov    0x2c3d(%rip),%rax
mov    (%rax),%rdi
lea    0xc4d(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    13df <main+0x15f>
movl   $0x36,-0x18(%rbp)
jmp    1407 <main+0x187>
mov    0x2be2(%rip),%rax
mov    (%rax),%edi
mov    0x2c09(%rip),%rax
mov    (%rax),%rdx
lea    0xc20(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
mov    $0x0,%al
call   1130 <usage@plt>
jmp    140c <main+0x18c>
jmp    1411 <main+0x191>
jmp    146d <main+0x1ed>
mov    0x2bdb(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strlen@plt>
cltq
cmp    $0x40,%rax
jb     144e <main+0x1ce>
lea    -0x60(%rbp),%rdi
mov    0x2bbc(%rip),%rax
mov    (%rax),%rsi
mov    $0x3f,%edx
call   1050 <strncpy@plt>
jmp    1461 <main+0x1e1>
lea    -0x60(%rbp),%rdi
mov    0x2b9f(%rip),%rax
mov    (%rax),%rsi
call   1080 <strcpy@plt>
jmp    146d <main+0x1ed>
mov    $0x0,%al
call   1130 <usage@plt>
jmp    12eb <main+0x6b>
mov    -0x8(%rbp),%eax
mov    0x2b5c(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x0,%eax
jle    148e <main+0x20e>
mov    $0x0,%al
call   1130 <usage@plt>
lea    -0x60(%rbp),%rdi
call   10b0 <strlen@plt>
cmp    $0x0,%eax
jle    1671 <main+0x3f1>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   10e0 <memset@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xb77(%rip),%rsi
call   1170 <sprintf@plt>
movsbl -0x60(%rbp),%eax
cmp    $0x24,%eax
jne    1600 <main+0x380>
movsbl -0x5e(%rbp),%eax
cmp    $0x24,%eax
jne    1600 <main+0x380>
lea    -0xa0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x3,%edx
call   1060 <strncmp@plt>
cmp    $0x0,%rax
je     1591 <main+0x311>
mov    0x2abf(%rip),%rax
mov    (%rax),%edi
lea    0xb2e(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
cmpl   $0x31,-0x18(%rbp)
jne    1536 <main+0x2b6>
lea    0xadd(%rip),%rax
mov    %rax,-0xa8(%rbp)
jmp    1566 <main+0x2e6>
cmpl   $0x35,-0x18(%rbp)
jne    1553 <main+0x2d3>
lea    0xac4(%rip),%rax
mov    %rax,-0xa8(%rbp)
jmp    1561 <main+0x2e1>
lea    0xab8(%rip),%rax
mov    %rax,-0xa8(%rbp)
jmp    1566 <main+0x2e6>
mov    0x2a5b(%rip),%rax
mov    (%rax),%edi
mov    -0xa8(%rbp),%rdx
mov    -0x18(%rbp),%ecx
lea    0xadc(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
lea    -0x60(%rbp),%rdi
add    $0x3,%rdi
mov    $0x24,%esi
call   10c0 <strchr@plt>
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     15c2 <main+0x342>
mov    -0xb0(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x60(%rbp),%rdi
call   10b0 <strlen@plt>
cltq
cmp    $0x20,%rax
jb     15ee <main+0x36e>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x1f,%edx
call   1050 <strncpy@plt>
jmp    15fb <main+0x37b>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <strcpy@plt>
jmp    166c <main+0x3ec>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1080 <strcpy@plt>
lea    -0x60(%rbp),%rdi
call   10b0 <strlen@plt>
cltq
mov    %rax,-0x1d8(%rbp)
lea    -0x80(%rbp),%rdi
call   10b0 <strlen@plt>
mov    %eax,%ecx
mov    -0x1d8(%rbp),%rax
movslq %ecx,%rdx
mov    $0x20,%ecx
sub    %rdx,%rcx
cmp    %rcx,%rax
jb     165f <main+0x3df>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x1f,%edx
call   10f0 <strncat@plt>
jmp    166c <main+0x3ec>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1160 <strcat@plt>
jmp    16bf <main+0x43f>
mov    -0x18(%rbp),%edi
call   10a0 <generate_salt@plt>
mov    %rax,-0xb8(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0xb8(%rbp),%rsi
call   1080 <strcpy@plt>
cmpq   $0x0,-0xb8(%rbp)
je     16b5 <main+0x435>
mov    -0xb8(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0xb8(%rbp)
jmp    16ba <main+0x43a>
jmp    16bf <main+0x43f>
cmpl   $0x0,-0x9c(%rbp)
je     1825 <main+0x5a5>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10e0 <memset@plt>
mov    0x28d2(%rip),%rax
mov    (%rax),%edi
lea    -0x1c0(%rbp),%rsi
mov    $0x100,%edx
call   1100 <read@plt>
mov    %eax,-0xbc(%rbp)
cmpl   $0x0,-0xbc(%rbp)
jge    174a <main+0x4ca>
mov    0x28b5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1dc(%rbp)
mov    0x289e(%rip),%rax
mov    (%rax),%edi
call   11a0 <strerror@plt>
mov    -0x1dc(%rbp),%edi
mov    %rax,%rdx
lea    0x948(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
movslq -0xbc(%rbp),%rax
cmp    $0x100,%rax
jne    17ae <main+0x52e>
mov    -0xbc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x1c0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     179f <main+0x51f>
mov    0x2848(%rip),%rax
mov    (%rax),%edi
lea    0x91d(%rip),%rsi
mov    $0xff,%edx
mov    $0x0,%al
call   1120 <fprintf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0xbc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xbc(%rbp)
movslq -0xbc(%rbp),%rax
movb   $0x0,-0x1c0(%rbp,%rax,1)
lea    -0x1c0(%rbp),%rdi
mov    $0xa,%esi
call   10c0 <strchr@plt>
mov    %rax,-0x1c8(%rbp)
cmpq   $0x0,-0x1c8(%rbp)
je     17ed <main+0x56d>
mov    -0x1c8(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x1c0(%rbp),%rdi
call   1070 <validate_password@plt>
cmp    $0x0,%rax
je     180d <main+0x58d>
mov    $0x1,%edi
call   1180 <exit@plt>
lea    -0x1c0(%rbp),%rdi
call   1190 <strdup@plt>
mov    %rax,-0x88(%rbp)
jmp    195c <main+0x6dc>
lea    0x8aa(%rip),%rdi
call   1140 <getpass@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1070 <validate_password@plt>
cmp    $0x0,%rax
je     1858 <main+0x5d8>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0x98(%rbp),%rdi
call   1190 <strdup@plt>
mov    %rax,-0x88(%rbp)
lea    0x85d(%rip),%rdi
call   1140 <getpass@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1190 <strdup@plt>
mov    %rax,-0x90(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
je     1928 <main+0x6a8>
mov    0x2713(%rip),%rax
mov    (%rax),%edi
lea    0x823(%rip),%rsi
mov    $0x0,%al
call   1120 <fprintf@plt>
cmpq   $0x0,-0x88(%rbp)
je     18ea <main+0x66a>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x88(%rbp)
jmp    18ef <main+0x66f>
jmp    18f4 <main+0x674>
cmpq   $0x0,-0x90(%rbp)
je     1919 <main+0x699>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x90(%rbp)
jmp    191e <main+0x69e>
mov    $0x1,%edi
call   1180 <exit@plt>
jmp    192d <main+0x6ad>
cmpq   $0x0,-0x90(%rbp)
je     1952 <main+0x6d2>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x90(%rbp)
jmp    1957 <main+0x6d7>
jmp    195c <main+0x6dc>
mov    -0x88(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1090 <crypt@plt>
mov    %rax,%rsi
lea    0x72c(%rip),%rdi
call   10d0 <printf@plt>
cmpq   $0x0,-0x88(%rbp)
je     19a0 <main+0x720>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x88(%rbp)
jmp    19a5 <main+0x725>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
mov    %rsi,%r15
mov    %edi,%r13d
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xd51(%rip),%rdx
call   1140 <getopt@plt>
mov    0x2d25(%rip),%rbx
cmp    (%rbx),%eax
jne    138c <main+0x11c>
mov    $0x36,%r12d
movl   $0x0,0xc(%rsp)
test   %r13d,%r13d
jle    12dd <main+0x6d>
xor    %eax,%eax
call   1120 <usage@plt>
lea    0x30(%rsp),%rdi
call   10b0 <strlen@plt>
test   %eax,%eax
jle    14c6 <main+0x256>
movl   $0x0,0x70(%rsp)
lea    0xd3d(%rip),%rsi
lea    0x70(%rsp),%rdi
mov    %r12d,%edx
call   1160 <sprintf@plt>
cmpb   $0x24,0x30(%rsp)
jne    14f7 <main+0x287>
cmpb   $0x24,0x32(%rsp)
jne    14f7 <main+0x287>
lea    0x70(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0x3,%edx
call   1060 <strncmp@plt>
test   %rax,%rax
jne    1772 <main+0x502>
lea    0x33(%rsp),%rdi
mov    $0x24,%esi
call   10c0 <strchr@plt>
test   %rax,%rax
je     1355 <main+0xe5>
movb   $0x0,(%rax)
lea    0x30(%rsp),%rdi
call   10b0 <strlen@plt>
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
cmp    $0x20,%eax
jb     1657 <main+0x3e7>
mov    $0x1f,%edx
call   1050 <strncpy@plt>
cmpl   $0x0,0xc(%rsp)
jne    155d <main+0x2ed>
jmp    1667 <main+0x3f7>
mov    $0x36,%r12d
lea    0xc67(%rip),%rbp
movl   $0x0,0xc(%rsp)
jmp    13cd <main+0x15d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1120 <usage@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1140 <getopt@plt>
cmp    (%rbx),%eax
je     12d1 <main+0x61>
cmp    $0x69,%eax
je     1460 <main+0x1f0>
cmp    $0x73,%eax
je     1470 <main+0x200>
cmp    $0x6d,%eax
jne    13b0 <main+0x140>
mov    %r12d,%r14d
mov    0x2c0a(%rip),%rax
mov    (%rax),%r12
mov    %r12,%rdi
lea    0xc0c(%rip),%rsi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     14a5 <main+0x235>
mov    %r12,%rdi
lea    0xbf9(%rip),%rsi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     14b0 <main+0x240>
mov    %r12,%rdi
lea    0xbe9(%rip),%rsi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     14bb <main+0x24b>
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
lea    0xbd3(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1110 <fprintf@plt>
xor    %eax,%eax
call   1120 <usage@plt>
mov    %r14d,%r12d
jmp    13b7 <main+0x147>
nop
movl   $0x1,0xc(%rsp)
jmp    13b7 <main+0x147>
nopl   (%rax)
mov    0x2b81(%rip),%r14
mov    (%r14),%rdi
call   10b0 <strlen@plt>
mov    (%r14),%rsi
lea    0x30(%rsp),%rdi
cmp    $0x40,%eax
jb     149b <main+0x22b>
mov    $0x3f,%edx
call   1050 <strncpy@plt>
jmp    13b7 <main+0x147>
call   1080 <strcpy@plt>
jmp    13b7 <main+0x147>
mov    $0x31,%r12d
jmp    13b7 <main+0x147>
mov    $0x35,%r12d
jmp    13b7 <main+0x147>
mov    $0x36,%r12d
jmp    13b7 <main+0x147>
mov    %r12d,%edi
call   10a0 <generate_salt@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    %rax,%rsi
call   1080 <strcpy@plt>
test   %rbx,%rbx
je     1552 <main+0x2e2>
mov    %rbx,%rdi
call   1030 <free@plt>
cmpl   $0x0,0xc(%rsp)
jne    155d <main+0x2ed>
jmp    1667 <main+0x3f7>
lea    0x10(%rsp),%rbx
lea    0x70(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcpy@plt>
lea    0x30(%rsp),%rdi
call   10b0 <strlen@plt>
movslq %eax,%rbp
mov    %rbx,%rdi
call   10b0 <strlen@plt>
cltq
mov    $0x20,%ecx
sub    %rax,%rcx
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
cmp    %rbp,%rcx
jbe    1548 <main+0x2d8>
call   1150 <strcat@plt>
cmpl   $0x0,0xc(%rsp)
jne    155d <main+0x2ed>
jmp    1667 <main+0x3f7>
mov    $0x1f,%edx
call   10e0 <strncat@plt>
cmpl   $0x0,0xc(%rsp)
je     1667 <main+0x3f7>
xorps  %xmm0,%xmm0
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
mov    0x29dc(%rip),%rax
mov    (%rax),%edi
lea    0x70(%rsp),%rsi
mov    $0x100,%edx
call   10f0 <read@plt>
test   %eax,%eax
js     1703 <main+0x493>
cmp    $0x100,%eax
jne    1617 <main+0x3a7>
mov    $0xff,%eax
cmpb   $0xa,0x16f(%rsp)
0a
jne    17cb <main+0x55b>
mov    %eax,%eax
movb   $0x0,0x70(%rsp,%rax,1)
lea    0x70(%rsp),%rdi
mov    $0xa,%esi
call   10c0 <strchr@plt>
test   %rax,%rax
je     1635 <main+0x3c5>
movb   $0x0,(%rax)
lea    0x70(%rsp),%rdi
call   1070 <validate_password@plt>
test   %rax,%rax
jne    1768 <main+0x4f8>
lea    0x70(%rsp),%rdi
call   1180 <strdup@plt>
mov    %rax,%rbx
jmp    16c6 <main+0x456>
call   1080 <strcpy@plt>
cmpl   $0x0,0xc(%rsp)
jne    155d <main+0x2ed>
lea    0xa68(%rip),%rdi
call   1130 <getpass@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <validate_password@plt>
test   %rax,%rax
jne    1768 <main+0x4f8>
mov    %rbx,%rdi
call   1180 <strdup@plt>
mov    %rax,%rbx
lea    0xa36(%rip),%rdi
call   1130 <getpass@plt>
mov    %rax,%rdi
call   1180 <strdup@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
jne    1737 <main+0x4c7>
test   %rbp,%rbp
je     16c6 <main+0x456>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <crypt@plt>
lea    0x9c8(%rip),%rdi
mov    %rax,%rsi
call   10d0 <printf@plt>
test   %rbx,%rbx
je     16ef <main+0x47f>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x178,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x28c6(%rip),%rax
mov    (%rax),%ebx
mov    0x28b5(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
lea    0x960(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x2892(%rip),%rax
mov    (%rax),%edi
lea    0x99a(%rip),%rsi
xor    %eax,%eax
call   1110 <fprintf@plt>
test   %rbx,%rbx
je     175b <main+0x4eb>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %rbp,%rbp
je     1768 <main+0x4f8>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x2857(%rip),%rbx
mov    (%rbx),%edi
lea    0x8be(%rip),%rsi
xor    %eax,%eax
call   1110 <fprintf@plt>
cmp    $0x35,%r12d
lea    0x877(%rip),%rax
lea    0x877(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x31,%r12d
lea    0x85d(%rip),%rdx
cmovne %rcx,%rdx
mov    (%rbx),%edi
lea    0x8a5(%rip),%rsi
mov    %r12d,%ecx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x27fe(%rip),%rax
mov    (%rax),%edi
lea    0x8cb(%rip),%rsi
mov    $0xff,%edx
xor    %eax,%eax
call   1110 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"him:s:\00"
@EOF = global i32 0
@optarg = global i8* null
@.str.1 = [4 x i8] c"md5\00"
@.str.2 = [7 x i8] c"sha256\00"
@.str.3 = [7 x i8] c"sha512\00"
@stderr = global i32 0
@.str.4 = [34 x i8] c"ERROR: invalid value of -m (%s)\0A\0A\00"
@optind = constant i32 0
@.str.5 = [5 x i8] c"$%c$\00"
@.str.6 = [28 x i8] c"The given salt is invalid. \00"
@.str.7 = [37 x i8] c"The salt of %s is started by '$%c$'\0A\00"
@STDIN_FILENO = global i32 0
@.str.8 = [37 x i8] c"Error: error reading from stdin: %s\0A\00"
@errno = global i32 0
@.str.9 = [41 x i8] c"Error: password too long, maximum is %u\0A\00"
@.str.10 = [11 x i8] c"Password: \00"
@.str.11 = [18 x i8] c"Retype Password: \00"
@.str.12 = [40 x i8] c"Error: Sorry, passwords are not match.\0A\00"
@.str.13 = [4 x i8] c"%s\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 [64 x i8]
%9 = alloca [32 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca [4 x i8]
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca [256 x i8]
%20 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 54, i32* %7
%21 = bitcast [64 x i8]* %8 to i8*
%22 = bitcast [32 x i8]* %9 to i8*
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32 0, i32* %13
br label %23
23: ; preds = %72, %2
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
%26 = call i32 @getopt(i32 %24, i8** %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %26, i32* %6
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %73
29: ; preds = %23
%30 = load i32, i32* %6
switch i32 %30, label %70 [
i32 105, label %31
i32 109, label %32
i32 115, label %55
]
31: ; preds = %29
store i32 1, i32* %13
br label %72
32: ; preds = %29
%33 = load i8*, i8** @optarg
%34 = call i32 @strcasecmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 49, i32* %7
br label %54
37: ; preds = %32
%38 = load i8*, i8** @optarg
%39 = call i32 @strcasecmp(i8* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 53, i32* %7
br label %53
42: ; preds = %37
%43 = load i8*, i8** @optarg
%44 = call i32 @strcasecmp(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 54, i32* %7
br label %52
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** @optarg
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = call i32 (...) @usage()
br label %52
52: ; preds = %47, %46
br label %53
53: ; preds = %52, %41
br label %54
54: ; preds = %53, %36
br label %72
55: ; preds = %29
%56 = load i8*, i8** @optarg
%57 = call i32 @strlen(i8* %56)
%58 = sext i32 %57 to i64
%59 = icmp uge i64 %58, 64
br i1 %59, label %60, label %64
60: ; preds = %55
%61 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%62 = load i8*, i8** @optarg
%63 = call i32 @strncpy(i8* %61, i8* %62, i32 63)
br label %68
64: ; preds = %55
%65 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%66 = load i8*, i8** @optarg
%67 = call i32 @strcpy(i8* %65, i8* %66)
br label %68
68: ; preds = %64, %60
%69 = phi i32 [ %63, %60 ], [ %67, %64 ]
br label %72
70: ; preds = %29
%71 = call i32 (...) @usage()
br label %72
72: ; preds = %70, %68, %54, %31
br label %23
73: ; preds = %23
%74 = load i32, i32* %4
%75 = load i32, i32* @optind
%76 = sub nsw i32 %74, %75
%77 = icmp sgt i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %73
%79 = call i32 (...) @usage()
br label %80
80: ; preds = %78, %73
%81 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%82 = call i32 @strlen(i8* %81)
%83 = icmp sgt i32 %82, 0
br i1 %83, label %84, label %167
84: ; preds = %80
%85 = bitcast [4 x i8]* %14 to i8*
%86 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%87 = load i32, i32* %7
%88 = call i32 @sprintf(i8* %86, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 36
br i1 %92, label %93, label %144
93: ; preds = %84
%94 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 2
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 36
br i1 %97, label %98, label %144
98: ; preds = %93
%99 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%100 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%101 = call i64 @strncmp(i8* %99, i8* %100, i32 3)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %121
103: ; preds = %98
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%106 = load i32, i32* %7
%107 = icmp eq i32 %106, 49
br i1 %107, label %108, label %109
108: ; preds = %103
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %15
br label %115
109: ; preds = %103
%110 = load i32, i32* %7
%111 = icmp eq i32 %110, 53
br i1 %111, label %112, label %113
112: ; preds = %109
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %15
br label %114
113: ; preds = %109
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %15
br label %114
114: ; preds = %113, %112
br label %115
115: ; preds = %114, %108
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %15
%118 = load i32, i32* %7
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %117, i32 %118)
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %98
%122 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%123 = getelementptr inbounds i8, i8* %122, i64 3
%124 = call i8* @strchr(i8* %123, i8 signext 36)
store i8* %124, i8** %16
%125 = load i8*, i8** %16
%126 = icmp ne i8* %125, null
br i1 %126, label %127, label %129
127: ; preds = %121
%128 = load i8*, i8** %16
store i8 0, i8* %128
br label %129
129: ; preds = %127, %121
%130 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%131 = call i32 @strlen(i8* %130)
%132 = sext i32 %131 to i64
%133 = icmp uge i64 %132, 32
br i1 %133, label %134, label %138
134: ; preds = %129
%135 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%136 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%137 = call i32 @strncpy(i8* %135, i8* %136, i32 31)
br label %142
138: ; preds = %129
%139 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%140 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%141 = call i32 @strcpy(i8* %139, i8* %140)
br label %142
142: ; preds = %138, %134
%143 = phi i32 [ %137, %134 ], [ %141, %138 ]
br label %166
144: ; preds = %93, %84
%145 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%146 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%147 = call i32 @strcpy(i8* %145, i8* %146)
%148 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%149 = call i32 @strlen(i8* %148)
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%152 = call i32 @strlen(i8* %151)
%153 = sext i32 %152 to i64
%154 = sub i64 32, %153
%155 = icmp uge i64 %150, %154
br i1 %155, label %156, label %160
156: ; preds = %144
%157 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%158 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%159 = call i32 @strncat(i8* %157, i8* %158, i32 31)
br label %164
160: ; preds = %144
%161 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%162 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%163 = call i32 @strcat(i8* %161, i8* %162)
br label %164
164: ; preds = %160, %156
%165 = phi i32 [ %159, %156 ], [ %163, %160 ]
br label %166
166: ; preds = %164, %142
br label %181
167: ; preds = %80
%168 = load i32, i32* %7
%169 = call i8* @generate_salt(i32 %168)
store i8* %169, i8** %17
%170 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%171 = load i8*, i8** %17
%172 = call i32 @strcpy(i8* %170, i8* %171)
br label %173
173: ; preds = %167
%174 = load i8*, i8** %17
%175 = icmp ne i8* %174, null
br i1 %175, label %176, label %179
176: ; preds = %173
%177 = load i8*, i8** %17
%178 = call i32 @free(i8* %177)
store i8* null, i8** %17
br label %179
179: ; preds = %176, %173
br label %180
180: ; preds = %179
br label %181
181: ; preds = %180, %166
%182 = load i32, i32* %13
%183 = icmp ne i32 %182, 0
br i1 %183, label %184, label %235
184: ; preds = %181
%185 = bitcast [256 x i8]* %19 to i8*
%186 = load i32, i32* @STDIN_FILENO
%187 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%188 = call i32 @read(i32 %186, i8* %187, i32 256)
store i32 %188, i32* %18
%189 = load i32, i32* %18
%190 = icmp slt i32 %189, 0
br i1 %190, label %191, label %197
191: ; preds = %184
%192 = load i32, i32* @stderr
%193 = load i32, i32* @errno
%194 = call i8* @strerror(i32 %193)
%195 = call i32 (i32, i8*, ...) @fprintf(i32 %192, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %194)
%196 = call i32 @exit(i32 1)
unreachable
197: ; preds = %184
%198 = load i32, i32* %18
%199 = sext i32 %198 to i64
%200 = icmp eq i64 %199, 256
br i1 %200, label %201, label %216
201: ; preds = %197
%202 = load i32, i32* %18
%203 = sub nsw i32 %202, 1
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 %204
%206 = load i8, i8* %205
%207 = sext i8 %206 to i32
%208 = icmp ne i32 %207, 10
br i1 %208, label %209, label %213
209: ; preds = %201
%210 = load i32, i32* @stderr
%211 = call i32 (i32, i8*, ...) @fprintf(i32 %210, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i32 255)
%212 = call i32 @exit(i32 1)
unreachable
213: ; preds = %201
%214 = load i32, i32* %18
%215 = add nsw i32 %214, -1
store i32 %215, i32* %18
br label %216
216: ; preds = %213, %197
%217 = load i32, i32* %18
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 %218
store i8 0, i8* %219
%220 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%221 = call i8* @strchr(i8* %220, i8 signext 10)
store i8* %221, i8** %20
%222 = load i8*, i8** %20
%223 = icmp ne i8* %222, null
br i1 %223, label %224, label %226
224: ; preds = %216
%225 = load i8*, i8** %20
store i8 0, i8* %225
br label %226
226: ; preds = %224, %216
%227 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%228 = call i64 @validate_password(i8* %227)
%229 = icmp ne i64 %228, 0
br i1 %229, label %230, label %232
230: ; preds = %226
%231 = call i32 @exit(i32 1)
unreachable
232: ; preds = %226
%233 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%234 = call i8* @strdup(i8* %233)
store i8* %234, i8** %10
br label %281
235: ; preds = %181
%236 = call i8* @getpass(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
store i8* %236, i8** %12
%237 = load i8*, i8** %12
%238 = call i64 @validate_password(i8* %237)
%239 = icmp ne i64 %238, 0
br i1 %239, label %240, label %242
240: ; preds = %235
%241 = call i32 @exit(i32 1)
unreachable
242: ; preds = %235
%243 = load i8*, i8** %12
%244 = call i8* @strdup(i8* %243)
store i8* %244, i8** %10
%245 = call i8* @getpass(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
store i8* %245, i8** %12
%246 = load i8*, i8** %12
%247 = call i8* @strdup(i8* %246)
store i8* %247, i8** %11
%248 = load i8*, i8** %10
%249 = load i8*, i8** %11
%250 = call i64 @strcmp(i8* %248, i8* %249)
%251 = icmp ne i64 %250, 0
br i1 %251, label %252, label %272
252: ; preds = %242
%253 = load i32, i32* @stderr
%254 = call i32 (i32, i8*, ...) @fprintf(i32 %253, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0))
br label %255
255: ; preds = %252
%256 = load i8*, i8** %10
%257 = icmp ne i8* %256, null
br i1 %257, label %258, label %261
258: ; preds = %255
%259 = load i8*, i8** %10
%260 = call i32 @free(i8* %259)
store i8* null, i8** %10
br label %261
261: ; preds = %258, %255
br label %262
262: ; preds = %261
br label %263
263: ; preds = %262
%264 = load i8*, i8** %11
%265 = icmp ne i8* %264, null
br i1 %265, label %266, label %269
266: ; preds = %263
%267 = load i8*, i8** %11
%268 = call i32 @free(i8* %267)
store i8* null, i8** %11
br label %269
269: ; preds = %266, %263
br label %270
270: ; preds = %269
%271 = call i32 @exit(i32 1)
unreachable
272: ; preds = %242
br label %273
273: ; preds = %272
%274 = load i8*, i8** %11
%275 = icmp ne i8* %274, null
br i1 %275, label %276, label %279
276: ; preds = %273
%277 = load i8*, i8** %11
%278 = call i32 @free(i8* %277)
store i8* null, i8** %11
br label %279
279: ; preds = %276, %273
br label %280
280: ; preds = %279
br label %281
281: ; preds = %280, %232
%282 = load i8*, i8** %10
%283 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%284 = call i8* @crypt(i8* %282, i8* %283)
%285 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %284)
br label %286
286: ; preds = %281
%287 = load i8*, i8** %10
%288 = icmp ne i8* %287, null
br i1 %288, label %289, label %292
289: ; preds = %286
%290 = load i8*, i8** %10
%291 = call i32 @free(i8* %290)
store i8* null, i8** %10
br label %292
292: ; preds = %289, %286
br label %293
293: ; preds = %292
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"him:s:\00"
@EOF = global i32 0
@optarg = global i8* null
@.str.1 = [4 x i8] c"md5\00"
@.str.2 = [7 x i8] c"sha256\00"
@.str.3 = [7 x i8] c"sha512\00"
@stderr = global i32 0
@.str.4 = [34 x i8] c"ERROR: invalid value of -m (%s)\0A\0A\00"
@optind = constant i32 0
@.str.5 = [5 x i8] c"$%c$\00"
@.str.6 = [28 x i8] c"The given salt is invalid. \00"
@.str.7 = [37 x i8] c"The salt of %s is started by '$%c$'\0A\00"
@STDIN_FILENO = global i32 0
@.str.8 = [37 x i8] c"Error: error reading from stdin: %s\0A\00"
@errno = global i32 0
@.str.9 = [41 x i8] c"Error: password too long, maximum is %u\0A\00"
@.str.10 = [11 x i8] c"Password: \00"
@.str.11 = [18 x i8] c"Retype Password: \00"
@.str.12 = [40 x i8] c"Error: Sorry, passwords are not match.\0A\00"
@.str.13 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [64 x i8]
%4 = alloca [32 x i8]
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%9 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %47, label %12
12: ; preds = %2, %41
%13 = phi i32 [ %44, %41 ], [ %9, %2 ]
%14 = phi i32 [ %43, %41 ], [ 54, %2 ]
%15 = phi i32 [ %42, %41 ], [ 0, %2 ]
switch i32 %13, label %39 [
i32 105, label %41
i32 109, label %16
i32 115, label %30
]
16: ; preds = %12
%17 = load i8*, i8** @optarg
%18 = call i32 @strcasecmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %41, label %20
20: ; preds = %16
%21 = call i32 @strcasecmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %41, label %23
23: ; preds = %20
%24 = call i32 @strcasecmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %41, label %26
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%29 = call i32 (...) @usage()
br label %41
30: ; preds = %12
%31 = load i8*, i8** @optarg
%32 = call i32 @strlen(i8* %31)
%33 = icmp ugt i32 %32, 63
%34 = load i8*, i8** @optarg
br i1 %33, label %35, label %37
35: ; preds = %30
%36 = call i32 @strncpy(i8* %7, i8* %34, i32 63)
br label %41
37: ; preds = %30
%38 = call i32 @strcpy(i8* %7, i8* %34)
br label %41
39: ; preds = %12
%40 = call i32 (...) @usage()
br label %41
41: ; preds = %23, %20, %16, %12, %35, %37, %26, %39
%42 = phi i32 [ %15, %39 ], [ %15, %35 ], [ %15, %37 ], [ %15, %26 ], [ 1, %12 ], [ %15, %16 ], [ %15, %20 ], [ %15, %23 ]
%43 = phi i32 [ %14, %39 ], [ %14, %35 ], [ %14, %37 ], [ %14, %26 ], [ %14, %12 ], [ 49, %16 ], [ 53, %20 ], [ 54, %23 ]
%44 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%45 = load i32, i32* @EOF
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %12
47: ; preds = %41, %2
%48 = phi i32 [ 0, %2 ], [ %42, %41 ]
%49 = phi i32 [ 54, %2 ], [ %43, %41 ]
%50 = icmp sgt i32 %0, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (...) @usage()
br label %53
53: ; preds = %51, %47
%54 = call i32 @strlen(i8* %7)
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %103
56: ; preds = %53
%57 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%58 = call i32 @sprintf(i8* %57, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%59 = load i8, i8* %7
%60 = icmp eq i8 %59, 36
%61 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 2
%62 = load i8, i8* %61
%63 = icmp eq i8 %62, 36
%64 = select i1 %60, i1 %63, i1 false
br i1 %64, label %65, label %90
65: ; preds = %56
%66 = call i64 @strncmp(i8* %57, i8* %7, i32 3)
%67 = icmp eq i64 %66, 0
br i1 %67, label %78, label %68
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%71 = icmp eq i32 %49, 53
%72 = select i1 %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%73 = icmp eq i32 %49, 49
%74 = select i1 %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %72
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %74, i32 %49)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %65
%79 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 3
%80 = call i8* @strchr(i8* %79, i8 signext 36)
%81 = icmp eq i8* %80, null
br i1 %81, label %83, label %82
82: ; preds = %78
store i8 0, i8* %80
br label %83
83: ; preds = %82, %78
%84 = call i32 @strlen(i8* %7)
%85 = icmp ugt i32 %84, 31
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = call i32 @strncpy(i8* %8, i8* %7, i32 31)
br label %102
88: ; preds = %83
%89 = call i32 @strcpy(i8* %8, i8* %7)
br label %102
90: ; preds = %56
%91 = call i32 @strcpy(i8* %8, i8* %57)
%92 = call i32 @strlen(i8* %7)
%93 = sext i32 %92 to i64
%94 = call i32 @strlen(i8* %8)
%95 = sext i32 %94 to i64
%96 = sub nsw i64 32, %95
%97 = icmp ugt i64 %96, %93
br i1 %97, label %100, label %98
98: ; preds = %90
%99 = call i32 @strncat(i8* %8, i8* %7, i32 31)
br label %102
100: ; preds = %90
%101 = call i32 @strcat(i8* %8, i8* %7)
br label %102
102: ; preds = %86, %88, %98, %100
br label %109
103: ; preds = %53
%104 = call i8* @generate_salt(i32 %49)
%105 = call i32 @strcpy(i8* %8, i8* %104)
%106 = icmp eq i8* %104, null
br i1 %106, label %109, label %107
107: ; preds = %103
%108 = call i32 @free(i8* %104)
br label %109
109: ; preds = %103, %107, %102
%110 = icmp eq i32 %48, 0
br i1 %110, label %146, label %111
111: ; preds = %109
%112 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%113 = load i32, i32* @STDIN_FILENO
%114 = call i32 @read(i32 %113, i8* %112, i32 256)
%115 = icmp slt i32 %114, 0
br i1 %115, label %116, label %122
116: ; preds = %111
%117 = load i32, i32* @stderr
%118 = load i32, i32* @errno
%119 = call i8* @strerror(i32 %118)
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %119)
%121 = call i32 @exit(i32 1)
unreachable
122: ; preds = %111
%123 = icmp eq i32 %114, 256
br i1 %123, label %124, label %132
124: ; preds = %122
%125 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 255
%126 = load i8, i8* %125
%127 = icmp eq i8 %126, 10
br i1 %127, label %132, label %128
128: ; preds = %124
%129 = load i32, i32* @stderr
%130 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i32 255)
%131 = call i32 @exit(i32 1)
unreachable
132: ; preds = %124, %122
%133 = phi i32 [ %114, %122 ], [ 255, %124 ]
%134 = zext i32 %133 to i64
%135 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %134
store i8 0, i8* %135
%136 = call i8* @strchr(i8* %112, i8 signext 10)
%137 = icmp eq i8* %136, null
br i1 %137, label %139, label %138
138: ; preds = %132
store i8 0, i8* %136
br label %139
139: ; preds = %138, %132
%140 = call i64 @validate_password(i8* %112)
%141 = icmp eq i64 %140, 0
br i1 %141, label %144, label %142
142: ; preds = %139
%143 = call i32 @exit(i32 1)
unreachable
144: ; preds = %139
%145 = call i8* @strdup(i8* %112)
br label %174
146: ; preds = %109
%147 = call i8* @getpass(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%148 = call i64 @validate_password(i8* %147)
%149 = icmp eq i64 %148, 0
br i1 %149, label %152, label %150
150: ; preds = %146
%151 = call i32 @exit(i32 1)
unreachable
152: ; preds = %146
%153 = call i8* @strdup(i8* %147)
%154 = call i8* @getpass(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%155 = call i8* @strdup(i8* %154)
%156 = call i64 @strcmp(i8* %153, i8* %155)
%157 = icmp eq i64 %156, 0
br i1 %157, label %170, label %158
158: ; preds = %152
%159 = load i32, i32* @stderr
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0))
%161 = icmp eq i8* %153, null
br i1 %161, label %164, label %162
162: ; preds = %158
%163 = call i32 @free(i8* %153)
br label %164
164: ; preds = %158, %162
%165 = icmp eq i8* %155, null
br i1 %165, label %168, label %166
166: ; preds = %164
%167 = call i32 @free(i8* %155)
br label %168
168: ; preds = %166, %164
%169 = call i32 @exit(i32 1)
unreachable
170: ; preds = %152
%171 = icmp eq i8* %155, null
br i1 %171, label %174, label %172
172: ; preds = %170
%173 = call i32 @free(i8* %155)
br label %174
174: ; preds = %170, %172, %144
%175 = phi i8* [ %145, %144 ], [ %153, %172 ], [ %153, %170 ]
%176 = call i8* @crypt(i8* %175, i8* %8)
%177 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %176)
%178 = icmp eq i8* %175, null
br i1 %178, label %181, label %179
179: ; preds = %174
%180 = call i32 @free(i8* %175)
br label %181
181: ; preds = %179, %174
ret i32 0
}