#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 /*<<< orphan*/ ASN1_OCTET_STRING;

/* Variables and functions */
int /*<<< orphan*/ ASN1_OCTET_STRING_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_OCTET_STRING_new();
int /*<<< orphan*/ ASN1_OCTET_STRING_set(int /*<<< orphan*/ *, unsigned char *,
                                         int);
int a2i_ipadd(unsigned char *, char const *);
ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc) {
  unsigned char ipout[16];
  ASN1_OCTET_STRING *ret;
  int iplen;
  iplen = a2i_ipadd(ipout, ipasc);
  if (!iplen)
    return NULL;
  ret = ASN1_OCTET_STRING_new();
  if (!ret)
    return NULL;
  if (!ASN1_OCTET_STRING_set(ret, ipout, iplen)) {
    ASN1_OCTET_STRING_free(ret);
    return NULL;
  }
  return ret;
}


x86 assembly (clang, -O0):
<a2i_IPADDRESS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <a2i_ipadd@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1173 <a2i_IPADDRESS+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11cd <a2i_IPADDRESS+0x8d>
mov    $0x0,%al
call   1030 <ASN1_OCTET_STRING_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1196 <a2i_IPADDRESS+0x56>
movq   $0x0,-0x8(%rbp)
jmp    11cd <a2i_IPADDRESS+0x8d>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1050 <ASN1_OCTET_STRING_set@plt>
cmp    $0x0,%eax
jne    11c5 <a2i_IPADDRESS+0x85>
mov    -0x28(%rbp),%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11cd <a2i_IPADDRESS+0x8d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a2i_IPADDRESS>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1060 <a2i_ipadd@plt>
test   %eax,%eax
je     117f <a2i_IPADDRESS+0x3f>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <ASN1_OCTET_STRING_new@plt>
test   %rax,%rax
je     117f <a2i_IPADDRESS+0x3f>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
mov    %ebp,%edx
call   1050 <ASN1_OCTET_STRING_set@plt>
test   %eax,%eax
jne    1181 <a2i_IPADDRESS+0x41>
mov    %rbx,%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32* @a2i_IPADDRESS(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca [16 x i8]
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @a2i_ipadd(i8* %7, i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %1
store i32* null, i32** %2
br label %29
13: ; preds = %1
%14 = call i32* (...) @ASN1_OCTET_STRING_new()
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %13
store i32* null, i32** %2
br label %29
18: ; preds = %13
%19 = load i32*, i32** %5
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%21 = load i32, i32* %6
%22 = call i32 @ASN1_OCTET_STRING_set(i32* %19, i8* %20, i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %18
%25 = load i32*, i32** %5
%26 = call i32 @ASN1_OCTET_STRING_free(i32* %25)
store i32* null, i32** %2
br label %29
27: ; preds = %18
%28 = load i32*, i32** %5
store i32* %28, i32** %2
br label %29
29: ; preds = %27, %24, %17, %12
%30 = load i32*, i32** %2
ret i32* %30
}

LLVM IR (-O2):
define i32* @a2i_IPADDRESS(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = call i32 @a2i_ipadd(i8* %3, i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = call i32* (...) @ASN1_OCTET_STRING_new()
%8 = icmp eq i32* %7, null
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = call i32 @ASN1_OCTET_STRING_set(i32* %7, i8* %3, i32 %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @ASN1_OCTET_STRING_free(i32* %7)
br label %14
14: ; preds = %9, %6, %1, %12
%15 = phi i32* [ null, %12 ], [ null, %1 ], [ null, %6 ], [ %7, %9 ]
ret i32* %15
}