#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 netent {
  int n_net;
};

/* Variables and functions */
int /*<<< orphan*/ endnetent();
struct netent *getnetent();
int /*<<< orphan*/ printf(char *, int, int, int, int);
int /*<<< orphan*/ setnetent(int /*<<< orphan*/);
int main(void) {
  struct netent *net;
  setnetent(0);
  while ((net = getnetent())) {
    while (net->n_net && !((net->n_net >> 24) & 0xff)) {
      net->n_net <<= 8;
    }
    printf("%lu.%lu.%lu.%lu\n", (net->n_net >> 24) & 0xff,
           (net->n_net >> 16) & 0xff, (net->n_net >> 8) & 0xff,
           net->n_net & 0xff);
  }
  endnetent();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1060 <setnetent@plt>
mov    $0x0,%al
call   1040 <getnetent@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1207 <main+0xc7>
jmp    1170 <main+0x30>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x11(%rbp)
je     119b <main+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x18,%eax
and    $0xff,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11ab <main+0x6b>
jmp    11bb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0x8,%ecx
mov    %ecx,(%rax)
jmp    1170 <main+0x30>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
sar    $0x18,%esi
and    $0xff,%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
sar    $0x10,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
and    $0xff,%r8d
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
jmp    1156 <main+0x16>
mov    $0x0,%al
call   1050 <endnetent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <setnetent@plt>
xor    %eax,%eax
call   1040 <getnetent@plt>
test   %rax,%rax
je     11b2 <main+0x72>
lea    0xea2(%rip),%r14
jmp    118a <main+0x4a>
mov    %ebx,%eax
shr    $0x18,%eax
mov    %ebx,%ecx
shr    $0x10,%ecx
movzbl %cl,%edx
movzbl %bh,%ecx
movzbl %bl,%r8d
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getnetent@plt>
test   %rax,%rax
je     11b2 <main+0x72>
mov    (%rax),%ebx
lea    -0x1(%rbx),%ecx
cmp    $0xfffffe,%ecx
ja     1160 <main+0x20>
nopw   0x0(%rax,%rax,1)
shl    $0x8,%ebx
lea    -0x1(%rbx),%ecx
cmp    $0xffffff,%ecx
jb     11a0 <main+0x60>
mov    %ebx,(%rax)
jmp    1160 <main+0x20>
xor    %eax,%eax
call   1050 <endnetent@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.netent = type { i32 }
@.str = [17 x i8] c"%lu.%lu.%lu.%lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.netent*
store i32 0, i32* %1
%3 = call i32 @setnetent(i32 0)
br label %4
4: ; preds = %28, %0
%5 = call %struct.netent* (...) @getnetent()
store %struct.netent* %5, %struct.netent** %2
%6 = icmp ne %struct.netent* %5, null
br i1 %6, label %7, label %49
7: ; preds = %4
br label %8
8: ; preds = %23, %7
%9 = load %struct.netent*, %struct.netent** %2
%10 = getelementptr inbounds %struct.netent, %struct.netent* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load %struct.netent*, %struct.netent** %2
%15 = getelementptr inbounds %struct.netent, %struct.netent* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = ashr i32 %16, 24
%18 = and i32 %17, 255
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br label %21
21: ; preds = %13, %8
%22 = phi i1 [ false, %8 ], [ %20, %13 ]
br i1 %22, label %23, label %28
23: ; preds = %21
%24 = load %struct.netent*, %struct.netent** %2
%25 = getelementptr inbounds %struct.netent, %struct.netent* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = shl i32 %26, 8
store i32 %27, i32* %25
br label %8
28: ; preds = %21
%29 = load %struct.netent*, %struct.netent** %2
%30 = getelementptr inbounds %struct.netent, %struct.netent* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = ashr i32 %31, 24
%33 = and i32 %32, 255
%34 = load %struct.netent*, %struct.netent** %2
%35 = getelementptr inbounds %struct.netent, %struct.netent* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = ashr i32 %36, 16
%38 = and i32 %37, 255
%39 = load %struct.netent*, %struct.netent** %2
%40 = getelementptr inbounds %struct.netent, %struct.netent* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = ashr i32 %41, 8
%43 = and i32 %42, 255
%44 = load %struct.netent*, %struct.netent** %2
%45 = getelementptr inbounds %struct.netent, %struct.netent* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = and i32 %46, 255
%48 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %33, i32 %38, i32 %43, i32 %47)
br label %4
49: ; preds = %4
%50 = call i32 (...) @endnetent()
ret i32 0
}

LLVM IR (-O2):
%struct.netent = type { i32 }
@.str = [17 x i8] c"%lu.%lu.%lu.%lu\0A\00"
define i32 @main() {
%1 = tail call i32 @setnetent(i32 0)
%2 = tail call %struct.netent* (...) @getnetent()
%3 = icmp eq %struct.netent* %2, null
br i1 %3, label %27, label %4
4: ; preds = %0, %16
%5 = phi %struct.netent* [ %25, %16 ], [ %2, %0 ]
%6 = getelementptr inbounds %struct.netent, %struct.netent* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add i32 %7, -1
%9 = icmp ult i32 %8, 16777215
br i1 %9, label %10, label %16
10: ; preds = %4, %10
%11 = phi i32 [ %12, %10 ], [ %7, %4 ]
%12 = shl nuw i32 %11, 8
%13 = add i32 %12, -1
%14 = icmp ult i32 %13, 16777215
br i1 %14, label %10, label %15
15: ; preds = %10
store i32 %12, i32* %6
br label %16
16: ; preds = %15, %4
%17 = phi i32 [ %12, %15 ], [ %7, %4 ]
%18 = lshr i32 %17, 24
%19 = lshr i32 %17, 16
%20 = and i32 %19, 255
%21 = lshr i32 %17, 8
%22 = and i32 %21, 255
%23 = and i32 %17, 255
%24 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20, i32 %22, i32 %23)
%25 = tail call %struct.netent* (...) @getnetent()
%26 = icmp eq %struct.netent* %25, null
br i1 %26, label %27, label %4
27: ; preds = %16, %0
%28 = tail call i32 (...) @endnetent()
ret i32 0
}