#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 */
double RAND_MAX;
double rand();
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
char *xmalloc(int);
char *RandomIp(void) {
  char *ipRand = NULL;
  int r1, r2, r3, r4;
  r1 = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  r2 = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  r3 = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  r4 = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  ipRand = xmalloc(12 * sizeof(char *));
  sprintf(ipRand, "%d.%d.%d.%d", r1, r2, r3, r4);
  return ipRand;
}


x86 assembly (clang, -O0):
<RandomIp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xeb6(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xea2(%rip),%xmm1
mov    0x2e83(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe7f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
mov    0x2e4c(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe48(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe34(%rip),%xmm1
mov    0x2e15(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe11(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdfd(%rip),%xmm1
mov    0x2dde(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    $0x60,%edi
call   1030 <xmalloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xdcd(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RandomIp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xeb9(%rip),%xmm0
mov    0x2e9a(%rip),%rbx
movsd  (%rbx),%xmm1
addsd  0xeae(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r14d
add    $0x1,%r14d
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xe8a(%rip),%xmm0
movsd  (%rbx),%xmm1
addsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r15d
add    $0x1,%r15d
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xe62(%rip),%xmm0
movsd  (%rbx),%xmm1
addsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r12d
add    $0x1,%r12d
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xe3a(%rip),%xmm0
movsd  0xe3a(%rip),%xmm1
addsd  (%rbx),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebp
add    $0x1,%ebp
mov    $0x60,%edi
call   1030 <xmalloc@plt>
mov    %rax,%rbx
lea    0xe1f(%rip),%rsi
mov    %rax,%rdi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    %ebp,%r9d
call   1040 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @RandomIp() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* null, i8** %1
%6 = call double (...) @rand()
%7 = fmul double 2.550000e+02, %6
%8 = load double, double* @RAND_MAX
%9 = fadd double %8, 1.000000e+00
%10 = fdiv double %7, %9
%11 = fptosi double %10 to i32
%12 = add nsw i32 1, %11
store i32 %12, i32* %2
%13 = call double (...) @rand()
%14 = fmul double 2.550000e+02, %13
%15 = load double, double* @RAND_MAX
%16 = fadd double %15, 1.000000e+00
%17 = fdiv double %14, %16
%18 = fptosi double %17 to i32
%19 = add nsw i32 1, %18
store i32 %19, i32* %3
%20 = call double (...) @rand()
%21 = fmul double 2.550000e+02, %20
%22 = load double, double* @RAND_MAX
%23 = fadd double %22, 1.000000e+00
%24 = fdiv double %21, %23
%25 = fptosi double %24 to i32
%26 = add nsw i32 1, %25
store i32 %26, i32* %4
%27 = call double (...) @rand()
%28 = fmul double 2.550000e+02, %27
%29 = load double, double* @RAND_MAX
%30 = fadd double %29, 1.000000e+00
%31 = fdiv double %28, %30
%32 = fptosi double %31 to i32
%33 = add nsw i32 1, %32
store i32 %33, i32* %5
%34 = call i8* @xmalloc(i32 96)
store i8* %34, i8** %1
%35 = load i8*, i8** %1
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %36, i32 %37, i32 %38, i32 %39)
%41 = load i8*, i8** %1
ret i8* %41
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @RandomIp() {
%1 = tail call double (...) @rand()
%2 = fmul double %1, 2.550000e+02
%3 = load double, double* @RAND_MAX
%4 = fadd double %3, 1.000000e+00
%5 = fdiv double %2, %4
%6 = fptosi double %5 to i32
%7 = add nsw i32 %6, 1
%8 = tail call double (...) @rand()
%9 = fmul double %8, 2.550000e+02
%10 = load double, double* @RAND_MAX
%11 = fadd double %10, 1.000000e+00
%12 = fdiv double %9, %11
%13 = fptosi double %12 to i32
%14 = add nsw i32 %13, 1
%15 = tail call double (...) @rand()
%16 = fmul double %15, 2.550000e+02
%17 = load double, double* @RAND_MAX
%18 = fadd double %17, 1.000000e+00
%19 = fdiv double %16, %18
%20 = fptosi double %19 to i32
%21 = add nsw i32 %20, 1
%22 = tail call double (...) @rand()
%23 = fmul double %22, 2.550000e+02
%24 = load double, double* @RAND_MAX
%25 = fadd double %24, 1.000000e+00
%26 = fdiv double %23, %25
%27 = fptosi double %26 to i32
%28 = add nsw i32 %27, 1
%29 = tail call i8* @xmalloc(i32 96)
%30 = tail call i32 @sprintf(i8* dereferenceable(1) %29, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %14, i32 %21, i32 %28)
ret i8* %29
}