build_pyr(image, x_size, y_size, num_levels, lo_filter, hi_filter,
          filter_size) int x_size,
    y_size, num_levels, filter_size;
float *image, *lo_filter, *hi_filter;
{
  int x_level, y_level, level;
  for (level = 0, x_level = x_size, y_level = y_size; level < num_levels;
       level++, x_level /= 2, y_level /= 2)
    build_level(image, x_level, y_level, lo_filter, hi_filter, filter_size,
                image);
}


x86 assembly (clang, -O0):
<build_pyr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119e <build_pyr+0x8e>
mov    -0x10(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    -0x10(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <build_level@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
jmp    1143 <build_pyr+0x33>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_pyr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %ecx,%ecx
jle    1186 <build_pyr+0x76>
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r12
mov    %esi,%r13d
mov    %edx,%ebx
mov    %r8,0x10(%rsp)
mov    %r9,0x8(%rsp)
nopl   0x0(%rax)
mov    %r12,(%rsp)
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r8,%rcx
mov    %r9,%r8
mov    0x50(%rsp),%r9d
xor    %eax,%eax
call   1030 <build_level@plt>
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
shr    $0x1f,%r13d
add    %r14d,%r13d
sar    %r13d
shr    $0x1f,%ebx
add    %r15d,%ebx
sar    %ebx
mov    %ebx,%r15d
mov    %r13d,%r14d
add    $0xffffffff,%ebp
jne    1140 <build_pyr+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @build_pyr(float* %0, i32 %1, i32 %2, i32 %3, float* %4, float* %5, i32 %6) {
%8 = alloca i32
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float*
%14 = alloca float*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store float* %0, float** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store float* %4, float** %13
store float* %5, float** %14
store i32 %6, i32* %15
store i32 0, i32* %18
%19 = load i32, i32* %10
store i32 %19, i32* %16
%20 = load i32, i32* %11
store i32 %20, i32* %17
br label %21
21: ; preds = %34, %7
%22 = load i32, i32* %18
%23 = load i32, i32* %12
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %41
25: ; preds = %21
%26 = load float*, float** %9
%27 = load i32, i32* %16
%28 = load i32, i32* %17
%29 = load float*, float** %13
%30 = load float*, float** %14
%31 = load i32, i32* %15
%32 = load float*, float** %9
%33 = call i32 (float*, i32, i32, float*, float*, i32, float*, ...) bitcast (i32 (...)* @build_level to i32 (float*, i32, i32, float*, float*, i32, float*, ...)*)(float* %26, i32 %27, i32 %28, float* %29, float* %30, i32 %31, float* %32)
br label %34
34: ; preds = %25
%35 = load i32, i32* %18
%36 = add nsw i32 %35, 1
store i32 %36, i32* %18
%37 = load i32, i32* %16
%38 = sdiv i32 %37, 2
store i32 %38, i32* %16
%39 = load i32, i32* %17
%40 = sdiv i32 %39, 2
store i32 %40, i32* %17
br label %21
41: ; preds = %21
%42 = load i32, i32* %8
ret i32 %42
}

LLVM IR (-O2):
define i32 @build_pyr(float* %0, i32 %1, i32 %2, i32 %3, float* %4, float* %5, i32 %6) {
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %18
9: ; preds = %7, %9
%10 = phi i32 [ %14, %9 ], [ 0, %7 ]
%11 = phi i32 [ %16, %9 ], [ %2, %7 ]
%12 = phi i32 [ %15, %9 ], [ %1, %7 ]
%13 = tail call i32 (float*, i32, i32, float*, float*, i32, float*, ...) bitcast (i32 (...)* @build_level to i32 (float*, i32, i32, float*, float*, i32, float*, ...)*)(float* %0, i32 %12, i32 %11, float* %4, float* %5, i32 %6, float* %0)
%14 = add nuw nsw i32 %10, 1
%15 = sdiv i32 %12, 2
%16 = sdiv i32 %11, 2
%17 = icmp eq i32 %14, %3
br i1 %17, label %18, label %9
18: ; preds = %9, %7
ret i32 undef
}