#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 rand();
unsigned int mk_rnd_ipv4(const int msb_floor) {
  unsigned char b0 = msb_floor + (rand() % 2);
  unsigned char b1 = 1 + (rand() % 254);
  unsigned char b2 = 1 + (rand() % 254);
  unsigned char b3 = 1 + (rand() % 254);
  return ((unsigned int)b0 << 24) | ((unsigned int)b1 << 16) |
         ((unsigned int)b2 << 8) | ((unsigned int)b3);
}


x86 assembly (clang, -O0):
<mk_rnd_ipv4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0xc(%rbp),%eax
add    %edx,%eax
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xfe,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%al
mov    %al,-0x6(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xfe,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%al
mov    %al,-0x7(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xfe,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %dl,%al
mov    %al,-0x8(%rbp)
movzbl -0x5(%rbp),%eax
shl    $0x18,%eax
movzbl -0x6(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x7(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x8(%rbp),%ecx
or     %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_rnd_ipv4>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%r14d
shr    $0x1f,%eax
add    %r14d,%eax
and    $0xfe,%eax
sub    %eax,%r14d
add    %ebp,%r14d
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
mov    %ecx,%ebp
sub    %edx,%ebp
add    %ecx,%ebp
add    %eax,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
mov    %ecx,%ebx
sub    %edx,%ebx
add    %ecx,%ebx
add    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
add    %esi,%eax
add    $0x1,%eax
shl    $0x18,%r14d
shl    $0x10,%ebp
add    $0x10000,%ebp
and    $0xff0000,%ebp
or     %r14d,%ebp
shl    $0x8,%ebx
add    $0x100,%ebx
movzwl %bx,%ecx
or     %ebp,%ecx
movzbl %al,%eax
or     %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mk_rnd_ipv4(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 2
%10 = add nsw i32 %7, %9
%11 = trunc i32 %10 to i8
store i8 %11, i8* %3
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 254
%14 = add nsw i32 1, %13
%15 = trunc i32 %14 to i8
store i8 %15, i8* %4
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 254
%18 = add nsw i32 1, %17
%19 = trunc i32 %18 to i8
store i8 %19, i8* %5
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 254
%22 = add nsw i32 1, %21
%23 = trunc i32 %22 to i8
store i8 %23, i8* %6
%24 = load i8, i8* %3
%25 = zext i8 %24 to i32
%26 = shl i32 %25, 24
%27 = load i8, i8* %4
%28 = zext i8 %27 to i32
%29 = shl i32 %28, 16
%30 = or i32 %26, %29
%31 = load i8, i8* %5
%32 = zext i8 %31 to i32
%33 = shl i32 %32, 8
%34 = or i32 %30, %33
%35 = load i8, i8* %6
%36 = zext i8 %35 to i32
%37 = or i32 %34, %36
ret i32 %37
}

LLVM IR (-O2):
define i32 @mk_rnd_ipv4(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 2
%4 = add nsw i32 %3, %0
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 254
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 254
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 254
%11 = add nsw i32 %10, 1
%12 = shl i32 %4, 24
%13 = shl nsw i32 %6, 16
%14 = add nsw i32 %13, 65536
%15 = and i32 %14, 16711680
%16 = or i32 %15, %12
%17 = shl nsw i32 %8, 8
%18 = add nsw i32 %17, 256
%19 = and i32 %18, 65280
%20 = or i32 %16, %19
%21 = and i32 %11, 255
%22 = or i32 %20, %21
ret i32 %22
}