#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 */
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  TYPE_1__ *ipAddressChoice;
};
struct TYPE_4__ {
  scalar_t__ type;
};
typedef TYPE_2__ IPAddressFamily;
typedef int /*<<< orphan*/ IPAddrBlocks;

/* Variables and functions */
scalar_t__ IPAddressChoice_inherit;
int sk_IPAddressFamily_num(int /*<<< orphan*/ *);
TYPE_2__ *sk_IPAddressFamily_value(int /*<<< orphan*/ *, int);
int v3_addr_inherits(IPAddrBlocks *addr) {
  int i;
  if (addr == NULL)
    return 0;
  for (i = 0; i < sk_IPAddressFamily_num(addr); i++) {
    IPAddressFamily *f = sk_IPAddressFamily_value(addr, i);
    if (f->ipAddressChoice->type == IPAddressChoice_inherit)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<v3_addr_inherits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <v3_addr_inherits+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <v3_addr_inherits+0x96>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sk_IPAddressFamily_num@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11af <v3_addr_inherits+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <sk_IPAddressFamily_value@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%rax
jne    119c <v3_addr_inherits+0x7c>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <v3_addr_inherits+0x96>
jmp    11a1 <v3_addr_inherits+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <v3_addr_inherits+0x2a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v3_addr_inherits>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     116d <v3_addr_inherits+0x4d>
mov    %rdi,%rbx
call   1030 <sk_IPAddressFamily_num@plt>
test   %eax,%eax
jle    116d <v3_addr_inherits+0x4d>
xor    %ebp,%ebp
mov    0x2ea8(%rip),%r14
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <sk_IPAddressFamily_value@plt>
mov    (%rax),%rax
mov    (%rax),%rax
cmp    (%r14),%rax
je     1168 <v3_addr_inherits+0x48>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <sk_IPAddressFamily_num@plt>
cmp    %eax,%ebp
jl     1140 <v3_addr_inherits+0x20>
xor    %ebp,%ebp
jmp    116d <v3_addr_inherits+0x4d>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i64 }
@IPAddressChoice_inherit = global i64 0
define i32 @v3_addr_inherits(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.TYPE_5__*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %32
9: ; preds = %1
store i32 0, i32* %4
br label %10
10: ; preds = %28, %9
%11 = load i32, i32* %4
%12 = load i32*, i32** %3
%13 = call i32 @sk_IPAddressFamily_num(i32* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %31
15: ; preds = %10
%16 = load i32*, i32** %3
%17 = load i32, i32* %4
%18 = call %struct.TYPE_5__* @sk_IPAddressFamily_value(i32* %16, i32 %17)
store %struct.TYPE_5__* %18, %struct.TYPE_5__** %5
%19 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %19, i32 0, i32 0
%21 = load %struct.TYPE_4__*, %struct.TYPE_4__** %20
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load i64, i64* %22
%24 = load i64, i64* @IPAddressChoice_inherit
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %15
store i32 1, i32* %2
br label %32
27: ; preds = %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %10
31: ; preds = %10
store i32 0, i32* %2
br label %32
32: ; preds = %31, %26, %8
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i64 }
@IPAddressChoice_inherit = global i64 0
define i32 @v3_addr_inherits(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i32 @sk_IPAddressFamily_num(i32* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %9, label %19
6: ; preds = %9
%7 = tail call i32 @sk_IPAddressFamily_num(i32* %0)
%8 = icmp slt i32 %18, %7
br i1 %8, label %9, label %19
9: ; preds = %3, %6
%10 = phi i32 [ %18, %6 ], [ 0, %3 ]
%11 = tail call %struct.TYPE_5__* @sk_IPAddressFamily_value(i32* %0, i32 %10)
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i64 0, i32 0
%13 = load %struct.TYPE_4__*, %struct.TYPE_4__** %12
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i64 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @IPAddressChoice_inherit
%17 = icmp eq i64 %15, %16
%18 = add nuw nsw i32 %10, 1
br i1 %17, label %19, label %6
19: ; preds = %9, %6, %3, %1
%20 = phi i32 [ 0, %1 ], [ 0, %3 ], [ 1, %9 ], [ 0, %6 ]
ret i32 %20
}