#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 */
struct sockaddr_in {
  int dummy;
};
struct hostent {
  int dummy;
};

/* Variables and functions */
scalar_t__ calloc(int, int);
unsigned int inet_addr(char *);
int random();
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
unsigned int randip() {
  struct hostent *he;
  struct sockaddr_in sin;
  char *buf = (char *)calloc(1, sizeof(char) * 16);
  sprintf(buf, "%d.%d.%d.%d", (random() % 191) + 23, (random() % 253) + 1,
          (random() % 253) + 1, (random() % 253) + 1);
  return inet_addr(buf);
}


x86 assembly (clang, -O0):
<randip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x1,%edi
mov    $0x10,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    $0xbf,%ecx
cltd
idiv   %ecx
add    $0x17,%edx
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    $0xfd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    $0xfd,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    $0xfd,%esi
cltd
idiv   %esi
mov    %edx,%r9d
mov    -0x1c(%rbp),%edx
add    $0x1,%r9d
lea    0xe33(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <inet_addr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randip>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x10,%esi
call   1030 <calloc@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0xffffffffab8f69e3,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
imul   $0xbf,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0x17,%r14d
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0xffffffff81848da9,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
imul   $0xfd,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0xffffffff81848da9,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
imul   $0xfd,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0xffffffff81848da9,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
imul   $0xfd,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r9d
add    $0x1,%r9d
lea    0xde4(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   1060 <sprintf@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <inet_addr@plt>

LLVM IR (-O0):
%struct.hostent = type { i32 }
%struct.sockaddr_in = type { i32 }
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i32 @randip() {
%1 = alloca %struct.hostent*
%2 = alloca %struct.sockaddr_in
%3 = alloca i8*
%4 = call i64 @calloc(i32 1, i32 16)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 (...) @random()
%8 = srem i32 %7, 191
%9 = add nsw i32 %8, 23
%10 = call i32 (...) @random()
%11 = srem i32 %10, 253
%12 = add nsw i32 %11, 1
%13 = call i32 (...) @random()
%14 = srem i32 %13, 253
%15 = add nsw i32 %14, 1
%16 = call i32 (...) @random()
%17 = srem i32 %16, 253
%18 = add nsw i32 %17, 1
%19 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i32 %15, i32 %18)
%20 = load i8*, i8** %3
%21 = call i32 @inet_addr(i8* %20)
ret i32 %21
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i32 @randip() {
%1 = tail call i64 @calloc(i32 1, i32 16)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 (...) @random()
%4 = srem i32 %3, 191
%5 = add nsw i32 %4, 23
%6 = tail call i32 (...) @random()
%7 = srem i32 %6, 253
%8 = add nsw i32 %7, 1
%9 = tail call i32 (...) @random()
%10 = srem i32 %9, 253
%11 = add nsw i32 %10, 1
%12 = tail call i32 (...) @random()
%13 = srem i32 %12, 253
%14 = add nsw i32 %13, 1
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8, i32 %11, i32 %14)
%16 = tail call i32 @inet_addr(i8* %2)
ret i32 %16
}