void test_indeterminate(int flags) {
  struct test **list, *t;
  int i;
  list = kmalloc(sizeof(*list) * 10, flags);
  if (list == ((void *)0))
    return;
  for (i = 0; i < 10; i++) {
    t = list[i];
    foo(t);
  }
  free(list);
}


x86 assembly (clang, -O0):
<test_indeterminate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x50,%edi
mov    $0x0,%al
call   1050 <kmalloc@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1160 <test_indeterminate+0x30>
jmp    11a3 <test_indeterminate+0x73>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    119a <test_indeterminate+0x6a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1040 <foo@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <test_indeterminate+0x37>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_indeterminate>:
push   %rbx
mov    %edi,%esi
mov    $0x50,%edi
xor    %eax,%eax
call   1050 <kmalloc@plt>
test   %eax,%eax
je     11bc <test_indeterminate+0x8c>
movslq %eax,%rbx
mov    (%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x8(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x10(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x18(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x20(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x28(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x30(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x38(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x40(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    0x48(%rbx),%rdi
xor    %eax,%eax
call   1040 <foo@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>
pop    %rbx
ret

LLVM IR (-O0):
%struct.test = type opaque
define void @test_indeterminate(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.test**
%4 = alloca %struct.test*
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 (i64, i32, ...) bitcast (i32 (...)* @kmalloc to i32 (i64, i32, ...)*)(i64 80, i32 %6)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to %struct.test**
store %struct.test** %9, %struct.test*** %3
%10 = load %struct.test**, %struct.test*** %3
%11 = icmp eq %struct.test** %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
br label %31
13: ; preds = %1
store i32 0, i32* %5
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load %struct.test**, %struct.test*** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds %struct.test*, %struct.test** %18, i64 %20
%22 = load %struct.test*, %struct.test** %21
store %struct.test* %22, %struct.test** %4
%23 = load %struct.test*, %struct.test** %4
%24 = call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %23)
br label %25
25: ; preds = %17
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %14
28: ; preds = %14
%29 = load %struct.test**, %struct.test*** %3
%30 = bitcast %struct.test** %29 to i8*
br label %31
31: ; preds = %28, %12
ret void
}

LLVM IR (-O2):
%struct.test = type opaque
define void @test_indeterminate(i32 %0) {
%2 = tail call i32 (i64, i32, ...) bitcast (i32 (...)* @kmalloc to i32 (i64, i32, ...)*)(i64 80, i32 %0)
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to %struct.test**
%5 = icmp eq i32 %2, 0
br i1 %5, label %37, label %6
6: ; preds = %1
%7 = load %struct.test*, %struct.test** %4
%8 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %7)
%9 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 1
%10 = load %struct.test*, %struct.test** %9
%11 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %10)
%12 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 2
%13 = load %struct.test*, %struct.test** %12
%14 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %13)
%15 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 3
%16 = load %struct.test*, %struct.test** %15
%17 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %16)
%18 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 4
%19 = load %struct.test*, %struct.test** %18
%20 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %19)
%21 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 5
%22 = load %struct.test*, %struct.test** %21
%23 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %22)
%24 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 6
%25 = load %struct.test*, %struct.test** %24
%26 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %25)
%27 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 7
%28 = load %struct.test*, %struct.test** %27
%29 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %28)
%30 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 8
%31 = load %struct.test*, %struct.test** %30
%32 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %31)
%33 = getelementptr inbounds %struct.test*, %struct.test** %4, i64 9
%34 = load %struct.test*, %struct.test** %33
%35 = tail call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %34)
%36 = inttoptr i64 %3 to i8*
tail call void @free(i8* %36)
br label %37
37: ; preds = %1, %6
ret void
}