#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ die(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ extract(char *, long *, short *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, long, short, int, short);
scalar_t__ putc(short, int /*<<< orphan*/ *);
int main() {
  FILE *ipnub = fopen("ip-nub.csv", "r");
  if (!ipnub)
    die("fopen ip-nub.csv", 1);
  FILE *ipmap = fopen("ip.map.new", "w");
  if (!ipmap)
    die("fopen ip.map.new", 2);
  long ip, lastip;
  short nub;
  char buf[256];
  for (ip = 0, lastip = -1; ip < 4294967296; ip++) {
    if (ip > lastip) {
      if (!fgets(buf, 256, ipnub))
        die("fgets line of ip-nub.csv", 3);
      extract(buf, &lastip, &nub);
    }
    if (ip == 758512576 || ip == 1815626509) {
      printf("ip: %ld, %d (%d, %d)\n", ip, nub, 255 & nub, nub >> 8);
    }
    if (EOF == putc(255 & nub, ipmap))
      die("putc to ip.map.new", 7);
    if (EOF == putc(nub >> 8, ipmap))
      die("putc to ip.map.new", 8);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea9(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b5 <main+0x45>
lea    0xe57(%rip),%rdi
mov    $0x1,%esi
call   1070 <die@plt>
lea    0xe5d(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e8 <main+0x78>
lea    0xe35(%rip),%rdi
mov    $0x2,%esi
call   1070 <die@plt>
movq   $0x0,-0x20(%rbp)
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
movabs $0x100000000,%rax
cmp    %rax,-0x20(%rbp)
jge    134d <main+0x1dd>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    125d <main+0xed>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    1249 <main+0xd9>
lea    0xde5(%rip),%rdi
mov    $0x3,%esi
call   1070 <die@plt>
lea    -0x130(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
call   1080 <extract@plt>
cmpq   $0x2d35fbc0,-0x20(%rbp)
2d
je     1279 <main+0x109>
cmpq   $0x6c38430d,-0x20(%rbp)
6c
jne    12a5 <main+0x135>
mov    -0x20(%rbp),%rsi
mov    -0x2a(%rbp),%dx
movswl -0x2a(%rbp),%ecx
and    $0xff,%ecx
movswl -0x2a(%rbp),%eax
sar    $0x8,%eax
lea    0xda4(%rip),%rdi
movswl %dx,%edx
movswl %ax,%r8d
call   1030 <printf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x138(%rbp)
movswl -0x2a(%rbp),%eax
and    $0xff,%eax
mov    -0x18(%rbp),%rsi
movswl %ax,%edi
call   1050 <putc@plt>
mov    %rax,%rcx
mov    -0x138(%rbp),%rax
cmp    %rcx,%rax
jne    12ef <main+0x17f>
lea    0xd6e(%rip),%rdi
mov    $0x7,%esi
call   1070 <die@plt>
mov    0x2cf2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x140(%rbp)
movswl -0x2a(%rbp),%eax
sar    $0x8,%eax
mov    -0x18(%rbp),%rsi
movswl %ax,%edi
call   1050 <putc@plt>
mov    %rax,%rcx
mov    -0x140(%rbp),%rax
cmp    %rcx,%rax
jne    1337 <main+0x1c7>
lea    0xd26(%rip),%rdi
mov    $0x8,%esi
call   1070 <die@plt>
jmp    133c <main+0x1cc>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11f8 <main+0x88>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
lea    0xeaa(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
jne    11af <main+0x3f>
lea    0xe5d(%rip),%rdi
mov    $0x1,%esi
call   1070 <die@plt>
lea    0xe63(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11db <main+0x6b>
lea    0xe42(%rip),%rdi
mov    $0x2,%esi
call   1070 <die@plt>
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
mov    $0xffffffffffffffff,%rax
xor    %ebx,%ebx
lea    0x20(%rsp),%r14
mov    0x2def(%rip),%r13
cmp    %rax,%rbx
jle    1239 <main+0xc9>
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x100,%esi
mov    0x18(%rsp),%rdx
call   1040 <fgets@plt>
test   %eax,%eax
jne    1227 <main+0xb7>
lea    0xe07(%rip),%rdi
mov    $0x3,%esi
call   1070 <die@plt>
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
lea    0xe(%rsp),%rdx
call   1080 <extract@plt>
cmp    $0x6c38430d,%rbx
je     124b <main+0xdb>
cmp    $0x2d35fbc0,%rbx
jne    1269 <main+0xf9>
movswl 0xe(%rsp),%edx
movzbl %dl,%ecx
mov    %edx,%r8d
sar    $0x8,%r8d
lea    0xddc(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%r12
movzbl 0xe(%rsp),%edi
mov    %r15,%rsi
call   1050 <putc@plt>
cmp    %rax,%r12
jne    1290 <main+0x120>
lea    0xdcd(%rip),%rdi
mov    $0x7,%esi
call   1070 <die@plt>
mov    0x0(%r13),%rbp
movsbl 0xf(%rsp),%edi
mov    %r15,%rsi
call   1050 <putc@plt>
cmp    %rax,%rbp
jne    12b7 <main+0x147>
lea    0xda6(%rip),%rdi
mov    $0x8,%esi
call   1070 <die@plt>
mov    $0xffffffff,%eax
cmp    %rax,%rbx
je     12d8 <main+0x168>
mov    0x10(%rsp),%rax
add    $0x1,%rbx
cmp    %rax,%rbx
jg     1200 <main+0x90>
jmp    1239 <main+0xc9>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"ip-nub.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"fopen ip-nub.csv\00"
@.str.3 = [11 x i8] c"ip.map.new\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [17 x i8] c"fopen ip.map.new\00"
@.str.6 = [25 x i8] c"fgets line of ip-nub.csv\00"
@.str.7 = [22 x i8] c"ip: %ld, %d (%d, %d)\0A\00"
@EOF = global i64 0
@.str.8 = [19 x i8] c"putc to ip.map.new\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i16
%7 = alloca [256 x i8]
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp ne i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 @die(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %13
13: ; preds = %11, %0
%14 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %14, i32** %3
%15 = load i32*, i32** %3
%16 = icmp ne i32* %15, null
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @die(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 2)
br label %19
19: ; preds = %17, %13
store i64 0, i64* %4
store i64 -1, i64* %5
br label %20
20: ; preds = %77, %19
%21 = load i64, i64* %4
%22 = icmp slt i64 %21, 4294967296
br i1 %22, label %23, label %80
23: ; preds = %20
%24 = load i64, i64* %4
%25 = load i64, i64* %5
%26 = icmp sgt i64 %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%29 = load i32*, i32** %2
%30 = call i32 @fgets(i8* %28, i32 256, i32* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %27
%33 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 3)
br label %34
34: ; preds = %32, %27
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%36 = call i32 @extract(i8* %35, i64* %5, i16* %6)
br label %37
37: ; preds = %34, %23
%38 = load i64, i64* %4
%39 = icmp eq i64 %38, 758512576
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i64, i64* %4
%42 = icmp eq i64 %41, 1815626509
br i1 %42, label %43, label %54
43: ; preds = %40, %37
%44 = load i64, i64* %4
%45 = load i16, i16* %6
%46 = load i16, i16* %6
%47 = sext i16 %46 to i32
%48 = and i32 255, %47
%49 = load i16, i16* %6
%50 = sext i16 %49 to i32
%51 = ashr i32 %50, 8
%52 = trunc i32 %51 to i16
%53 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i64 %44, i16 signext %45, i32 %48, i16 signext %52)
br label %54
54: ; preds = %43, %40
%55 = load i64, i64* @EOF
%56 = load i16, i16* %6
%57 = sext i16 %56 to i32
%58 = and i32 255, %57
%59 = trunc i32 %58 to i16
%60 = load i32*, i32** %3
%61 = call i64 @putc(i16 signext %59, i32* %60)
%62 = icmp eq i64 %55, %61
br i1 %62, label %63, label %65
63: ; preds = %54
%64 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 7)
br label %65
65: ; preds = %63, %54
%66 = load i64, i64* @EOF
%67 = load i16, i16* %6
%68 = sext i16 %67 to i32
%69 = ashr i32 %68, 8
%70 = trunc i32 %69 to i16
%71 = load i32*, i32** %3
%72 = call i64 @putc(i16 signext %70, i32* %71)
%73 = icmp eq i64 %66, %72
br i1 %73, label %74, label %76
74: ; preds = %65
%75 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 8)
br label %76
76: ; preds = %74, %65
br label %77
77: ; preds = %76
%78 = load i64, i64* %4
%79 = add nsw i64 %78, 1
store i64 %79, i64* %4
br label %20
80: ; preds = %20
%81 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"ip-nub.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"fopen ip-nub.csv\00"
@.str.3 = [11 x i8] c"ip.map.new\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [17 x i8] c"fopen ip.map.new\00"
@.str.6 = [25 x i8] c"fgets line of ip-nub.csv\00"
@.str.7 = [22 x i8] c"ip: %ld, %d (%d, %d)\0A\00"
@EOF = global i64 0
@.str.8 = [19 x i8] c"putc to ip.map.new\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i16
%3 = alloca [256 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @die(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %8
8: ; preds = %6, %0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @die(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 2)
br label %13
13: ; preds = %11, %8
%14 = bitcast i64* %1 to i8*
%15 = bitcast i16* %2 to i8*
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i64 -1, i64* %1
br label %17
17: ; preds = %54, %13
%18 = phi i64 [ -1, %13 ], [ %55, %54 ]
%19 = phi i64 [ 0, %13 ], [ %52, %54 ]
%20 = icmp sgt i64 %19, %18
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = call i32 @fgets(i8* %16, i32 256, i32* %4)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 3)
br label %26
26: ; preds = %24, %21
%27 = call i32 @extract(i8* %16, i64* %1, i16* %2)
br label %28
28: ; preds = %26, %17
switch i64 %19, label %35 [
i64 1815626509, label %29
i64 758512576, label %29
]
29: ; preds = %28, %28
%30 = load i16, i16* %2
%31 = and i16 %30, 255
%32 = zext i16 %31 to i32
%33 = ashr i16 %30, 8
%34 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i64 %19, i16 signext %30, i32 %32, i16 signext %33)
br label %35
35: ; preds = %28, %29
%36 = load i64, i64* @EOF
%37 = load i16, i16* %2
%38 = and i16 %37, 255
%39 = call i64 @putc(i16 signext %38, i32* %9)
%40 = icmp eq i64 %36, %39
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 7)
br label %43
43: ; preds = %41, %35
%44 = load i64, i64* @EOF
%45 = load i16, i16* %2
%46 = ashr i16 %45, 8
%47 = call i64 @putc(i16 signext %46, i32* %9)
%48 = icmp eq i64 %44, %47
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 8)
br label %51
51: ; preds = %43, %49
%52 = add nuw nsw i64 %19, 1
%53 = icmp eq i64 %52, 4294967296
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = load i64, i64* %1
br label %17
56: ; preds = %51
%57 = call i32 @exit(i32 0)
unreachable
}