#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 timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct in_addr {
  void *s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int /*<<< orphan*/ func_help();
int getopt(int, char **, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void *inet_addr(char *);
char *optarg;
int /*<<< orphan*/ scan_ip(struct in_addr, struct in_addr);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct timeval ti, tf;
  struct in_addr ip, masque;
  char format[] = "ha:n:";
  int optch;
  extern int opterr;
  char *ip_buff;
  char *netmask_buff;
  int ip_set = 0, netmask_set = 0;
  opterr = 1;
  while ((optch = getopt(argc, argv, format)) != -1)
    switch (optch) {
    case 'a':
      ip_buff = optarg;
      ip_set = 1;
      break;
    case 'n':
      netmask_buff = optarg;
      netmask_set = 1;
      break;
    case 'h':
      func_help();
      return 0;
      break;
    }
  if (ip_set) {
    ip.s_addr = inet_addr(ip_buff);
  } else {
    ip.s_addr = inet_addr("192.168.1.1");
  }
  if (netmask_set) {
    masque.s_addr = inet_addr(netmask_buff);
  } else {
    masque.s_addr = inet_addr("255.255.255.0");
  }
  gettimeofday(&ti, NULL);
  scan_ip(ip, masque);
  gettimeofday(&tf, NULL);
  fprintf(stderr, " Execution time  : %f micro secondes \n",
          ((double)((tf.tv_sec - ti.tv_sec) * 1000000 +
                    (tf.tv_usec - ti.tv_usec))));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe84(%rip),%eax
mov    %eax,-0x46(%rbp)
mov    0xe7e(%rip),%ax
mov    %ax,-0x42(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    0x2e59(%rip),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x46(%rbp),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0xffffffff,%eax
je     1243 <main+0xe3>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x61,%eax
je     11f7 <main+0x97>
jmp    11d5 <main+0x75>
mov    -0x6c(%rbp),%eax
sub    $0x68,%eax
je     122b <main+0xcb>
jmp    11e6 <main+0x86>
mov    -0x6c(%rbp),%eax
sub    $0x6e,%eax
je     1211 <main+0xb1>
jmp    123e <main+0xde>
mov    0x2df2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
movl   $0x1,-0x64(%rbp)
jmp    123e <main+0xde>
mov    0x2dd8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    123e <main+0xde>
mov    $0x0,%al
call   1070 <func_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <main+0x19c>
jmp    11a5 <main+0x45>
cmpl   $0x0,-0x64(%rbp)
je     125f <main+0xff>
mov    -0x58(%rbp),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x38(%rbp)
jmp    126f <main+0x10f>
lea    0xda0(%rip),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x68(%rbp)
je     128b <main+0x12b>
mov    -0x60(%rbp),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x40(%rbp)
jmp    129b <main+0x13b>
lea    0xd80(%rip),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x40(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1040 <scan_ip@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%eax
sub    -0x20(%rbp),%eax
imul   $0xf4240,%eax,%eax
cltq
mov    -0x28(%rbp),%rcx
sub    -0x18(%rbp),%rcx
add    %rcx,%rax
cvtsi2sd %rax,%xmm0
lea    0xd30(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movw   $0x3a,0x4(%rsp)
movl   $0x6e3a6168,(%rsp)
mov    0x2e70(%rip),%rax
movl   $0x1,(%rax)
xor    %r13d,%r13d
lea    0xe6e(%rip),%r15
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1080 <getopt@plt>
cmp    $0x67,%eax
jg     11d0 <main+0x70>
cmp    $0xffffffff,%eax
je     11f0 <main+0x90>
cmp    $0x61,%eax
jne    11a0 <main+0x40>
mov    0x2e2d(%rip),%rax
mov    (%rax),%r15
jmp    11a0 <main+0x40>
nopl   0x0(%rax,%rax,1)
cmp    $0x68,%eax
je     1274 <main+0x114>
cmp    $0x6e,%eax
jne    11a0 <main+0x40>
mov    0x2e0b(%rip),%rax
mov    (%rax),%r14
mov    $0x1,%r13d
jmp    11a0 <main+0x40>
mov    %r15,%rdi
call   1050 <inet_addr@plt>
mov    %rax,%rbx
test   %r13d,%r13d
lea    0xe0d(%rip),%rax
cmove  %rax,%r14
mov    %r14,%rdi
call   1050 <inet_addr@plt>
mov    %rax,%rbp
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scan_ip@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
movslq 0x8(%rsp),%rax
movslq 0x18(%rsp),%rcx
sub    %rcx,%rax
mov    0x10(%rsp),%rcx
sub    0x20(%rsp),%rcx
imul   $0xf4240,%rax,%rax
add    %rax,%rcx
cvtsi2sd %rcx,%xmm0
lea    0xdb3(%rip),%rsi
call   1060 <fprintf@plt>
jmp    127b <main+0x11b>
xor    %eax,%eax
call   1070 <func_help@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
%struct.in_addr = type { i8* }
@__const.main.format = [6 x i8] c"ha:n:\00"
@opterr = external global i32
@optarg = global i8* null
@.str = [12 x i8] c"192.168.1.1\00"
@.str.1 = [14 x i8] c"255.255.255.0\00"
@stderr = global i32 0
@.str.2 = [39 x i8] c" Execution time : %f micro secondes \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.in_addr
%9 = alloca %struct.in_addr
%10 = alloca [6 x i8]
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = bitcast [6 x i8]* %10 to i8*
store i32 0, i32* %14
store i32 0, i32* %15
store i32 1, i32* @opterr
br label %17
17: ; preds = %31, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%21 = call i32 @getopt(i32 %18, i8** %19, i8* %20)
store i32 %21, i32* %11
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %32
23: ; preds = %17
%24 = load i32, i32* %11
switch i32 %24, label %31 [
i32 97, label %25
i32 110, label %27
i32 104, label %29
]
25: ; preds = %23
%26 = load i8*, i8** @optarg
store i8* %26, i8** %12
store i32 1, i32* %14
br label %31
27: ; preds = %23
%28 = load i8*, i8** @optarg
store i8* %28, i8** %13
store i32 1, i32* %15
br label %31
29: ; preds = %23
%30 = call i32 (...) @func_help()
store i32 0, i32* %3
br label %76
31: ; preds = %23, %27, %25
br label %17
32: ; preds = %17
%33 = load i32, i32* %14
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8*, i8** %12
%37 = call i8* @inet_addr(i8* %36)
%38 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
store i8* %37, i8** %38
br label %42
39: ; preds = %32
%40 = call i8* @inet_addr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%41 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
store i8* %40, i8** %41
br label %42
42: ; preds = %39, %35
%43 = load i32, i32* %15
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i8*, i8** %13
%47 = call i8* @inet_addr(i8* %46)
%48 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
store i8* %47, i8** %48
br label %52
49: ; preds = %42
%50 = call i8* @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%51 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
store i8* %50, i8** %51
br label %52
52: ; preds = %49, %45
%53 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%54 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%55 = load i8*, i8** %54
%56 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%57 = load i8*, i8** %56
%58 = call i32 @scan_ip(i8* %55, i8* %57)
%59 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%60 = load i32, i32* @stderr
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%64 = load i32, i32* %63
%65 = sub nsw i32 %62, %64
%66 = mul nsw i32 %65, 1000000
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%69 = load i64, i64* %68
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%71 = load i64, i64* %70
%72 = sub nsw i64 %69, %71
%73 = add nsw i64 %67, %72
%74 = sitofp i64 %73 to double
%75 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %74)
store i32 0, i32* %3
br label %76
76: ; preds = %52, %29
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@__const.main.format = [6 x i8] c"ha:n:\00"
@opterr = external global i32
@optarg = global i8* null
@.str = [12 x i8] c"192.168.1.1\00"
@.str.1 = [14 x i8] c"255.255.255.0\00"
@stderr = global i32 0
@.str.2 = [39 x i8] c" Execution time : %f micro secondes \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca [6 x i8]
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
store i32 1, i32* @opterr
br label %9
9: ; preds = %18, %2
%10 = phi i8* [ %14, %18 ], [ undef, %2 ]
%11 = phi i8* [ %19, %18 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = phi i32 [ %15, %18 ], [ 0, %2 ]
br label %13
13: ; preds = %9, %20
%14 = phi i8* [ %10, %9 ], [ %21, %20 ]
%15 = phi i32 [ %12, %9 ], [ 1, %20 ]
br label %16
16: ; preds = %13, %16
%17 = call i32 @getopt(i32 %0, i8** %1, i8* %8)
switch i32 %17, label %16 [
i32 -1, label %24
i32 97, label %18
i32 110, label %20
i32 104, label %22
]
18: ; preds = %16
%19 = load i8*, i8** @optarg
br label %9
20: ; preds = %16
%21 = load i8*, i8** @optarg
br label %13
22: ; preds = %16
%23 = call i32 (...) @func_help()
br label %48
24: ; preds = %16
%25 = call i8* @inet_addr(i8* %11)
%26 = icmp eq i32 %15, 0
%27 = select i1 %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %14
%28 = call i8* @inet_addr(i8* %27)
%29 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%30 = call i32 @scan_ip(i8* %25, i8* %28)
%31 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%32 = load i32, i32* @stderr
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%36 = load i32, i32* %35
%37 = sub nsw i32 %34, %36
%38 = mul nsw i32 %37, 1000000
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%41 = load i64, i64* %40
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%43 = load i64, i64* %42
%44 = sub i64 %41, %43
%45 = add nsw i64 %44, %39
%46 = sitofp i64 %45 to double
%47 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %46)
br label %48
48: ; preds = %24, %22
ret i32 0
}