char *returnFooString(int **doubleIntPtr, unsigned short ushortValue) {
  int i;
  static char returnVal[100];
  for (i = 0; i < (**doubleIntPtr); i++)
    returnVal[i] = ((ushortValue + i) % 26) + 'a';
  returnVal[(**doubleIntPtr)] = '\0';
  return returnVal;
}


x86 assembly (clang, -O0):
<returnFooString>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
cmp    (%rcx),%eax
jge    1156 <returnFooString+0x56>
movzwl -0xa(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
movslq -0x10(%rbp),%rcx
lea    0x2eeb(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1116 <returnFooString+0x16>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq (%rax),%rcx
lea    0x2ec9(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2ebe(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<returnFooString>:
mov    (%rdi),%rax
mov    (%rax),%r8d
test   %r8d,%r8d
jle    1156 <returnFooString+0x56>
lea    0x61(%rsi),%r10d
movzwl %si,%r11d
xor    %edx,%edx
lea    0x2f14(%rip),%r9
nopl   0x0(%rax)
mov    %r11d,%esi
imul   $0x4ec4ec4f,%rsi,%rsi
shr    $0x23,%rsi
lea    (%rsi,%rsi,4),%eax
lea    (%rax,%rax,4),%eax
add    %esi,%eax
mov    %r10d,%ecx
sub    %al,%cl
mov    %cl,(%rdx,%r9,1)
add    $0x1,%rdx
mov    (%rdi),%rax
movslq (%rax),%r8
add    $0x1,%r10b
add    $0x1,%r11d
cmp    %r8,%rdx
jl     1120 <returnFooString+0x20>
movslq %r8d,%rcx
lea    0x2ed0(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
ret

LLVM IR (-O0):
@returnFooString.returnVal = internal global [100 x i8] zeroinitializer
define i8* @returnFooString(i32** %0, i16 zeroext %1) {
%3 = alloca i32**
%4 = alloca i16
%5 = alloca i32
store i32** %0, i32*** %3
store i16 %1, i16* %4
store i32 0, i32* %5
br label %6
6: ; preds = %23, %2
%7 = load i32, i32* %5
%8 = load i32**, i32*** %3
%9 = load i32*, i32** %8
%10 = load i32, i32* %9
%11 = icmp slt i32 %7, %10
br i1 %11, label %12, label %26
12: ; preds = %6
%13 = load i16, i16* %4
%14 = zext i16 %13 to i32
%15 = load i32, i32* %5
%16 = add nsw i32 %14, %15
%17 = srem i32 %16, 26
%18 = add nsw i32 %17, 97
%19 = trunc i32 %18 to i8
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* @returnFooString.returnVal, i64 0, i64 %21
store i8 %19, i8* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %6
26: ; preds = %6
%27 = load i32**, i32*** %3
%28 = load i32*, i32** %27
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i8], [100 x i8]* @returnFooString.returnVal, i64 0, i64 %30
store i8 0, i8* %31
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @returnFooString.returnVal, i64 0, i64 0)
}

LLVM IR (-O2):
@returnFooString.returnVal = internal global [100 x i8] zeroinitializer
define i8* @returnFooString(i32** nocapture %0, i16 zeroext %1) {
%3 = load i32*, i32** %0
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %2
%7 = zext i16 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %16, %8 ]
%10 = add nuw nsw i64 %9, %7
%11 = trunc i64 %10 to i32
%12 = urem i32 %11, 26
%13 = trunc i32 %12 to i8
%14 = add nuw nsw i8 %13, 97
%15 = getelementptr inbounds [100 x i8], [100 x i8]* @returnFooString.returnVal, i64 0, i64 %9
store i8 %14, i8* %15
%16 = add nuw nsw i64 %9, 1
%17 = load i32*, i32** %0
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %16, %19
br i1 %20, label %8, label %21
21: ; preds = %8, %2
%22 = phi i32 [ %4, %2 ], [ %18, %8 ]
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* @returnFooString.returnVal, i64 0, i64 %23
store i8 0, i8* %24
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @returnFooString.returnVal, i64 0, i64 0)
}