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

/* Variables and functions */
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int strlen(unsigned char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int adj_order(unsigned char *pwd) {
  do {
  } while (0);
  int length = strlen(pwd);
  int idx = 0;
  srand(time(NULL));
  while (length) {
    idx = rand() % length;
    if (idx == length - 1) {
    } else {
      unsigned char tmp = *(pwd + length - 1);
      *(pwd + length - 1) = *(pwd + idx);
      *(pwd + idx) = tmp;
    }
    length--;
  }
}


x86 assembly (clang, -O0):
<adj_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
jmp    1151 <adj_order+0x11>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x0,-0x14(%rbp)
je     11e4 <adj_order+0xa4>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11a2 <adj_order+0x62>
jmp    11d6 <adj_order+0x96>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    -0x1(%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,-0x1(%rax,%rcx,1)
mov    -0x19(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <adj_order+0x34>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adj_order>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%r15d
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r15d,%r15d
je     11a0 <adj_order+0x60>
movslq %r15d,%rax
lea    (%rax,%r14,1),%rbx
add    $0xffffffffffffffff,%rbx
jmp    117a <adj_order+0x3a>
add    $0xffffffffffffffff,%rbx
add    $0xffffffff,%r15d
je     11a0 <adj_order+0x60>
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idiv   %r15d
lea    -0x1(%r15),%eax
cmp    %edx,%eax
je     1170 <adj_order+0x30>
movzbl (%rbx),%eax
movslq %edx,%rcx
movzbl (%r14,%rcx,1),%edx
mov    %dl,(%rbx)
mov    %al,(%r14,%rcx,1)
jmp    1170 <adj_order+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @adj_order(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
br label %7
7: ; preds = %1
br label %8
8: ; preds = %7
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %4
store i32 0, i32* %5
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
br label %13
13: ; preds = %47, %8
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %50
16: ; preds = %13
%17 = call i32 (...) @rand()
%18 = load i32, i32* %4
%19 = srem i32 %17, %18
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %25
24: ; preds = %16
br label %47
25: ; preds = %16
%26 = load i8*, i8** %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = getelementptr inbounds i8, i8* %29, i64 -1
%31 = load i8, i8* %30
store i8 %31, i8* %6
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %3
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 -1
store i8 %36, i8* %41
%42 = load i8, i8* %6
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %25, %24
%48 = load i32, i32* %4
%49 = add nsw i32 %48, -1
store i32 %49, i32* %4
br label %13
50: ; preds = %13
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
define i32 @adj_order(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp eq i32 %2, 0
br i1 %5, label %25, label %6
6: ; preds = %1
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 -1
br label %9
9: ; preds = %6, %23
%10 = phi i64 [ %7, %6 ], [ %14, %23 ]
%11 = tail call i32 (...) @rand()
%12 = trunc i64 %10 to i32
%13 = srem i32 %11, %12
%14 = add nsw i64 %10, -1
%15 = trunc i64 %14 to i32
%16 = icmp eq i32 %13, %15
br i1 %16, label %23, label %17
17: ; preds = %9
%18 = getelementptr inbounds i8, i8* %8, i64 %10
%19 = load i8, i8* %18
%20 = sext i32 %13 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
store i8 %22, i8* %18
store i8 %19, i8* %21
br label %23
23: ; preds = %9, %17
%24 = icmp eq i32 %15, 0
br i1 %24, label %25, label %9
25: ; preds = %23, %1
ret i32 undef
}