#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 is_ipv4_global_unicast(int /*<<< orphan*/);
int is_ipv4_private_unicast(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void check(const char *str, bool glob, bool priv) {
  uint32_t ip = inet_addr(str);
  if (is_ipv4_global_unicast(ip) != glob) {
    fprintf(stderr, "Error with %s\n", str);
    exit(1);
  }
  if (is_ipv4_private_unicast(ip) != priv) {
    fprintf(stderr, "Error with %s\n", str);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <is_ipv4_global_unicast@plt>
cmp    -0xc(%rbp),%eax
je     11a2 <check+0x52>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe6d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
call   1060 <is_ipv4_private_unicast@plt>
cmp    -0x10(%rbp),%eax
je     11d6 <check+0x86>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe39(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <inet_addr@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <is_ipv4_global_unicast@plt>
cmp    %ebp,%eax
jne    1188 <check+0x38>
mov    %ebx,%edi
call   1060 <is_ipv4_private_unicast@plt>
cmp    %r15d,%eax
jne    1188 <check+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <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, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = call i32 @inet_addr(i8* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = call i32 @is_ipv4_global_unicast(i32 %10)
%12 = load i32, i32* %5
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %4
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %3
%20 = load i32, i32* %7
%21 = call i32 @is_ipv4_private_unicast(i32 %20)
%22 = load i32, i32* %6
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %4
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
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, i32 %2) {
%4 = tail call i32 @inet_addr(i8* %0)
%5 = tail call i32 @is_ipv4_global_unicast(i32 %4)
%6 = icmp eq i32 %5, %1
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
%12 = tail call i32 @is_ipv4_private_unicast(i32 %4)
%13 = icmp eq i32 %12, %2
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %11
ret void
}