#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 sockaddr_in6 {
  int dummy;
};
struct in6_addr {
  int dummy;
};
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int INET6_ADDRSTRLEN;
void *atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
unsigned short htons(unsigned short);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, struct in6_addr *, char *,
                             int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, struct in6_addr *);
int /*<<< orphan*/ mask_addr(struct in6_addr *, int);
char *optarg;
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
char *strstr(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  char str[INET6_ADDRSTRLEN];
  struct sockaddr_in6 sa6;
  char *prgName = NULL;
  long offset = 0;
  int c;
  struct in6_addr addr;
  struct in6_addr suffix;
  char *prefix = NULL;
  char *id = NULL;
  int mb = 64;
  char *s = NULL;
  if ((prgName = strrchr(argv[0], '/')))
    prgName++;
  else
    prgName = argv[0];
  while ((c = getopt(argc, argv, "i:hp:o:")) > 0) {
    switch (c) {
    case 'i':
      id = optarg;
      break;
    case 'p':
      prefix = strdup(optarg);
      break;
    case 'o':
      offset = atoi(optarg);
      break;
    default:
      usage(prgName);
      return 1;
      break;
    }
  }
  if (id) {
    if (strstr(id, "::") == id) {
      strncpy(str, id, INET6_ADDRSTRLEN);
    } else {
      strcpy(str, "::");
      strncat(str, id, INET6_ADDRSTRLEN - 2);
    }
    str[INET6_ADDRSTRLEN - 1] = '\0';
    inet_pton(AF_INET6, str, &suffix);
  }
  if (prefix && (s = strchr(prefix, '/'))) {
    mb = atoi(s + 1);
    *s = '\0';
    if (mb > 64) {
      fprintf(stderr, "%s: subnet > 64 not supported\n", prgName);
      return 1;
    } else {
      inet_pton(AF_INET6, prefix, &addr);
      mask_addr(&addr, mb);
      inet_ntop(AF_INET6, &addr, str, sizeof(str));
      printf("%s/%d\n", str, mb);
      return 0;
    }
  }
  if (prefix && strstr(prefix, "::") && !strchr(prefix, '/')) {
    struct in6_addr addr;
    inet_pton(AF_INET6, prefix, &addr);
    unsigned short *ad16 = (unsigned short *)&addr;
    ad16 += 3;
    unsigned short s = htons(*ad16);
    s += offset;
    *ad16 = htons(s);
    if (id) {
      unsigned short *s16 = (unsigned short *)&suffix;
      s16 += 4;
      ad16++;
      int i;
      for (i = 0; i < 4; i++)
        *ad16++ = *s16++;
    }
    inet_ntop(AF_INET6, &addr, str, sizeof(str));
    printf("%s\n", str);
    return 0;
  }
  usage(prgName);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xa0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x40,-0x5c(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   10a0 <strrchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     12ae <main+0xae>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12b9 <main+0xb9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    12be <main+0xbe>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd34(%rip),%rdx
call   10f0 <getopt@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jle    1380 <main+0x180>
mov    -0x3c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
sub    $0x69,%eax
je     131c <main+0x11c>
jmp    12f4 <main+0xf4>
mov    -0xa4(%rbp),%eax
sub    $0x6f,%eax
je     1347 <main+0x147>
jmp    1308 <main+0x108>
mov    -0xa4(%rbp),%eax
sub    $0x70,%eax
je     132f <main+0x12f>
jmp    135f <main+0x15f>
mov    0x2cd5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    137b <main+0x17b>
mov    0x2cc2(%rip),%rax
mov    (%rax),%rdi
call   1110 <strdup@plt>
mov    %rax,-0x50(%rbp)
jmp    137b <main+0x17b>
mov    0x2caa(%rip),%rax
mov    (%rax),%rdi
call   1100 <atoi@plt>
mov    %rax,-0x38(%rbp)
jmp    137b <main+0x17b>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1688 <main+0x488>
jmp    12be <main+0xbe>
cmpq   $0x0,-0x58(%rbp)
je     141d <main+0x21d>
mov    -0x58(%rbp),%rdi
lea    0xc72(%rip),%rsi
call   1120 <strstr@plt>
cmp    -0x58(%rbp),%rax
jne    13c3 <main+0x1c3>
mov    -0x98(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
call   1040 <strncpy@plt>
jmp    13f2 <main+0x1f2>
mov    -0x98(%rbp),%rdi
lea    0xc37(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x98(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x2bf8(%rip),%rax
mov    (%rax),%edx
sub    $0x2,%edx
call   10b0 <strncat@plt>
mov    -0x98(%rbp),%rsi
mov    0x2be0(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
cltq
movb   $0x0,(%rsi,%rax,1)
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rdx
call   10d0 <inet_pton@plt>
cmpq   $0x0,-0x50(%rbp)
je     1500 <main+0x300>
mov    -0x50(%rbp),%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
je     1500 <main+0x300>
mov    -0x68(%rbp),%rdi
add    $0x1,%rdi
call   1100 <atoi@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x40,-0x5c(%rbp)
jle    1491 <main+0x291>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xb92(%rip),%rsi
call   10c0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1688 <main+0x488>
mov    0x2b40(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   10d0 <inet_pton@plt>
mov    -0x5c(%rbp),%esi
lea    -0x40(%rbp),%rdi
call   1060 <mask_addr@plt>
mov    -0x98(%rbp),%rdx
mov    -0xa0(%rbp),%rax
mov    0x2b10(%rip),%rcx
mov    (%rcx),%edi
mov    %eax,%ecx
lea    -0x40(%rbp),%rsi
call   1030 <inet_ntop@plt>
mov    -0x98(%rbp),%rsi
mov    -0x5c(%rbp),%edx
lea    0xb44(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1688 <main+0x488>
cmpq   $0x0,-0x50(%rbp)
je     1671 <main+0x471>
mov    -0x50(%rbp),%rdi
lea    0xaf2(%rip),%rsi
call   1120 <strstr@plt>
cmp    $0x0,%rax
je     1671 <main+0x471>
mov    -0x50(%rbp),%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
cmp    $0x0,%rax
jne    1671 <main+0x471>
mov    0x2a94(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   10d0 <inet_pton@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
movzwl (%rax),%edi
call   1070 <htons@plt>
mov    %ax,-0x7a(%rbp)
mov    -0x38(%rbp),%rcx
movzwl -0x7a(%rbp),%eax
add    %rcx,%rax
mov    %ax,-0x7a(%rbp)
movzwl -0x7a(%rbp),%edi
call   1070 <htons@plt>
mov    %ax,%cx
mov    -0x78(%rbp),%rax
mov    %cx,(%rax)
cmpq   $0x0,-0x58(%rbp)
je     1627 <main+0x427>
lea    -0x48(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x88(%rbp)
mov    -0x78(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x8c(%rbp)
cmpl   $0x4,-0x8c(%rbp)
jge    1622 <main+0x422>
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x88(%rbp)
mov    (%rax),%cx
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x2,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cx,(%rax)
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    15d7 <main+0x3d7>
jmp    1627 <main+0x427>
mov    -0x98(%rbp),%rdx
mov    -0xa0(%rbp),%rax
mov    0x299c(%rip),%rcx
mov    (%rcx),%edi
mov    %eax,%ecx
lea    -0x70(%rbp),%rsi
call   1030 <inet_ntop@plt>
mov    -0x98(%rbp),%rsi
lea    0x9da(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1688 <main+0x488>
mov    -0x30(%rbp),%rdi
call   10e0 <usage@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
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    $0x48,%rsp
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
mov    %rax,-0x48(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rsi),%r14
mov    %r14,%rdi
mov    $0x2f,%esi
call   10b0 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %r14,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xd95(%rip),%rdx
mov    %r12d,%edi
mov    %r15,%rsi
call   1100 <getopt@plt>
test   %eax,%eax
jle    1442 <main+0x232>
mov    %rbx,-0x60(%rbp)
xor    %ecx,%ecx
mov    %rcx,-0x58(%rbp)
mov    0x2d69(%rip),%r13
lea    0xd6a(%rip),%r14
xor    %ebx,%ebx
xor    %ecx,%ecx
mov    %rcx,-0x50(%rbp)
jmp    12be <main+0xae>
mov    0x0(%r13),%rdi
call   1120 <strdup@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1100 <getopt@plt>
test   %eax,%eax
jle    12ef <main+0xdf>
cmp    $0x70,%eax
je     12a0 <main+0x90>
cmp    $0x6f,%eax
je     12e0 <main+0xd0>
cmp    $0x69,%eax
jne    1442 <main+0x232>
mov    0x0(%r13),%rax
mov    %rax,-0x58(%rbp)
jmp    12ac <main+0x9c>
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%rdi
call   1110 <atoi@plt>
mov    %rax,-0x50(%rbp)
jmp    12ac <main+0x9c>
mov    -0x58(%rbp),%r12
test   %r12,%r12
mov    -0x60(%rbp),%r13
mov    %rbx,%r14
je     1371 <main+0x161>
lea    0xd02(%rip),%rsi
mov    $0x2,%edx
mov    %r12,%rdi
call   1050 <strncmp@plt>
test   %eax,%eax
je     133f <main+0x12f>
lea    0xcea(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcpy@plt>
mov    0x2cb3(%rip),%rbx
mov    (%rbx),%edx
add    $0xfffffffe,%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   10c0 <strncat@plt>
jmp    1353 <main+0x143>
mov    0x2c9a(%rip),%rbx
mov    (%rbx),%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strncpy@plt>
movslq (%rbx),%rax
movb   $0x0,-0x1(%rax,%r13,1)
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
mov    %r13,%rsi
call   10e0 <inet_pton@plt>
test   %r14,%r14
je     1442 <main+0x232>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     13ca <main+0x1ba>
mov    %rax,%r15
mov    %rax,%rdi
add    $0x1,%rdi
call   1110 <atoi@plt>
mov    %rax,%r12
movb   $0x0,(%r15)
cmp    $0x41,%r12d
jl     1461 <main+0x251>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
lea    0xc4f(%rip),%rsi
mov    -0x38(%rbp),%rdx
call   10d0 <fprintf@plt>
jmp    144b <main+0x23b>
lea    0xc37(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
test   %rax,%rax
je     1442 <main+0x232>
mov    0x2bf3(%rip),%rbx
mov    (%rbx),%edi
lea    -0x30(%rbp),%rdx
mov    %r14,%rsi
call   10e0 <inet_pton@plt>
movzwl -0x2a(%rbp),%edi
call   1080 <htons@plt>
mov    -0x50(%rbp),%rcx
add    %eax,%ecx
movzwl %cx,%edi
call   1080 <htons@plt>
mov    %ax,-0x2a(%rbp)
test   %r12,%r12
je     141b <main+0x20b>
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    (%rbx),%edi
lea    -0x30(%rbp),%rsi
mov    %r13,%rdx
mov    -0x48(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xbfd(%rip),%rdi
xor    %ebx,%ebx
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    1450 <main+0x240>
mov    -0x38(%rbp),%rdi
call   10f0 <usage@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b70(%rip),%rbx
mov    (%rbx),%edi
lea    -0x68(%rbp),%r15
mov    %r14,%rsi
mov    %r15,%rdx
call   10e0 <inet_pton@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1070 <mask_addr@plt>
mov    (%rbx),%edi
mov    %r15,%rsi
mov    %r13,%rdx
mov    -0x48(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xb8e(%rip),%rdi
xor    %ebx,%ebx
mov    %r13,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    1450 <main+0x240>

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
%struct.in6_addr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [8 x i8] c"i:hp:o:\00"
@optarg = global i8* null
@.str.1 = [3 x i8] c"::\00"
@AF_INET6 = global i32 0
@stderr = global i32 0
@.str.2 = [31 x i8] c"%s: subnet > 64 not supported\0A\00"
@.str.3 = [7 x i8] c"%s/%d\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.sockaddr_in6
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca %struct.in6_addr
%13 = alloca %struct.in6_addr
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32
%19 = alloca %struct.in6_addr
%20 = alloca i16*
%21 = alloca i16
%22 = alloca i16*
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = load i32, i32* @INET6_ADDRSTRLEN
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %6
%27 = alloca i8, i64 %25
store i64 %25, i64* %7
store i8* null, i8** %9
store i64 0, i64* %10
store i8* null, i8** %14
store i8* null, i8** %15
store i32 64, i32* %16
store i8* null, i8** %17
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i8* @strrchr(i8* %30, i8 signext 47)
store i8* %31, i8** %9
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %2
%34 = load i8*, i8** %9
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %9
br label %40
36: ; preds = %2
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
store i8* %39, i8** %9
br label %40
40: ; preds = %36, %33
br label %41
41: ; preds = %60, %40
%42 = load i32, i32* %4
%43 = load i8**, i8*** %5
%44 = call i32 @getopt(i32 %42, i8** %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %44, i32* %11
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %61
46: ; preds = %41
%47 = load i32, i32* %11
switch i32 %47, label %57 [
i32 105, label %48
i32 112, label %50
i32 111, label %53
]
48: ; preds = %46
%49 = load i8*, i8** @optarg
store i8* %49, i8** %15
br label %60
50: ; preds = %46
%51 = load i8*, i8** @optarg
%52 = call i8* @strdup(i8* %51)
store i8* %52, i8** %14
br label %60
53: ; preds = %46
%54 = load i8*, i8** @optarg
%55 = call i8* @atoi(i8* %54)
%56 = ptrtoint i8* %55 to i64
store i64 %56, i64* %10
br label %60
57: ; preds = %46
%58 = load i8*, i8** %9
%59 = call i32 @usage(i8* %58)
store i32 1, i32* %3
store i32 1, i32* %18
br label %174
60: ; preds = %53, %50, %48
br label %41
61: ; preds = %41
%62 = load i8*, i8** %15
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %86
64: ; preds = %61
%65 = load i8*, i8** %15
%66 = call i8* @strstr(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%67 = load i8*, i8** %15
%68 = icmp eq i8* %66, %67
br i1 %68, label %69, label %73
69: ; preds = %64
%70 = load i8*, i8** %15
%71 = load i32, i32* @INET6_ADDRSTRLEN
%72 = call i32 @strncpy(i8* %27, i8* %70, i32 %71)
br label %79
73: ; preds = %64
%74 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%75 = load i8*, i8** %15
%76 = load i32, i32* @INET6_ADDRSTRLEN
%77 = sub nsw i32 %76, 2
%78 = call i32 @strncat(i8* %27, i8* %75, i32 %77)
br label %79
79: ; preds = %73, %69
%80 = load i32, i32* @INET6_ADDRSTRLEN
%81 = sub nsw i32 %80, 1
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %27, i64 %82
store i8 0, i8* %83
%84 = load i32, i32* @AF_INET6
%85 = call i32 @inet_pton(i32 %84, i8* %27, %struct.in6_addr* %13)
br label %86
86: ; preds = %79, %61
%87 = load i8*, i8** %14
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %116
89: ; preds = %86
%90 = load i8*, i8** %14
%91 = call i8* @strchr(i8* %90, i8 signext 47)
store i8* %91, i8** %17
%92 = icmp ne i8* %91, null
br i1 %92, label %93, label %116
93: ; preds = %89
%94 = load i8*, i8** %17
%95 = getelementptr inbounds i8, i8* %94, i64 1
%96 = call i8* @atoi(i8* %95)
%97 = ptrtoint i8* %96 to i32
store i32 %97, i32* %16
%98 = load i8*, i8** %17
store i8 0, i8* %98
%99 = load i32, i32* %16
%100 = icmp sgt i32 %99, 64
br i1 %100, label %101, label %105
101: ; preds = %93
%102 = load i32, i32* @stderr
%103 = load i8*, i8** %9
%104 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %103)
store i32 1, i32* %3
store i32 1, i32* %18
br label %174
105: ; preds = %93
%106 = load i32, i32* @AF_INET6
%107 = load i8*, i8** %14
%108 = call i32 @inet_pton(i32 %106, i8* %107, %struct.in6_addr* %12)
%109 = load i32, i32* %16
%110 = call i32 @mask_addr(%struct.in6_addr* %12, i32 %109)
%111 = load i32, i32* @AF_INET6
%112 = trunc i64 %25 to i32
%113 = call i32 @inet_ntop(i32 %111, %struct.in6_addr* %12, i8* %27, i32 %112)
%114 = load i32, i32* %16
%115 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %27, i32 %114)
store i32 0, i32* %3
store i32 1, i32* %18
br label %174
116: ; preds = %89, %86
%117 = load i8*, i8** %14
%118 = icmp ne i8* %117, null
br i1 %118, label %119, label %171
119: ; preds = %116
%120 = load i8*, i8** %14
%121 = call i8* @strstr(i8* %120, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%122 = icmp ne i8* %121, null
br i1 %122, label %123, label %171
123: ; preds = %119
%124 = load i8*, i8** %14
%125 = call i8* @strchr(i8* %124, i8 signext 47)
%126 = icmp ne i8* %125, null
br i1 %126, label %171, label %127
127: ; preds = %123
%128 = load i32, i32* @AF_INET6
%129 = load i8*, i8** %14
%130 = call i32 @inet_pton(i32 %128, i8* %129, %struct.in6_addr* %19)
%131 = bitcast %struct.in6_addr* %19 to i16*
store i16* %131, i16** %20
%132 = load i16*, i16** %20
%133 = getelementptr inbounds i16, i16* %132, i64 3
store i16* %133, i16** %20
%134 = load i16*, i16** %20
%135 = load i16, i16* %134
%136 = call zeroext i16 @htons(i16 zeroext %135)
store i16 %136, i16* %21
%137 = load i64, i64* %10
%138 = load i16, i16* %21
%139 = zext i16 %138 to i64
%140 = add nsw i64 %139, %137
%141 = trunc i64 %140 to i16
store i16 %141, i16* %21
%142 = load i16, i16* %21
%143 = call zeroext i16 @htons(i16 zeroext %142)
%144 = load i16*, i16** %20
store i16 %143, i16* %144
%145 = load i8*, i8** %15
%146 = icmp ne i8* %145, null
br i1 %146, label %147, label %166
147: ; preds = %127
%148 = bitcast %struct.in6_addr* %13 to i16*
store i16* %148, i16** %22
%149 = load i16*, i16** %22
%150 = getelementptr inbounds i16, i16* %149, i64 4
store i16* %150, i16** %22
%151 = load i16*, i16** %20
%152 = getelementptr inbounds i16, i16* %151, i32 1
store i16* %152, i16** %20
store i32 0, i32* %23
br label %153
153: ; preds = %162, %147
%154 = load i32, i32* %23
%155 = icmp slt i32 %154, 4
br i1 %155, label %156, label %165
156: ; preds = %153
%157 = load i16*, i16** %22
%158 = getelementptr inbounds i16, i16* %157, i32 1
store i16* %158, i16** %22
%159 = load i16, i16* %157
%160 = load i16*, i16** %20
%161 = getelementptr inbounds i16, i16* %160, i32 1
store i16* %161, i16** %20
store i16 %159, i16* %160
br label %162
162: ; preds = %156
%163 = load i32, i32* %23
%164 = add nsw i32 %163, 1
store i32 %164, i32* %23
br label %153
165: ; preds = %153
br label %166
166: ; preds = %165, %127
%167 = load i32, i32* @AF_INET6
%168 = trunc i64 %25 to i32
%169 = call i32 @inet_ntop(i32 %167, %struct.in6_addr* %19, i8* %27, i32 %168)
%170 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %27)
store i32 0, i32* %3
store i32 1, i32* %18
br label %174
171: ; preds = %123, %119, %116
%172 = load i8*, i8** %9
%173 = call i32 @usage(i8* %172)
store i32 1, i32* %3
store i32 1, i32* %18
br label %174
174: ; preds = %171, %166, %105, %101, %57
%175 = load i8*, i8** %6
%176 = load i32, i32* %3
ret i32 %176
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [8 x i8] c"i:hp:o:\00"
@optarg = global i8* null
@.str.1 = [3 x i8] c"::\00"
@AF_INET6 = global i32 0
@stderr = global i32 0
@.str.2 = [31 x i8] c"%s: subnet > 64 not supported\0A\00"
@.str.3 = [7 x i8] c"%s/%d\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.in6_addr
%4 = alloca %struct.in6_addr
%5 = alloca %struct.in6_addr
%6 = load i32, i32* @INET6_ADDRSTRLEN
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = bitcast %struct.in6_addr* %3 to i8*
%10 = bitcast %struct.in6_addr* %4 to i8*
%11 = load i8*, i8** %1
%12 = tail call i8* @strrchr(i8* dereferenceable(1) %11, i8 signext 47)
%13 = icmp eq i8* %12, null
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = select i1 %13, i8* %11, i8* %14
%16 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %105
18: ; preds = %2, %34
%19 = phi i32 [ %38, %34 ], [ %16, %2 ]
%20 = phi i8* [ %37, %34 ], [ null, %2 ]
%21 = phi i8* [ %36, %34 ], [ null, %2 ]
%22 = phi i64 [ %35, %34 ], [ 0, %2 ]
switch i32 %19, label %32 [
i32 105, label %23
i32 112, label %25
i32 111, label %28
]
23: ; preds = %18
%24 = load i8*, i8** @optarg
br label %34
25: ; preds = %18
%26 = load i8*, i8** @optarg
%27 = tail call i8* @strdup(i8* %26)
br label %34
28: ; preds = %18
%29 = load i8*, i8** @optarg
%30 = tail call i8* @atoi(i8* %29)
%31 = ptrtoint i8* %30 to i64
br label %34
32: ; preds = %18
%33 = tail call i32 @usage(i8* %15)
br label %107
34: ; preds = %28, %25, %23
%35 = phi i64 [ %31, %28 ], [ %22, %25 ], [ %22, %23 ]
%36 = phi i8* [ %21, %28 ], [ %27, %25 ], [ %21, %23 ]
%37 = phi i8* [ %20, %28 ], [ %20, %25 ], [ %24, %23 ]
%38 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%39 = icmp sgt i32 %38, 0
br i1 %39, label %18, label %40
40: ; preds = %34
%41 = icmp eq i8* %37, null
br i1 %41, label %60, label %42
42: ; preds = %40
%43 = tail call i32 @strncmp(i8* %37, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* @INET6_ADDRSTRLEN
%47 = call i32 @strncpy(i8* %8, i8* %37, i32 %46)
br label %53
48: ; preds = %42
%49 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%50 = load i32, i32* @INET6_ADDRSTRLEN
%51 = add nsw i32 %50, -2
%52 = call i32 @strncat(i8* %8, i8* %37, i32 %51)
br label %53
53: ; preds = %48, %45
%54 = load i32, i32* @INET6_ADDRSTRLEN
%55 = add nsw i32 %54, -1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %8, i64 %56
store i8 0, i8* %57
%58 = load i32, i32* @AF_INET6
%59 = call i32 @inet_pton(i32 %58, i8* %8, %struct.in6_addr* %4)
br label %60
60: ; preds = %53, %40
%61 = icmp eq i8* %36, null
br i1 %61, label %105, label %62
62: ; preds = %60
%63 = call i8* @strchr(i8* %36, i8 signext 47)
%64 = icmp eq i8* %63, null
br i1 %64, label %81, label %65
65: ; preds = %62
%66 = getelementptr inbounds i8, i8* %63, i64 1
%67 = call i8* @atoi(i8* %66)
%68 = ptrtoint i8* %67 to i64
%69 = trunc i64 %68 to i32
store i8 0, i8* %63
%70 = icmp sgt i32 %69, 64
br i1 %70, label %71, label %74
71: ; preds = %65
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %107
74: ; preds = %65
%75 = load i32, i32* @AF_INET6
%76 = call i32 @inet_pton(i32 %75, i8* %36, %struct.in6_addr* %3)
%77 = call i32 @mask_addr(%struct.in6_addr* %3, i32 %69)
%78 = load i32, i32* @AF_INET6
%79 = call i32 @inet_ntop(i32 %78, %struct.in6_addr* %3, i8* %8, i32 %6)
%80 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %69)
br label %107
81: ; preds = %62
%82 = call i8* @strstr(i8* %36, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%83 = icmp eq i8* %82, null
br i1 %83, label %105, label %84
84: ; preds = %81
%85 = bitcast %struct.in6_addr* %5 to i8*
%86 = load i32, i32* @AF_INET6
%87 = call i32 @inet_pton(i32 %86, i8* %36, %struct.in6_addr* %5)
%88 = bitcast %struct.in6_addr* %5 to i16*
%89 = getelementptr inbounds i16, i16* %88, i64 3
%90 = load i16, i16* %89
%91 = call zeroext i16 @htons(i16 zeroext %90)
%92 = trunc i64 %35 to i16
%93 = add i16 %91, %92
%94 = call zeroext i16 @htons(i16 zeroext %93)
store i16 %94, i16* %89
br i1 %41, label %101, label %95
95: ; preds = %84
%96 = getelementptr %struct.in6_addr, %struct.in6_addr* %4, i64 2
%97 = getelementptr %struct.in6_addr, %struct.in6_addr* %5, i64 2
%98 = bitcast %struct.in6_addr* %96 to i64*
%99 = bitcast %struct.in6_addr* %97 to i64*
%100 = load i64, i64* %98
store i64 %100, i64* %99
br label %101
101: ; preds = %95, %84
%102 = load i32, i32* @AF_INET6
%103 = call i32 @inet_ntop(i32 %102, %struct.in6_addr* %5, i8* %8, i32 %6)
%104 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %8)
br label %107
105: ; preds = %2, %60, %81
%106 = call i32 @usage(i8* %15)
br label %107
107: ; preds = %105, %101, %74, %71, %32
%108 = phi i32 [ 1, %32 ], [ 1, %71 ], [ 0, %74 ], [ 1, %105 ], [ 0, %101 ]
ret i32 %108
}