#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*/ print_num_to_ip_string(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void generate_ip_address_list(unsigned int subnet, unsigned int mask) {
  int shift = (32 - mask);
  unsigned int maskbit = 0xffffffff << (32 - mask);
  unsigned int ip;
  subnet = maskbit & subnet;
  print_num_to_ip_string(subnet);
  subnet = (subnet >> shift);
  printf("~maskbit %d\n", ~maskbit);
  print_num_to_ip_string(maskbit);
  printf("Loop Start\n");
  for (unsigned int i = 1; i <= (~maskbit); i++) {
    print_num_to_ip_string(maskbit + i);
    ip = subnet & (maskbit + i);
    print_num_to_ip_string(ip);
  }
}


x86 assembly (clang, -O0):
<generate_ip_address_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x20,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x20,%ecx
sub    -0x8(%rbp),%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <print_num_to_ip_string@plt>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shr    %cl,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%esi
xor    $0xffffffff,%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edi
call   1040 <print_num_to_ip_string@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
xor    $0xffffffff,%ecx
cmp    %ecx,%eax
ja     11d8 <generate_ip_address_list+0xb8>
mov    -0x10(%rbp),%edi
add    -0x18(%rbp),%edi
call   1040 <print_num_to_ip_string@plt>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    -0x18(%rbp),%ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <print_num_to_ip_string@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1198 <generate_ip_address_list+0x78>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_ip_address_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
mov    %r15d,%ebp
neg    %bpl
mov    $0xffffffff,%r12d
mov    %ebp,%ecx
shl    %cl,%r12d
and    %r12d,%r14d
mov    %r14d,%edi
call   1050 <print_num_to_ip_string@plt>
mov    %ebp,%ecx
shr    %cl,%r14d
mov    %r12d,%r13d
not    %r13d
lea    0xe91(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%edi
call   1050 <print_num_to_ip_string@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x20,%r15d
je     11bd <generate_ip_address_list+0x8d>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbp,1),%ebx
mov    %ebx,%edi
call   1050 <print_num_to_ip_string@plt>
and    %r14d,%ebx
mov    %ebx,%edi
call   1050 <print_num_to_ip_string@plt>
add    $0x1,%ebp
cmp    %r13d,%ebp
jbe    11a0 <generate_ip_address_list+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"~maskbit %d\0A\00"
@.str.1 = [12 x i8] c"Loop Start\0A\00"
define void @generate_ip_address_list(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = sub i32 32, %9
store i32 %10, i32* %5
%11 = load i32, i32* %4
%12 = sub i32 32, %11
%13 = shl i32 -1, %12
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = and i32 %14, %15
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @print_num_to_ip_string(i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = lshr i32 %19, %20
store i32 %21, i32* %3
%22 = load i32, i32* %6
%23 = xor i32 %22, -1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %6
%26 = call i32 @print_num_to_ip_string(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %8
br label %28
28: ; preds = %45, %2
%29 = load i32, i32* %8
%30 = load i32, i32* %6
%31 = xor i32 %30, -1
%32 = icmp ule i32 %29, %31
br i1 %32, label %33, label %48
33: ; preds = %28
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = add i32 %34, %35
%37 = call i32 @print_num_to_ip_string(i32 %36)
%38 = load i32, i32* %3
%39 = load i32, i32* %6
%40 = load i32, i32* %8
%41 = add i32 %39, %40
%42 = and i32 %38, %41
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = call i32 @print_num_to_ip_string(i32 %43)
br label %45
45: ; preds = %33
%46 = load i32, i32* %8
%47 = add i32 %46, 1
store i32 %47, i32* %8
br label %28
48: ; preds = %28
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"~maskbit %d\0A\00"
@str = [11 x i8] c"Loop Start\00"
define void @generate_ip_address_list(i32 %0, i32 %1) {
%3 = sub i32 32, %1
%4 = shl nsw i32 -1, %3
%5 = and i32 %4, %0
%6 = tail call i32 @print_num_to_ip_string(i32 %5)
%7 = lshr i32 %5, %3
%8 = xor i32 %4, -1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = tail call i32 @print_num_to_ip_string(i32 %4)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%12 = icmp eq i32 %1, 32
br i1 %12, label %13, label %14
13: ; preds = %14, %2
ret void
14: ; preds = %2, %14
%15 = phi i32 [ %20, %14 ], [ 1, %2 ]
%16 = add i32 %15, %4
%17 = tail call i32 @print_num_to_ip_string(i32 %16)
%18 = and i32 %16, %7
%19 = tail call i32 @print_num_to_ip_string(i32 %18)
%20 = add i32 %15, 1
%21 = icmp ugt i32 %20, %8
br i1 %21, label %13, label %14
}