#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 /*<<< orphan*/ memset(char *, char, int);
int sscanf(char const *, char *, char *);
int validate_ipv4net(char const *);
int validate_ipv4net_negate(const char *str) {
  if (!str)
    return 0;
  char ipv4net[18];
  memset(ipv4net, '\0', 18);
  if (sscanf(str, "!%18s", ipv4net) != 1)
    return validate_ipv4net(str);
  return validate_ipv4net(ipv4net);
}


x86 assembly (clang, -O0):
<validate_ipv4net_negate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <validate_ipv4net_negate+0x23>
movl   $0x0,-0x4(%rbp)
jmp    119d <validate_ipv4net_negate+0x6d>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe8e(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1191 <validate_ipv4net_negate+0x61>
mov    -0x10(%rbp),%rdi
call   1030 <validate_ipv4net@plt>
mov    %eax,-0x4(%rbp)
jmp    119d <validate_ipv4net_negate+0x6d>
lea    -0x30(%rbp),%rdi
call   1030 <validate_ipv4net@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_ipv4net_negate>:
test   %rdi,%rdi
je     117a <validate_ipv4net_negate+0x4a>
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
cmove  %r14,%rbx
mov    %rbx,%rdi
call   1030 <validate_ipv4net@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"!%18s\00"
define i32 @validate_ipv4net_negate(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [18 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %21
8: ; preds = %1
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 18)
%11 = load i8*, i8** %3
%12 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%13 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = call i32 @validate_ipv4net(i8* %16)
store i32 %17, i32* %2
br label %21
18: ; preds = %8
%19 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%20 = call i32 @validate_ipv4net(i8* %19)
store i32 %20, i32* %2
br label %21
21: ; preds = %18, %15, %7
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"!%18s\00"
define i32 @validate_ipv4net_negate(i8* %0) {
%2 = alloca [18 x i8]
%3 = icmp eq i8* %0, null
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i8 signext 0, i32 18)
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* %5, i8* %0
%10 = call i32 @validate_ipv4net(i8* %9)
br label %11
11: ; preds = %1, %4
%12 = phi i32 [ %10, %4 ], [ 0, %1 ]
ret i32 %12
}