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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ INET6_ADDRSTRLEN;
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strsep(char **, char *);
int conv_from_cidr_fmt(const char *cidr_address, char **net_addr,
                       char **net_mask_bits) {
  char *buf = NULL;
  char *buf_ptr = NULL;
  buf = (char *)malloc(INET6_ADDRSTRLEN);
  buf_ptr = buf;
  strcpy(buf, cidr_address);
  (*net_addr) = strsep(&buf, "/");
  (*net_mask_bits) = strsep(&buf, "/");
  if ((*net_addr) == NULL || (*net_mask_bits) == NULL || buf != NULL) {
    free(buf_ptr);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<conv_from_cidr_fmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x28(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <strsep@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x28(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1060 <strsep@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e6 <conv_from_cidr_fmt+0xa6>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e6 <conv_from_cidr_fmt+0xa6>
cmpq   $0x0,-0x28(%rbp)
je     1200 <conv_from_cidr_fmt+0xc0>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    120c <conv_from_cidr_fmt+0xcc>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_from_cidr_fmt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0xe82(%rip),%r12
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <strsep@plt>
mov    %rax,(%r14)
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <strsep@plt>
mov    %rax,(%r15)
cmpq   $0x0,(%r14)
je     11bb <conv_from_cidr_fmt+0x7b>
test   %rax,%rax
je     11bb <conv_from_cidr_fmt+0x7b>
cmpq   $0x0,0x8(%rsp)
jne    11bb <conv_from_cidr_fmt+0x7b>
mov    0x2e17(%rip),%rax
jmp    11ca <conv_from_cidr_fmt+0x8a>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@INET6_ADDRSTRLEN = global i32 0
@.str = [2 x i8] c"/\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @conv_from_cidr_fmt(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8* null, i8** %8
store i8* null, i8** %9
%10 = load i32, i32* @INET6_ADDRSTRLEN
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %8
%13 = load i8*, i8** %8
store i8* %13, i8** %9
%14 = load i8*, i8** %8
%15 = load i8*, i8** %5
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = call i8* @strsep(i8** %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = load i8**, i8*** %6
store i8* %17, i8** %18
%19 = call i8* @strsep(i8** %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i8**, i8*** %7
store i8* %19, i8** %20
%21 = load i8**, i8*** %6
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %31, label %24
24: ; preds = %3
%25 = load i8**, i8*** %7
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %35
31: ; preds = %28, %24, %3
%32 = load i8*, i8** %9
%33 = call i32 @free(i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %4
br label %37
35: ; preds = %28
%36 = load i32, i32* @EXIT_SUCCESS
store i32 %36, i32* %4
br label %37
37: ; preds = %35, %31
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@INET6_ADDRSTRLEN = global i32 0
@.str = [2 x i8] c"/\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @conv_from_cidr_fmt(i8* %0, i8** nocapture %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = load i32, i32* @INET6_ADDRSTRLEN
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %4
%9 = tail call i32 @strcpy(i8* %8, i8* %0)
%10 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %1
%11 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %2
%12 = load i8*, i8** %1
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %3
%15 = icmp eq i8* %11, null
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %21
19: ; preds = %14, %3
%20 = call i32 @free(i8* %8)
br label %21
21: ; preds = %14, %19
%22 = phi i32* [ @EXIT_FAILURE, %19 ], [ @EXIT_SUCCESS, %14 ]
%23 = load i32, i32* %22
ret i32 %23
}