#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 zrpc_prefix {
  int dummy;
};
struct zrpc_ipv6_prefix {
  int dummy;
};
struct zrpc_ipv4_prefix {
  int dummy;
};

/* Variables and functions */
int zrpc_util_str2ipv4_prefix(char const *, struct zrpc_ipv4_prefix *);
int zrpc_util_str2ipv6_prefix(char const *, struct zrpc_ipv6_prefix *);
int zrpc_util_str2_prefix(const char *buf, struct zrpc_prefix *prefix_p) {
  struct zrpc_ipv6_prefix *ipv6_p;
  struct zrpc_ipv4_prefix *ipv4_p;
  int ret;
  ipv4_p = (struct zrpc_ipv4_prefix *)prefix_p;
  ret = zrpc_util_str2ipv4_prefix(buf, ipv4_p);
  if (ret)
    return ret;
  ipv6_p = (struct zrpc_ipv6_prefix *)prefix_p;
  ret = zrpc_util_str2ipv6_prefix(buf, ipv6_p);
  return ret;
}


x86 assembly (clang, -O0):
<zrpc_util_str2_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <zrpc_util_str2ipv4_prefix@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     115d <zrpc_util_str2_prefix+0x3d>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <zrpc_util_str2_prefix+0x5b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <zrpc_util_str2ipv6_prefix@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zrpc_util_str2_prefix>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <zrpc_util_str2ipv4_prefix@plt>
test   %eax,%eax
je     113b <zrpc_util_str2_prefix+0x1b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <zrpc_util_str2ipv6_prefix@plt>

LLVM IR (-O0):
%struct.zrpc_prefix = type { i32 }
%struct.zrpc_ipv6_prefix = type { i32 }
%struct.zrpc_ipv4_prefix = type { i32 }
define i32 @zrpc_util_str2_prefix(i8* %0, %struct.zrpc_prefix* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.zrpc_prefix*
%6 = alloca %struct.zrpc_ipv6_prefix*
%7 = alloca %struct.zrpc_ipv4_prefix*
%8 = alloca i32
store i8* %0, i8** %4
store %struct.zrpc_prefix* %1, %struct.zrpc_prefix** %5
%9 = load %struct.zrpc_prefix*, %struct.zrpc_prefix** %5
%10 = bitcast %struct.zrpc_prefix* %9 to %struct.zrpc_ipv4_prefix*
store %struct.zrpc_ipv4_prefix* %10, %struct.zrpc_ipv4_prefix** %7
%11 = load i8*, i8** %4
%12 = load %struct.zrpc_ipv4_prefix*, %struct.zrpc_ipv4_prefix** %7
%13 = call i32 @zrpc_util_str2ipv4_prefix(i8* %11, %struct.zrpc_ipv4_prefix* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = load i32, i32* %8
store i32 %17, i32* %3
br label %25
18: ; preds = %2
%19 = load %struct.zrpc_prefix*, %struct.zrpc_prefix** %5
%20 = bitcast %struct.zrpc_prefix* %19 to %struct.zrpc_ipv6_prefix*
store %struct.zrpc_ipv6_prefix* %20, %struct.zrpc_ipv6_prefix** %6
%21 = load i8*, i8** %4
%22 = load %struct.zrpc_ipv6_prefix*, %struct.zrpc_ipv6_prefix** %6
%23 = call i32 @zrpc_util_str2ipv6_prefix(i8* %21, %struct.zrpc_ipv6_prefix* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
store i32 %24, i32* %3
br label %25
25: ; preds = %18, %16
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.zrpc_prefix = type { i32 }
%struct.zrpc_ipv4_prefix = type { i32 }
%struct.zrpc_ipv6_prefix = type { i32 }
define i32 @zrpc_util_str2_prefix(i8* %0, %struct.zrpc_prefix* %1) {
%3 = bitcast %struct.zrpc_prefix* %1 to %struct.zrpc_ipv4_prefix*
%4 = tail call i32 @zrpc_util_str2ipv4_prefix(i8* %0, %struct.zrpc_ipv4_prefix* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = bitcast %struct.zrpc_prefix* %1 to %struct.zrpc_ipv6_prefix*
%8 = tail call i32 @zrpc_util_str2ipv6_prefix(i8* %0, %struct.zrpc_ipv6_prefix* %7)
br label %9
9: ; preds = %2, %6
%10 = phi i32 [ %8, %6 ], [ %4, %2 ]
ret i32 %10
}