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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ inet_addr(char const *);
int /*<<< orphan*/ is_ipv4_global_unicast(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void check(const char *str, bool glob) {
  uint32_t ip = inet_addr(str);
  if (!!is_ipv4_global_unicast(ip) != glob) {
    fprintf(stderr, "Error with %s\n", str);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <is_ipv4_global_unicast@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    -0xc(%rbp),%eax
je     119e <check+0x5e>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe71(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <inet_addr@plt>
mov    %eax,%edi
call   1030 <is_ipv4_global_unicast@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
cmp    %ebp,%ecx
jne    1166 <check+0x26>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Error with %s\0A\00"
define void @check(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @inet_addr(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = call i32 @is_ipv4_global_unicast(i32 %8)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = load i32, i32* %4
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %3
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Error with %s\0A\00"
define void @check(i8* %0, i32 %1) {
%3 = tail call i32 @inet_addr(i8* %0)
%4 = tail call i32 @is_ipv4_global_unicast(i32 %3)
%5 = icmp ne i32 %4, 0
%6 = zext i1 %5 to i32
%7 = icmp eq i32 %6, %1
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
ret void
}