#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 in_addr {
  int dummy;
};
struct hostent {
  scalar_t__ *h_addr_list;
};

/* Variables and functions */
struct hostent *gethostbyname(char *);
char *inet_ntoa(struct in_addr);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
unsigned short int wildcarDetect(char *dom, char *ipstr) {
  char strTmp[30] = {'\0'}, s[200] = {'\0'};
  unsigned short int i = 0, n = 0, max = 0;
  struct hostent *h;
  srand(time(NULL));
  max = rand() % 20;
  if (max < 10)
    max = max + (10 - max);
  for (i = 0; i < max; ++i) {
    n = rand() % 10;
    sprintf(strTmp, "%d", n);
    if (i == 0)
      strncpy(s, strTmp, 200 - strlen(s) - 1);
    else
      strncat(s, strTmp, 200 - strlen(s) - 1);
  }
  strncat(s, ".", 200 - strlen(s) - 1);
  strncat(s, dom, 200 - strlen(s) - 1);
  h = gethostbyname(s);
  if (h) {
    sprintf(ipstr, inet_ntoa(*((struct in_addr *)h->h_addr_list[0])), "%s");
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<wildcarDetect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1060 <memset@plt>
movw   $0x0,-0x112(%rbp)
movw   $0x0,-0x114(%rbp)
movw   $0x0,-0x116(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0x116(%rbp)
movzwl -0x116(%rbp),%eax
cmp    $0xa,%eax
jge    1248 <wildcarDetect+0xa8>
movzwl -0x116(%rbp),%eax
movzwl -0x116(%rbp),%edx
mov    $0xa,%ecx
sub    %edx,%ecx
add    %ecx,%eax
mov    %ax,-0x116(%rbp)
movw   $0x0,-0x112(%rbp)
movzwl -0x112(%rbp),%eax
movzwl -0x116(%rbp),%ecx
cmp    %ecx,%eax
jge    134e <wildcarDetect+0x1ae>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0x114(%rbp)
lea    -0x40(%rbp),%rdi
movzwl -0x114(%rbp),%edx
lea    0xd6e(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
movzwl -0x112(%rbp),%eax
cmp    $0x0,%eax
jne    12f0 <wildcarDetect+0x150>
lea    -0x110(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x130(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0xc8,%edx
sub    %eax,%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
jmp    1332 <wildcarDetect+0x192>
lea    -0x110(%rbp),%rax
mov    %rax,-0x140(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x140(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    $0xc8,%edx
sub    %eax,%edx
sub    $0x1,%edx
call   1070 <strncat@plt>
jmp    1337 <wildcarDetect+0x197>
mov    -0x112(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x112(%rbp)
jmp    1251 <wildcarDetect+0xb1>
lea    -0x110(%rbp),%rax
mov    %rax,-0x158(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x158(%rbp),%rdi
mov    $0xc8,%edx
sub    %eax,%edx
sub    $0x1,%edx
lea    0xc83(%rip),%rsi
call   1070 <strncat@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x150(%rbp),%rdi
mov    -0x148(%rbp),%rsi
mov    $0xc8,%edx
sub    %eax,%edx
sub    $0x1,%edx
call   1070 <strncat@plt>
lea    -0x110(%rbp),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x120(%rbp)
je     142a <wildcarDetect+0x28a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0x120(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    -0x160(%rbp),%rdi
mov    %rax,%rsi
lea    0xbed(%rip),%rdx
mov    $0x0,%al
call   10b0 <sprintf@plt>
movw   $0x1,-0x2(%rbp)
jmp    1430 <wildcarDetect+0x290>
movw   $0x0,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wildcarDetect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movups %xmm0,0xe(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0xe0(%rsp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
movzwl %ax,%ecx
and    $0xfffe,%eax
cmp    $0xa,%eax
mov    $0xa,%ebp
cmovae %ecx,%ebp
test   %ebp,%ebp
je     1323 <wildcarDetect+0x193>
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
movzwl %ax,%edx
lea    0xd77(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0xc7,%edx
sub    %eax,%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strncpy@plt>
cmp    $0x1,%ebp
je     1323 <wildcarDetect+0x193>
add    $0xffffffff,%ebp
lea    0xd3c(%rip),%r12
mov    %rsp,%r13
lea    0x20(%rsp),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
movzwl %ax,%edx
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0xc7,%edx
sub    %eax,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strncat@plt>
add    $0xffffffff,%ebp
jne    12d0 <wildcarDetect+0x140>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0xc7,%ebp
mov    $0xc7,%edx
sub    %eax,%edx
lea    0xcc0(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strncat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1060 <strncat@plt>
mov    %rbx,%rdi
call   1080 <gethostbyname@plt>
test   %rax,%rax
je     1396 <wildcarDetect+0x206>
mov    (%rax),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
lea    0xc82(%rip),%rdx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    $0x1,%ax
jmp    1398 <wildcarDetect+0x208>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i64* }
%struct.in_addr = type { i32 }
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"%s\00"
define zeroext i16 @wildcarDetect(i8* %0, i8* %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [30 x i8]
%7 = alloca [200 x i8]
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
%11 = alloca %struct.hostent*
store i8* %0, i8** %4
store i8* %1, i8** %5
%12 = bitcast [30 x i8]* %6 to i8*
%13 = bitcast [200 x i8]* %7 to i8*
store i16 0, i16* %8
store i16 0, i16* %9
store i16 0, i16* %10
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 20
%18 = trunc i32 %17 to i16
store i16 %18, i16* %10
%19 = load i16, i16* %10
%20 = zext i16 %19 to i32
%21 = icmp slt i32 %20, 10
br i1 %21, label %22, label %30
22: ; preds = %2
%23 = load i16, i16* %10
%24 = zext i16 %23 to i32
%25 = load i16, i16* %10
%26 = zext i16 %25 to i32
%27 = sub nsw i32 10, %26
%28 = add nsw i32 %24, %27
%29 = trunc i32 %28 to i16
store i16 %29, i16* %10
br label %30
30: ; preds = %22, %2
store i16 0, i16* %8
br label %31
31: ; preds = %65, %30
%32 = load i16, i16* %8
%33 = zext i16 %32 to i32
%34 = load i16, i16* %10
%35 = zext i16 %34 to i32
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %68
37: ; preds = %31
%38 = call i32 (...) @rand()
%39 = srem i32 %38, 10
%40 = trunc i32 %39 to i16
store i16 %40, i16* %9
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%42 = load i16, i16* %9
%43 = zext i16 %42 to i32
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i16, i16* %8
%46 = zext i16 %45 to i32
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %56
48: ; preds = %37
%49 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%50 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = sub nsw i32 200, %52
%54 = sub nsw i32 %53, 1
%55 = call i32 @strncpy(i8* %49, i8* %50, i32 %54)
br label %64
56: ; preds = %37
%57 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%58 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%59 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = sub nsw i32 200, %60
%62 = sub nsw i32 %61, 1
%63 = call i32 @strncat(i8* %57, i8* %58, i32 %62)
br label %64
64: ; preds = %56, %48
br label %65
65: ; preds = %64
%66 = load i16, i16* %8
%67 = add i16 %66, 1
store i16 %67, i16* %8
br label %31
68: ; preds = %31
%69 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%70 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%71 = call i32 @strlen(i8* %70)
%72 = sub nsw i32 200, %71
%73 = sub nsw i32 %72, 1
%74 = call i32 @strncat(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %73)
%75 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%76 = load i8*, i8** %4
%77 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%78 = call i32 @strlen(i8* %77)
%79 = sub nsw i32 200, %78
%80 = sub nsw i32 %79, 1
%81 = call i32 @strncat(i8* %75, i8* %76, i32 %80)
%82 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%83 = call %struct.hostent* @gethostbyname(i8* %82)
store %struct.hostent* %83, %struct.hostent** %11
%84 = load %struct.hostent*, %struct.hostent** %11
%85 = icmp ne %struct.hostent* %84, null
br i1 %85, label %86, label %98
86: ; preds = %68
%87 = load i8*, i8** %5
%88 = load %struct.hostent*, %struct.hostent** %11
%89 = getelementptr inbounds %struct.hostent, %struct.hostent* %88, i32 0, i32 0
%90 = load i64*, i64** %89
%91 = getelementptr inbounds i64, i64* %90, i64 0
%92 = load i64, i64* %91
%93 = inttoptr i64 %92 to %struct.in_addr*
%94 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %93, i32 0, i32 0
%95 = load i32, i32* %94
%96 = call i8* @inet_ntoa(i32 %95)
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %87, i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i16 1, i16* %3
br label %99
98: ; preds = %68
store i16 0, i16* %3
br label %99
99: ; preds = %98, %86
%100 = load i16, i16* %3
ret i16 %100
}

LLVM IR (-O2):
%struct.hostent = type { i64* }
%struct.in_addr = type { i32 }
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"%s\00"
define zeroext i16 @wildcarDetect(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca [30 x i8]
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 20
%11 = and i32 %10, 65534
%12 = icmp ult i32 %11, 10
%13 = and i32 %10, 65535
%14 = select i1 %12, i32 10, i32 %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %36, label %16
16: ; preds = %2
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 10
%19 = and i32 %18, 65535
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32 @strlen(i8* %6)
%22 = sub i32 199, %21
%23 = call i32 @strncpy(i8* %6, i8* %5, i32 %22)
%24 = icmp eq i32 %14, 1
br i1 %24, label %36, label %25
25: ; preds = %16, %25
%26 = phi i32 [ %34, %25 ], [ 1, %16 ]
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 10
%29 = and i32 %28, 65535
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = call i32 @strlen(i8* %6)
%32 = sub i32 199, %31
%33 = call i32 @strncat(i8* %6, i8* %5, i32 %32)
%34 = add nuw nsw i32 %26, 1
%35 = icmp eq i32 %34, %14
br i1 %35, label %36, label %25
36: ; preds = %25, %16, %2
%37 = call i32 @strlen(i8* %6)
%38 = sub i32 199, %37
%39 = call i32 @strncat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = call i32 @strlen(i8* %6)
%41 = sub i32 199, %40
%42 = call i32 @strncat(i8* %6, i8* %0, i32 %41)
%43 = call %struct.hostent* @gethostbyname(i8* %6)
%44 = icmp eq %struct.hostent* %43, null
br i1 %44, label %54, label %45
45: ; preds = %36
%46 = getelementptr inbounds %struct.hostent, %struct.hostent* %43, i64 0, i32 0
%47 = load i64*, i64** %46
%48 = load i64, i64* %47
%49 = inttoptr i64 %48 to %struct.in_addr*
%50 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %49, i64 0, i32 0
%51 = load i32, i32* %50
%52 = call i8* @inet_ntoa(i32 %51)
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %36, %45
%55 = phi i16 [ 1, %45 ], [ 0, %36 ]
ret i16 %55
}