void adsf_assert_consistency(int *t, int n) {
  assert(n > 0);
  assert(t);
  for (int i = 0; i < n; i++) {
    assert(t[i] >= 0);
    assert(t[i] < n);
  }
}


x86 assembly (clang, -O0):
<adsf_assert_consistency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <assert@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1196 <adsf_assert_consistency+0x86>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
setge  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <adsf_assert_consistency+0x34>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adsf_assert_consistency>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %edi,%edi
test   %esi,%esi
setg   %dil
xor    %eax,%eax
call   1030 <assert@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <assert@plt>
test   %r14d,%r14d
jle    1169 <adsf_assert_consistency+0x59>
mov    %r14d,%r15d
xor    %ebp,%ebp
mov    (%rbx,%rbp,4),%edi
not    %edi
shr    $0x1f,%edi
xor    %eax,%eax
call   1030 <assert@plt>
xor    %edi,%edi
cmp    %r14d,(%rbx,%rbp,4)
setl   %dil
xor    %eax,%eax
call   1030 <assert@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1140 <adsf_assert_consistency+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @adsf_assert_consistency(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %8)
%10 = load i32*, i32** %3
%11 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %10)
store i32 0, i32* %5
br label %12
12: ; preds = %34, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = icmp sge i32 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %23)
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
%32 = zext i1 %31 to i32
%33 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %32)
br label %34
34: ; preds = %16
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %12
37: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @adsf_assert_consistency(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %4)
%6 = tail call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %0)
br i1 %3, label %7, label %9
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %10
9: ; preds = %10, %2
ret void
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %21, %10 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = xor i32 %13, -1
%15 = lshr i32 %14, 31
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %15)
%17 = load i32, i32* %12
%18 = icmp slt i32 %17, %1
%19 = zext i1 %18 to i32
%20 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %19)
%21 = add nuw nsw i64 %11, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %9, label %10
}