void gen_contours(p_edges, z_level, xx_min, xx_max, yy_min,
                  yy_max) struct edge_struct *p_edges;
double z_level, xx_min, xx_max, yy_min, yy_max;
{
  int num_active, contr_kind;
  struct cntr_struct *p_cntr;
  num_active = update_all_edges(p_edges, z_level);
  contr_kind = 1;
  while (num_active > 0) {
    p_cntr = gen_one_contour(p_edges, z_level, &contr_kind, &num_active);
    put_contour(p_cntr, z_level, xx_min, xx_max, yy_min, yy_max, contr_kind);
  }
}


x86 assembly (clang, -O0):
<gen_contours>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1040 <update_all_edges@plt>
mov    %eax,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    11c3 <gen_contours+0x93>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    -0x38(%rbp),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x1,%al
call   1030 <gen_one_contour@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
mov    -0x38(%rbp),%esi
mov    $0x5,%al
call   1050 <put_contour@plt>
jmp    116f <gen_contours+0x3f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_contours>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1040 <update_all_edges@plt>
mov    %eax,0x4(%rsp)
movl   $0x1,(%rsp)
test   %eax,%eax
jle    11c8 <gen_contours+0x98>
mov    %rsp,%r14
lea    0x4(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x1,%al
call   1030 <gen_one_contour@plt>
movslq %eax,%rdi
mov    (%rsp),%esi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
mov    $0x5,%al
call   1050 <put_contour@plt>
cmpl   $0x0,0x4(%rsp)
jg     1180 <gen_contours+0x50>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.edge_struct = type opaque
%struct.cntr_struct = type opaque
define void @gen_contours(%struct.edge_struct* %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca %struct.edge_struct*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.cntr_struct*
store %struct.edge_struct* %0, %struct.edge_struct** %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%16 = load %struct.edge_struct*, %struct.edge_struct** %7
%17 = load double, double* %8
%18 = call i32 (%struct.edge_struct*, double, ...) bitcast (i32 (...)* @update_all_edges to i32 (%struct.edge_struct*, double, ...)*)(%struct.edge_struct* %16, double %17)
store i32 %18, i32* %13
store i32 1, i32* %14
br label %19
19: ; preds = %22, %6
%20 = load i32, i32* %13
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load %struct.edge_struct*, %struct.edge_struct** %7
%24 = load double, double* %8
%25 = call i32 (%struct.edge_struct*, double, i32*, i32*, ...) bitcast (i32 (...)* @gen_one_contour to i32 (%struct.edge_struct*, double, i32*, i32*, ...)*)(%struct.edge_struct* %23, double %24, i32* %14, i32* %13)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to %struct.cntr_struct*
store %struct.cntr_struct* %27, %struct.cntr_struct** %15
%28 = load %struct.cntr_struct*, %struct.cntr_struct** %15
%29 = load double, double* %8
%30 = load double, double* %9
%31 = load double, double* %10
%32 = load double, double* %11
%33 = load double, double* %12
%34 = load i32, i32* %14
%35 = call i32 (%struct.cntr_struct*, double, double, double, double, double, i32, ...) bitcast (i32 (...)* @put_contour to i32 (%struct.cntr_struct*, double, double, double, double, double, i32, ...)*)(%struct.cntr_struct* %28, double %29, double %30, double %31, double %32, double %33, i32 %34)
br label %19
36: ; preds = %19
ret void
}

LLVM IR (-O2):
%struct.edge_struct = type opaque
%struct.cntr_struct = type opaque
define void @gen_contours(%struct.edge_struct* %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %7 to i8*
%10 = bitcast i32* %8 to i8*
%11 = tail call i32 (%struct.edge_struct*, double, ...) bitcast (i32 (...)* @update_all_edges to i32 (%struct.edge_struct*, double, ...)*)(%struct.edge_struct* %0, double %1)
store i32 %11, i32* %7
store i32 1, i32* %8
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %6, %13
%14 = call i32 (%struct.edge_struct*, double, i32*, i32*, ...) bitcast (i32 (...)* @gen_one_contour to i32 (%struct.edge_struct*, double, i32*, i32*, ...)*)(%struct.edge_struct* %0, double %1, i32* %8, i32* %7)
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to %struct.cntr_struct*
%17 = load i32, i32* %8
%18 = call i32 (%struct.cntr_struct*, double, double, double, double, double, i32, ...) bitcast (i32 (...)* @put_contour to i32 (%struct.cntr_struct*, double, double, double, double, double, i32, ...)*)(%struct.cntr_struct* %16, double %1, double %2, double %3, double %4, double %5, i32 %17)
%19 = load i32, i32* %7
%20 = icmp sgt i32 %19, 0
br i1 %20, label %13, label %21
21: ; preds = %13, %6
ret void
}