#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 */
typedef scalar_t__ uint32_t;
struct in_addr {
  int /*<<< orphan*/ s_addr;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htonl(scalar_t__);
int /*<<< orphan*/ *inet_ntop(int /*<<< orphan*/, struct in_addr *, char *,
                              int);
int inet_pton(int /*<<< orphan*/, char const *, struct in_addr *);
scalar_t__ ntohl(int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int main(int argc, const char *argv[]) {
  struct in_addr start, end;
  uint32_t first, cur, last;
  if (argc != 3) {
    fprintf(stderr, "ip_iter: <start> <end>\n");
    return (1);
  }
  if (inet_pton(AF_INET, argv[1], &start) != 1) {
    fprintf(stderr, "argv[1] (%s) looks bad\n", argv[1]);
    return (1);
  }
  if (inet_pton(AF_INET, argv[2], &end) != 1) {
    fprintf(stderr, "argv[2] (%s) looks bad\n", argv[2]);
    return (1);
  }
  first = ntohl(start.s_addr);
  last = ntohl(end.s_addr);
  if (first > last) {
    fprintf(stderr, "starting address is larger than ending, "
                    "aborting\n");
    return (1);
  }
  for (cur = first; cur <= last; cur++) {
    struct in_addr i;
    char buf[INET_ADDRSTRLEN];
    i.s_addr = htonl(cur);
    if (inet_ntop(AF_INET, &i, buf, sizeof(buf)) == NULL) {
      fprintf(stderr, "conversion failed!\n");
      return (1);
    }
    puts(buf);
  }
  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)
cmpl   $0x3,-0x8(%rbp)
je     11a3 <main+0x43>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1375 <main+0x215>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
je     11f1 <main+0x91>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1375 <main+0x215>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
je     123f <main+0xdf>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1375 <main+0x215>
mov    -0x18(%rbp),%edi
call   1080 <ntohl@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
call   1080 <ntohl@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x38(%rbp),%rax
jle    1288 <main+0x128>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1375 <main+0x215>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jg     136e <main+0x20e>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x60(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <htonl@plt>
mov    -0x68(%rbp),%rdx
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
mov    %ecx,-0x40(%rbp)
mov    0x2cfd(%rip),%rcx
mov    (%rcx),%edi
mov    %eax,%ecx
lea    -0x40(%rbp),%rsi
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    132c <main+0x1cc>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    133c <main+0x1dc>
mov    -0x68(%rbp),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x54(%rbp),%eax
test   %eax,%eax
je     1358 <main+0x1f8>
jmp    1353 <main+0x1f3>
jmp    1375 <main+0x215>
jmp    135d <main+0x1fd>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1290 <main+0x130>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    11d4 <main+0x74>
mov    %rsi,%rbx
mov    0x2e68(%rip),%r14
mov    (%r14),%edi
mov    0x8(%rsi),%rsi
lea    -0x40(%rbp),%rdx
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
jne    11ed <main+0x8d>
mov    (%r14),%edi
mov    0x10(%rbx),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
jne    1203 <main+0xa3>
mov    -0x40(%rbp),%edi
call   1080 <ntohl@plt>
mov    %rax,%r12
mov    -0x38(%rbp),%edi
call   1080 <ntohl@plt>
cmp    %rax,%r12
jle    1232 <main+0xd2>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
jmp    11e4 <main+0x84>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    121e <main+0xbe>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe17(%rip),%rsi
jmp    1217 <main+0xb7>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe19(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%r14
add    $0x1,%r14
nopl   0x0(%rax)
mov    %rsp,%r15
mov    0x2d86(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%rbx
mov    %r13,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r12,%rdi
call   1050 <htonl@plt>
mov    %eax,-0x30(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    %rbx,%rdx
mov    %r13d,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     12a1 <main+0x141>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r15,%rsp
add    $0x1,%r12
cmp    %r12,%r14
jne    1240 <main+0xe0>
xor    %eax,%eax
jmp    1223 <main+0xc3>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rsp
jmp    121e <main+0xbe>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"ip_iter: <start> <end>\0A\00"
@AF_INET = global i32 0
@.str.1 = [24 x i8] c"argv[1] (%s) looks bad\0A\00"
@.str.2 = [24 x i8] c"argv[2] (%s) looks bad\0A\00"
@.str.3 = [50 x i8] c"starting address is larger than ending, aborting\0A\00"
@INET_ADDRSTRLEN = global i32 0
@.str.4 = [20 x i8] c"conversion failed!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.in_addr
%7 = alloca %struct.in_addr
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca %struct.in_addr
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %90
20: ; preds = %2
%21 = load i32, i32* @AF_INET
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @inet_pton(i32 %21, i8* %24, %struct.in_addr* %6)
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 1, i32* %3
br label %90
33: ; preds = %20
%34 = load i32, i32* @AF_INET
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @inet_pton(i32 %34, i8* %37, %struct.in_addr* %7)
%39 = icmp ne i32 %38, 1
br i1 %39, label %40, label %46
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %44)
store i32 1, i32* %3
br label %90
46: ; preds = %33
%47 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i64 @ntohl(i32 %48)
store i64 %49, i64* %8
%50 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i64 @ntohl(i32 %51)
store i64 %52, i64* %10
%53 = load i64, i64* %8
%54 = load i64, i64* %10
%55 = icmp sgt i64 %53, %54
br i1 %55, label %56, label %59
56: ; preds = %46
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %90
59: ; preds = %46
%60 = load i64, i64* %8
store i64 %60, i64* %9
br label %61
61: ; preds = %86, %59
%62 = load i64, i64* %9
%63 = load i64, i64* %10
%64 = icmp sle i64 %62, %63
br i1 %64, label %65, label %89
65: ; preds = %61
%66 = load i32, i32* @INET_ADDRSTRLEN
%67 = zext i32 %66 to i64
%68 = call i8* @llvm.stacksave()
store i8* %68, i8** %12
%69 = alloca i8, i64 %67
store i64 %67, i64* %13
%70 = load i64, i64* %9
%71 = call i32 @htonl(i64 %70)
%72 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %11, i32 0, i32 0
store i32 %71, i32* %72
%73 = load i32, i32* @AF_INET
%74 = trunc i64 %67 to i32
%75 = call i32* @inet_ntop(i32 %73, %struct.in_addr* %11, i8* %69, i32 %74)
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %65
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %14
br label %82
80: ; preds = %65
%81 = call i32 @puts(i8* %69)
store i32 0, i32* %14
br label %82
82: ; preds = %80, %77
%83 = load i8*, i8** %12
%84 = load i32, i32* %14
switch i32 %84, label %92 [
i32 0, label %85
i32 1, label %90
]
85: ; preds = %82
br label %86
86: ; preds = %85
%87 = load i64, i64* %9
%88 = add nsw i64 %87, 1
store i64 %88, i64* %9
br label %61
89: ; preds = %61
store i32 0, i32* %3
br label %90
90: ; preds = %89, %82, %56, %40, %27, %17
%91 = load i32, i32* %3
ret i32 %91
92: ; preds = %82
unreachable
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"ip_iter: <start> <end>\0A\00"
@AF_INET = global i32 0
@.str.1 = [24 x i8] c"argv[1] (%s) looks bad\0A\00"
@.str.2 = [24 x i8] c"argv[2] (%s) looks bad\0A\00"
@.str.3 = [50 x i8] c"starting address is larger than ending, aborting\0A\00"
@INET_ADDRSTRLEN = global i32 0
@.str.4 = [20 x i8] c"conversion failed!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = alloca %struct.in_addr
%5 = alloca %struct.in_addr
%6 = bitcast %struct.in_addr* %3 to i8*
%7 = bitcast %struct.in_addr* %4 to i8*
%8 = icmp eq i32 %0, 3
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %63
12: ; preds = %2
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @inet_pton(i32 %13, i8* %15, %struct.in_addr* %3)
%17 = icmp eq i32 %16, 1
br i1 %17, label %22, label %18
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %63
22: ; preds = %12
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @inet_pton(i32 %23, i8* %25, %struct.in_addr* %4)
%27 = icmp eq i32 %26, 1
br i1 %27, label %32, label %28
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %24
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %63
32: ; preds = %22
%33 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
%34 = load i32, i32* %33
%35 = call i64 @ntohl(i32 %34)
%36 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i64 0, i32 0
%37 = load i32, i32* %36
%38 = call i64 @ntohl(i32 %37)
%39 = icmp sgt i64 %35, %38
br i1 %39, label %43, label %40
40: ; preds = %32
%41 = bitcast %struct.in_addr* %5 to i8*
%42 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i64 0, i32 0
br label %46
43: ; preds = %32
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
br label %63
46: ; preds = %40, %59
%47 = phi i64 [ %35, %40 ], [ %61, %59 ]
%48 = load i32, i32* @INET_ADDRSTRLEN
%49 = zext i32 %48 to i64
%50 = call i8* @llvm.stacksave()
%51 = alloca i8, i64 %49
%52 = call i32 @htonl(i64 %47)
store i32 %52, i32* %42
%53 = load i32, i32* @AF_INET
%54 = call i32* @inet_ntop(i32 %53, %struct.in_addr* %5, i8* %51, i32 %48)
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %59
56: ; preds = %46
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %63
59: ; preds = %46
%60 = call i32 @puts(i8* %51)
%61 = add i64 %47, 1
%62 = icmp eq i64 %47, %38
br i1 %62, label %63, label %46
63: ; preds = %59, %56, %43, %28, %18, %9
%64 = phi i32 [ 1, %9 ], [ 1, %18 ], [ 1, %28 ], [ 1, %43 ], [ 1, %56 ], [ 0, %59 ]
ret i32 %64
}