#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 */
double RAND_MAX;
double rand();
int strlen(char *);
void __sdel_random_filename(char *filename) {
  int i;
  for (i = strlen(filename) - 1; (filename[i] != '/') && (i >= 0); i--)
    if (filename[i] != '.')
      filename[i] = 97 + (int)((int)((256.0 * rand()) / (RAND_MAX + 1.0)) % 26);
}


x86 assembly (clang, -O0):
<__sdel_random_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0xd(%rbp)
je     115f <__sdel_random_filename+0x3f>
cmpl   $0x0,-0xc(%rbp)
setge  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    116f <__sdel_random_filename+0x4f>
jmp    11de <__sdel_random_filename+0xbe>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     11cb <__sdel_random_filename+0xab>
mov    $0x0,%al
call   1040 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe72(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe5e(%rip),%xmm1
mov    0x2e3f(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11d0 <__sdel_random_filename+0xb0>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    113b <__sdel_random_filename+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sdel_random_filename>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%rdx
mov    -0x1(%rdx,%r14,1),%cl
cmp    $0x2f,%cl
je     11c6 <__sdel_random_filename+0xa6>
test   %eax,%eax
jle    11c6 <__sdel_random_filename+0xa6>
lea    (%rdx,%r14,1),%r12
add    $0xffffffffffffffff,%r12
mov    %eax,%ebx
add    $0xfffffffffffffffe,%r14
mov    0x2e8a(%rip),%r15
xchg   %ax,%ax
cmp    $0x2e,%cl
je     11af <__sdel_random_filename+0x8f>
xor    %eax,%eax
call   1040 <rand@plt>
mulsd  0xe8c(%rip),%xmm0
movsd  (%r15),%xmm1
addsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x61,%al
mov    %al,(%r12)
movzbl (%r14,%rbx,1),%ecx
cmp    $0x2f,%cl
je     11c6 <__sdel_random_filename+0xa6>
lea    (%r14,%rbx,1),%r12
add    $0xffffffffffffffff,%rbx
test   %rbx,%rbx
jg     1160 <__sdel_random_filename+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @__sdel_random_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = sub nsw i32 %5, 1
store i32 %6, i32* %3
br label %7
7: ; preds = %43, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 47
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = load i32, i32* %3
%17 = icmp sge i32 %16, 0
br label %18
18: ; preds = %15, %7
%19 = phi i1 [ false, %7 ], [ %17, %15 ]
br i1 %19, label %20, label %46
20: ; preds = %18
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 46
br i1 %27, label %28, label %42
28: ; preds = %20
%29 = call double (...) @rand()
%30 = fmul double 2.560000e+02, %29
%31 = load double, double* @RAND_MAX
%32 = fadd double %31, 1.000000e+00
%33 = fdiv double %30, %32
%34 = fptosi double %33 to i32
%35 = srem i32 %34, 26
%36 = add nsw i32 97, %35
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 %37, i8* %41
br label %42
42: ; preds = %28, %20
br label %43
43: ; preds = %42
%44 = load i32, i32* %3
%45 = add nsw i32 %44, -1
store i32 %45, i32* %3
br label %7
46: ; preds = %18
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @__sdel_random_filename(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 47
%8 = icmp sgt i32 %2, 0
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %10, label %35
10: ; preds = %1
%11 = zext i32 %2 to i64
%12 = add nsw i64 %11, -1
br label %13
13: ; preds = %10, %28
%14 = phi i64 [ %12, %10 ], [ %29, %28 ]
%15 = phi i8 [ %6, %10 ], [ %31, %28 ]
%16 = phi i8* [ %5, %10 ], [ %30, %28 ]
%17 = icmp eq i8 %15, 46
br i1 %17, label %28, label %18
18: ; preds = %13
%19 = tail call double (...) @rand()
%20 = fmul double %19, 2.560000e+02
%21 = load double, double* @RAND_MAX
%22 = fadd double %21, 1.000000e+00
%23 = fdiv double %20, %22
%24 = fptosi double %23 to i32
%25 = srem i32 %24, 26
%26 = trunc i32 %25 to i8
%27 = add nsw i8 %26, 97
store i8 %27, i8* %16
br label %28
28: ; preds = %13, %18
%29 = add nsw i64 %14, -1
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 47
%33 = icmp sgt i64 %14, 0
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %13, label %35
35: ; preds = %28, %1
ret void
}