#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 conv_from_cidr_fmt(char *, char **, char **);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  char *full_prefix = NULL;
  char *prefix = NULL;
  char *netmask = NULL;
  if (argc != 2) {
    printf("Usage: %s IP_addr_in_CIDR_fmt\n", argv[0]);
    return EXIT_FAILURE;
  }
  full_prefix = argv[1];
  printf("IP address in CIDR format: %s\n", full_prefix);
  if (conv_from_cidr_fmt(full_prefix, &prefix, &netmask) == EXIT_FAILURE) {
    printf("Error, IP address not in CIDR format: %s\n", full_prefix);
    return EXIT_FAILURE;
  }
  printf("network address: %s\n", prefix);
  printf("network mask bits: %s\n", netmask);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <conv_from_cidr_fmt@plt>
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%eax
jne    11d9 <main+0xb9>
mov    -0x18(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xe0>
mov    -0x20(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    1183 <main+0x63>
mov    0x8(%rsi),%rbx
lea    0xed6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <conv_from_cidr_fmt@plt>
mov    0x2e76(%rip),%r14
cmp    (%r14),%eax
jne    119d <main+0x7d>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    (%r14),%eax
jmp    11c1 <main+0xa1>
mov    (%rsi),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
jmp    11c1 <main+0xa1>
mov    0x10(%rsp),%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: %s IP_addr_in_CIDR_fmt\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"IP address in CIDR format: %s\0A\00"
@.str.2 = [42 x i8] c"Error, IP address not in CIDR format: %s\0A\00"
@.str.3 = [21 x i8] c"network address: %s\0A\00"
@.str.4 = [23 x i8] c"network mask bits: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %36
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 @conv_from_cidr_fmt(i8* %23, i8** %7, i8** %8)
%25 = load i32, i32* @EXIT_FAILURE
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %31
27: ; preds = %17
%28 = load i8*, i8** %6
%29 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %36
31: ; preds = %17
%32 = load i8*, i8** %7
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %8
%35 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %34)
store i32 0, i32* %3
br label %36
36: ; preds = %31, %27, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [31 x i8] c"Usage: %s IP_addr_in_CIDR_fmt\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"IP address in CIDR format: %s\0A\00"
@.str.2 = [42 x i8] c"Error, IP address not in CIDR format: %s\0A\00"
@.str.3 = [21 x i8] c"network address: %s\0A\00"
@.str.4 = [23 x i8] c"network mask bits: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
br label %27
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @conv_from_cidr_fmt(i8* %14, i8** %3, i8** %4)
%17 = load i32, i32* @EXIT_FAILURE
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%21 = load i32, i32* @EXIT_FAILURE
br label %27
22: ; preds = %12
%23 = load i8*, i8** %3
%24 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %4
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %22, %19, %8
%28 = phi i32 [ %11, %8 ], [ %21, %19 ], [ 0, %22 ]
ret i32 %28
}