#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct job_dump_data {
  int dummy;
};
struct component_loc {
  int dummy;
};

/* Variables and functions */
int check_component_address_data(struct component_loc *, int, char *, int);
int finalize_component_address_data(struct component_loc *, int, int);
int /*<<< orphan*/ free(struct component_loc *);
int get_dump_components(struct job_dump_data *, struct component_loc **, int *);
int /*<<< orphan*/ sort_cl_array(struct component_loc *, int);
int finalize_dump_address_data(struct job_dump_data *dump, char *name) {
  struct component_loc *cl;
  int num;
  int rc;
  rc = get_dump_components(dump, &cl, &num);
  if (rc)
    return rc;
  sort_cl_array(cl, num);
  rc = check_component_address_data(cl, num, name, 0x80000000LL);
  if (rc)
    goto out_free;
  rc = finalize_component_address_data(cl, num, 0x80000000LL);
out_free:
  free(cl);
  return rc;
}


x86 assembly (clang, -O0):
<finalize_dump_address_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <get_dump_components@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1189 <finalize_dump_address_data+0x39>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11df <finalize_dump_address_data+0x8f>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <sort_cl_array@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    $0x80000000,%ecx
call   1040 <check_component_address_data@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     11bc <finalize_dump_address_data+0x6c>
jmp    11d0 <finalize_dump_address_data+0x80>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x80000000,%edx
call   1070 <finalize_component_address_data@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finalize_dump_address_data>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <get_dump_components@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11b7 <finalize_dump_address_data+0x67>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1060 <sort_cl_array@plt>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %rbx,%rdx
mov    $0x80000000,%ecx
call   1040 <check_component_address_data@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11ad <finalize_dump_address_data+0x5d>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    $0x80000000,%edx
call   1070 <finalize_component_address_data@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.job_dump_data = type { i32 }
%struct.component_loc = type { i32 }
define i32 @finalize_dump_address_data(%struct.job_dump_data* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.job_dump_data*
%5 = alloca i8*
%6 = alloca %struct.component_loc*
%7 = alloca i32
%8 = alloca i32
store %struct.job_dump_data* %0, %struct.job_dump_data** %4
store i8* %1, i8** %5
%9 = load %struct.job_dump_data*, %struct.job_dump_data** %4
%10 = call i32 @get_dump_components(%struct.job_dump_data* %9, %struct.component_loc** %6, i32* %7)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* %8
store i32 %14, i32* %3
br label %34
15: ; preds = %2
%16 = load %struct.component_loc*, %struct.component_loc** %6
%17 = load i32, i32* %7
%18 = call i32 @sort_cl_array(%struct.component_loc* %16, i32 %17)
%19 = load %struct.component_loc*, %struct.component_loc** %6
%20 = load i32, i32* %7
%21 = load i8*, i8** %5
%22 = call i32 @check_component_address_data(%struct.component_loc* %19, i32 %20, i8* %21, i32 -2147483648)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %15
br label %30
26: ; preds = %15
%27 = load %struct.component_loc*, %struct.component_loc** %6
%28 = load i32, i32* %7
%29 = call i32 @finalize_component_address_data(%struct.component_loc* %27, i32 %28, i32 -2147483648)
store i32 %29, i32* %8
br label %30
30: ; preds = %26, %25
%31 = load %struct.component_loc*, %struct.component_loc** %6
%32 = call i32 @free(%struct.component_loc* %31)
%33 = load i32, i32* %8
store i32 %33, i32* %3
br label %34
34: ; preds = %30, %13
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
%struct.job_dump_data = type { i32 }
%struct.component_loc = type { i32 }
define i32 @finalize_dump_address_data(%struct.job_dump_data* %0, i8* %1) {
%3 = alloca %struct.component_loc*
%4 = alloca i32
%5 = bitcast %struct.component_loc** %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @get_dump_components(%struct.job_dump_data* %0, %struct.component_loc** %3, i32* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %2
%10 = load %struct.component_loc*, %struct.component_loc** %3
%11 = load i32, i32* %4
%12 = call i32 @sort_cl_array(%struct.component_loc* %10, i32 %11)
%13 = load %struct.component_loc*, %struct.component_loc** %3
%14 = load i32, i32* %4
%15 = call i32 @check_component_address_data(%struct.component_loc* %13, i32 %14, i8* %1, i32 -2147483648)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %9
%18 = load %struct.component_loc*, %struct.component_loc** %3
%19 = load i32, i32* %4
%20 = call i32 @finalize_component_address_data(%struct.component_loc* %18, i32 %19, i32 -2147483648)
br label %21
21: ; preds = %9, %17
%22 = phi i32 [ %15, %9 ], [ %20, %17 ]
%23 = load %struct.component_loc*, %struct.component_loc** %3
%24 = call i32 @free(%struct.component_loc* %23)
br label %25
25: ; preds = %2, %21
%26 = phi i32 [ %22, %21 ], [ %7, %2 ]
ret i32 %26
}