unsigned int __attribute__((no)) foo(unsigned long *x, void *y, void *z) {
  int i;
  for (i = 5; i > 0; i--)
    x[i] = (unsigned long)foo((unsigned long *)x[i], y, z);
  return 0;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x5,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    116c <foo+0x5c>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <foo@plt>
mov    %eax,%eax
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <foo+0x1b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x28(%rdi),%rdi
call   1030 <foo@plt>
movq   $0x0,0x28(%rbx)
mov    0x20(%rbx),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <foo@plt>
movq   $0x0,0x20(%rbx)
mov    0x18(%rbx),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <foo@plt>
movq   $0x0,0x18(%rbx)
mov    0x10(%rbx),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <foo@plt>
movq   $0x0,0x10(%rbx)
mov    0x8(%rbx),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <foo@plt>
movq   $0x0,0x8(%rbx)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @foo(i64* %0, i8* %1, i8* %2) {
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i64* %0, i64** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 5, i32* %7
br label %8
8: ; preds = %26, %3
%9 = load i32, i32* %7
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i64*, i64** %4
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i64, i64* %12, i64 %14
%16 = load i64, i64* %15
%17 = inttoptr i64 %16 to i64*
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = call i32 @foo(i64* %17, i8* %18, i8* %19)
%21 = zext i32 %20 to i64
%22 = load i64*, i64** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i64, i64* %22, i64 %24
store i64 %21, i64* %25
br label %26
26: ; preds = %11
%27 = load i32, i32* %7
%28 = add nsw i32 %27, -1
store i32 %28, i32* %7
br label %8
29: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
define i32 @foo(i64* nocapture %0, i8* nocapture readnone %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds i64, i64* %0, i64 5
%5 = load i64, i64* %4
%6 = inttoptr i64 %5 to i64*
%7 = tail call i32 @foo(i64* %6, i8* %1, i8* %2)
store i64 0, i64* %4
%8 = getelementptr inbounds i64, i64* %0, i64 4
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i64*
%11 = tail call i32 @foo(i64* %10, i8* %1, i8* %2)
store i64 0, i64* %8
%12 = getelementptr inbounds i64, i64* %0, i64 3
%13 = load i64, i64* %12
%14 = inttoptr i64 %13 to i64*
%15 = tail call i32 @foo(i64* %14, i8* %1, i8* %2)
store i64 0, i64* %12
%16 = getelementptr inbounds i64, i64* %0, i64 2
%17 = load i64, i64* %16
%18 = inttoptr i64 %17 to i64*
%19 = tail call i32 @foo(i64* %18, i8* %1, i8* %2)
store i64 0, i64* %16
%20 = getelementptr inbounds i64, i64* %0, i64 1
%21 = load i64, i64* %20
%22 = inttoptr i64 %21 to i64*
%23 = tail call i32 @foo(i64* %22, i8* %1, i8* %2)
store i64 0, i64* %20
ret i32 0
}