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

/* Variables and functions */
int /*<<< orphan*/ f(char *);
char random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void *doSomeThing() {
  char arr[16];
  char *str;
  srandom(time(NULL));
  int i;
  for (i = 0; i < sizeof(arr) - 1; i++) {
    arr[i] = (random() % ('z' - 'a' + 1)) + 'a';
  }
  arr[sizeof(arr) - 1] = '\0';
  str = arr;
  f(str);
}


x86 assembly (clang, -O0):
<doSomeThing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    $0xf,%rax
jae    119a <doSomeThing+0x5a>
mov    $0x0,%al
call   1060 <random@plt>
movsbl %al,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %dl,%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115f <doSomeThing+0x1f>
movb   $0x0,-0x11(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <f@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doSomeThing>:
sub    $0x18,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x1(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x2(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x3(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x4(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x5(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x6(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x7(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x8(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0x9(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0xa(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0xb(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0xc(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0xd(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
movsbl %al,%eax
imul   $0x4f,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
sar    $0x3,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x61,%al
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %rsp,%rdi
call   1040 <f@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i8* @doSomeThing() {
%1 = alloca i8*
%2 = alloca [16 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = call i32 @time(i32* null)
%6 = call i32 @srandom(i32 %5)
store i32 0, i32* %4
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 15
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = call signext i8 (...) @random()
%13 = sext i8 %12 to i32
%14 = srem i32 %13, 26
%15 = add nsw i32 %14, 97
%16 = trunc i32 %15 to i8
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %18
store i8 %16, i8* %19
br label %20
20: ; preds = %11
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %7
23: ; preds = %7
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 15
store i8 0, i8* %24
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
store i8* %25, i8** %3
%26 = load i8*, i8** %3
%27 = call i32 @f(i8* %26)
%28 = load i8*, i8** %1
ret i8* %28
}

LLVM IR (-O2):
define noalias i8* @doSomeThing() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srandom(i32 %3)
%5 = tail call signext i8 (...) @random()
%6 = srem i8 %5, 26
%7 = add nsw i8 %6, 97
store i8 %7, i8* %2
%8 = tail call signext i8 (...) @random()
%9 = srem i8 %8, 26
%10 = add nsw i8 %9, 97
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 1
store i8 %10, i8* %11
%12 = tail call signext i8 (...) @random()
%13 = srem i8 %12, 26
%14 = add nsw i8 %13, 97
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 2
store i8 %14, i8* %15
%16 = tail call signext i8 (...) @random()
%17 = srem i8 %16, 26
%18 = add nsw i8 %17, 97
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 3
store i8 %18, i8* %19
%20 = tail call signext i8 (...) @random()
%21 = srem i8 %20, 26
%22 = add nsw i8 %21, 97
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 4
store i8 %22, i8* %23
%24 = tail call signext i8 (...) @random()
%25 = srem i8 %24, 26
%26 = add nsw i8 %25, 97
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 5
store i8 %26, i8* %27
%28 = tail call signext i8 (...) @random()
%29 = srem i8 %28, 26
%30 = add nsw i8 %29, 97
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 6
store i8 %30, i8* %31
%32 = tail call signext i8 (...) @random()
%33 = srem i8 %32, 26
%34 = add nsw i8 %33, 97
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 7
store i8 %34, i8* %35
%36 = tail call signext i8 (...) @random()
%37 = srem i8 %36, 26
%38 = add nsw i8 %37, 97
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 8
store i8 %38, i8* %39
%40 = tail call signext i8 (...) @random()
%41 = srem i8 %40, 26
%42 = add nsw i8 %41, 97
%43 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 9
store i8 %42, i8* %43
%44 = tail call signext i8 (...) @random()
%45 = srem i8 %44, 26
%46 = add nsw i8 %45, 97
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 10
store i8 %46, i8* %47
%48 = tail call signext i8 (...) @random()
%49 = srem i8 %48, 26
%50 = add nsw i8 %49, 97
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 11
store i8 %50, i8* %51
%52 = tail call signext i8 (...) @random()
%53 = srem i8 %52, 26
%54 = add nsw i8 %53, 97
%55 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 12
store i8 %54, i8* %55
%56 = tail call signext i8 (...) @random()
%57 = srem i8 %56, 26
%58 = add nsw i8 %57, 97
%59 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 13
store i8 %58, i8* %59
%60 = tail call signext i8 (...) @random()
%61 = srem i8 %60, 26
%62 = add nsw i8 %61, 97
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 14
store i8 %62, i8* %63
%64 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 15
store i8 0, i8* %64
%65 = call i32 @f(i8* %2)
ret i8* undef
}