int 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);
  return 1;
}


x86 assembly (clang, -O0):
<build_pyr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119e <build_pyr+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    -0x8(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <build_level@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
jmp    1143 <build_pyr+0x33>
mov    $0x1,%eax
add    $0x40,%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>
mov    $0x1,%eax
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 float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store float* %0, float** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store float* %4, float** %12
store float* %5, float** %13
store i32 %6, i32* %14
store i32 0, i32* %17
%18 = load i32, i32* %9
store i32 %18, i32* %15
%19 = load i32, i32* %10
store i32 %19, i32* %16
br label %20
20: ; preds = %33, %7
%21 = load i32, i32* %17
%22 = load i32, i32* %11
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load float*, float** %8
%26 = load i32, i32* %15
%27 = load i32, i32* %16
%28 = load float*, float** %12
%29 = load float*, float** %13
%30 = load i32, i32* %14
%31 = load float*, float** %8
%32 = call i32 (float*, i32, i32, float*, float*, i32, float*, ...) bitcast (i32 (...)* @build_level to i32 (float*, i32, i32, float*, float*, i32, float*, ...)*)(float* %25, i32 %26, i32 %27, float* %28, float* %29, i32 %30, float* %31)
br label %33
33: ; preds = %24
%34 = load i32, i32* %17
%35 = add nsw i32 %34, 1
store i32 %35, i32* %17
%36 = load i32, i32* %15
%37 = sdiv i32 %36, 2
store i32 %37, i32* %15
%38 = load i32, i32* %16
%39 = sdiv i32 %38, 2
store i32 %39, i32* %16
br label %20
40: ; preds = %20
ret i32 1
}

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 1
}