#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 */
typedef int ssize_t;

/* Variables and functions */
int parse_ipv4addr(char const *, char const **);
int parse_ipv6addr(char const *, char const **);
ssize_t parse_ipaddr(const char *buffer, const char **error) {
  if (parse_ipv4addr(buffer, error) == 1)
    return 1;
  if (parse_ipv6addr(buffer, error) == 1)
    return 1;
  *error = "Invalid syntax for IP address";
  return 0;
}


x86 assembly (clang, -O0):
<parse_ipaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <parse_ipv4addr@plt>
cmp    $0x1,%eax
jne    1152 <parse_ipaddr+0x32>
movl   $0x1,-0x4(%rbp)
jmp    1189 <parse_ipaddr+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <parse_ipv6addr@plt>
cmp    $0x1,%eax
jne    1174 <parse_ipaddr+0x54>
movl   $0x1,-0x4(%rbp)
jmp    1189 <parse_ipaddr+0x69>
mov    -0x18(%rbp),%rax
lea    0xe81(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_ipaddr>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <parse_ipv4addr@plt>
mov    $0x1,%r14d
cmp    $0x1,%eax
je     1157 <parse_ipaddr+0x37>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <parse_ipv6addr@plt>
cmp    $0x1,%eax
je     1157 <parse_ipaddr+0x37>
lea    0xeaf(%rip),%rax
mov    %rax,(%rbx)
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Invalid syntax for IP address\00"
define i32 @parse_ipaddr(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%6 = load i8*, i8** %4
%7 = load i8**, i8*** %5
%8 = call i32 @parse_ipv4addr(i8* %6, i8** %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %19
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8**, i8*** %5
%14 = call i32 @parse_ipv6addr(i8* %12, i8** %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %3
br label %19
17: ; preds = %11
%18 = load i8**, i8*** %5
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8** %18
store i32 0, i32* %3
br label %19
19: ; preds = %17, %16, %10
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [30 x i8] c"Invalid syntax for IP address\00"
define i32 @parse_ipaddr(i8* %0, i8** %1) {
%3 = tail call i32 @parse_ipv4addr(i8* %0, i8** %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @parse_ipv6addr(i8* %0, i8** %1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %9, label %8
8: ; preds = %5
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8** %1
br label %9
9: ; preds = %5, %2, %8
%10 = phi i32 [ 0, %8 ], [ 1, %2 ], [ 1, %5 ]
ret i32 %10
}