#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 /*<<< orphan*/ time(int /*<<< orphan*/);
void insert(char *ch, int *n) {
  int index;
  srand(time(0));
  char temp;
  for (index = 0; index < *n; index++) {
    temp = rand() % 128;
    if ((temp >= 'A' && temp <= 'Z') || (temp >= 'a' && temp <= 'z'))
      ch[index] = temp;
    else
      index--;
  }
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11db <insert+0xab>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x41,%eax
jl     1192 <insert+0x62>
movsbl -0x15(%rbp),%eax
cmp    $0x5a,%eax
jle    11ac <insert+0x7c>
movsbl -0x15(%rbp),%eax
cmp    $0x61,%eax
jl     11bf <insert+0x8f>
movsbl -0x15(%rbp),%eax
cmp    $0x7a,%eax
jg     11bf <insert+0x8f>
mov    -0x15(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11c8 <insert+0x98>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <insert+0x9d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <insert+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
cmpl   $0x0,(%rbx)
jle    119d <insert+0x6d>
xor    %ebp,%ebp
jmp    116e <insert+0x3e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rax
mov    %cl,(%r14,%rax,1)
add    $0x1,%ebp
cmp    (%rbx),%ebp
jge    119d <insert+0x6d>
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x7f(%rax),%edx
test   %eax,%eax
cmovns %eax,%edx
and    $0xffffff80,%edx
mov    %eax,%ecx
sub    %edx,%ecx
lea    -0x41(%rcx),%esi
cmp    $0x1a,%esi
jb     1160 <insert+0x30>
neg    %edx
add    %edx,%eax
add    $0xffffff9f,%eax
cmp    $0x19,%eax
jbe    1160 <insert+0x30>
add    $0xffffffff,%ebp
jmp    1167 <insert+0x37>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @insert(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = call i32 @time(i32 0)
%8 = call i32 @srand(i32 %7)
store i32 0, i32* %5
br label %9
9: ; preds = %43, %2
%10 = load i32, i32* %5
%11 = load i32*, i32** %4
%12 = load i32, i32* %11
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %46
14: ; preds = %9
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 128
%17 = trunc i32 %16 to i8
store i8 %17, i8* %6
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp sge i32 %19, 65
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = load i8, i8* %6
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 90
br i1 %24, label %33, label %25
25: ; preds = %21, %14
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = icmp sge i32 %27, 97
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = load i8, i8* %6
%31 = sext i8 %30 to i32
%32 = icmp sle i32 %31, 122
br i1 %32, label %33, label %39
33: ; preds = %29, %21
%34 = load i8, i8* %6
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
br label %42
39: ; preds = %29, %25
%40 = load i32, i32* %5
%41 = add nsw i32 %40, -1
store i32 %41, i32* %5
br label %42
42: ; preds = %39, %33
br label %43
43: ; preds = %42
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %9
46: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @insert(i8* nocapture writeonly %0, i32* nocapture %1) {
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srand(i32 %3)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %2, %22
%8 = phi i32 [ %24, %22 ], [ 0, %2 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 128
%11 = add nsw i32 %10, -65
%12 = icmp ult i32 %11, 26
%13 = add nsw i32 %10, -97
%14 = icmp ult i32 %13, 26
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %20
16: ; preds = %7
%17 = trunc i32 %10 to i8
%18 = sext i32 %8 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 %17, i8* %19
br label %22
20: ; preds = %7
%21 = add nsw i32 %8, -1
br label %22
22: ; preds = %16, %20
%23 = phi i32 [ %8, %16 ], [ %21, %20 ]
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %1
%26 = icmp slt i32 %24, %25
br i1 %26, label %7, label %27
27: ; preds = %22, %2
ret void
}