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


x86 assembly (clang, -O0):
<test_zeroed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x50,%edi
mov    $0x8000,%esi
mov    $0x0,%al
call   1050 <kmalloc@plt>
cltq
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115f <test_zeroed+0x2f>
jmp    11a2 <test_zeroed+0x72>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1199 <test_zeroed+0x69>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <foo@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <test_zeroed+0x36>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_zeroed>:
push   %rbx
mov    $0x50,%edi
mov    $0x8000,%esi
xor    %eax,%eax
call   1050 <kmalloc@plt>
test   %eax,%eax
je     11bf <test_zeroed+0x8f>
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_zeroed() {
%1 = alloca %struct.test**
%2 = alloca %struct.test*
%3 = alloca i32
%4 = call i32 (i64, i32, ...) bitcast (i32 (...)* @kmalloc to i32 (i64, i32, ...)*)(i64 80, i32 32768)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to %struct.test**
store %struct.test** %6, %struct.test*** %1
%7 = load %struct.test**, %struct.test*** %1
%8 = icmp eq %struct.test** %7, null
br i1 %8, label %9, label %10
9: ; preds = %0
br label %28
10: ; preds = %0
store i32 0, i32* %3
br label %11
11: ; preds = %22, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = load %struct.test**, %struct.test*** %1
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds %struct.test*, %struct.test** %15, i64 %17
%19 = load %struct.test*, %struct.test** %18
store %struct.test* %19, %struct.test** %2
%20 = load %struct.test*, %struct.test** %2
%21 = call i32 (%struct.test*, ...) bitcast (i32 (...)* @foo to i32 (%struct.test*, ...)*)(%struct.test* %20)
br label %22
22: ; preds = %14
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %11
25: ; preds = %11
%26 = load %struct.test**, %struct.test*** %1
%27 = bitcast %struct.test** %26 to i8*
br label %28
28: ; preds = %25, %9
ret void
}

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