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

/* Variables and functions */
int /*<<< orphan*/ GEN_IPADD;
scalar_t__ a2i_ipadd(unsigned char *, char const *);
int do_x509_check(int /*<<< orphan*/ *, char *, size_t, unsigned int,
                  int /*<<< orphan*/, int /*<<< orphan*/ *);
int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags) {
  unsigned char ipout[16];
  size_t iplen;
  if (ipasc == NULL)
    return -2;
  iplen = (size_t)a2i_ipadd(ipout, ipasc);
  if (iplen == 0)
    return -2;
  return do_x509_check(x, (char *)ipout, iplen, flags, GEN_IPADD, NULL);
}


x86 assembly (clang, -O0):
<X509_check_ip_asc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114a <X509_check_ip_asc+0x2a>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1198 <X509_check_ip_asc+0x78>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <a2i_ipadd@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1172 <X509_check_ip_asc+0x52>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1198 <X509_check_ip_asc+0x78>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    0x2e60(%rip),%rax
mov    (%rax),%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1030 <do_x509_check@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_check_ip_asc>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xfffffffe,%ebp
test   %rsi,%rsi
je     1165 <X509_check_ip_asc+0x45>
mov    %edx,%r14d
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1040 <a2i_ipadd@plt>
test   %rax,%rax
je     1165 <X509_check_ip_asc+0x45>
mov    0x2e9c(%rip),%rcx
mov    (%rcx),%r8d
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
mov    %r14d,%ecx
xor    %r9d,%r9d
call   1030 <do_x509_check@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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