#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  unsigned char *data;
  int length;
};
typedef int /*<<< orphan*/ BIO;
typedef TYPE_1__ ASN1_OCTET_STRING;

/* Variables and functions */
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ BIO_puts(int /*<<< orphan*/ *, char *);
int print_nc_ipadd(BIO *bp, ASN1_OCTET_STRING *ip) {
  int i, len;
  unsigned char *p;
  p = ip->data;
  len = ip->length;
  BIO_puts(bp, "IP:");
  if (len == 8) {
    BIO_printf(bp, "%d.%d.%d.%d/%d.%d.%d.%d", p[0], p[1], p[2], p[3], p[4],
               p[5], p[6], p[7]);
  } else if (len == 32) {
    for (i = 0; i < 16; i++) {
      BIO_printf(bp, "%X", p[0] << 8 | p[1]);
      p += 2;
      if (i == 7)
        BIO_puts(bp, "/");
      else if (i != 15)
        BIO_puts(bp, ":");
    }
  } else
    BIO_printf(bp, "IP Address:<invalid>");
  return 1;
}


x86 assembly (clang, -O0):
<print_nc_ipadd>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1040 <BIO_puts@plt>
cmpl   $0x8,-0x20(%rbp)
jne    11cb <print_nc_ipadd+0xab>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
movzbl (%rax),%edx
mov    -0x28(%rbp),%rax
movzbl 0x1(%rax),%ecx
mov    -0x28(%rbp),%rax
movzbl 0x2(%rax),%r8d
mov    -0x28(%rbp),%rax
movzbl 0x3(%rax),%r9d
mov    -0x28(%rbp),%rax
movzbl 0x4(%rax),%ebx
mov    -0x28(%rbp),%rax
movzbl 0x5(%rax),%r11d
mov    -0x28(%rbp),%rax
movzbl 0x6(%rax),%r10d
mov    -0x28(%rbp),%rax
movzbl 0x7(%rax),%eax
lea    0xe56(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1030 <BIO_printf@plt>
jmp    1285 <print_nc_ipadd+0x165>
cmpl   $0x20,-0x20(%rbp)
jne    126e <print_nc_ipadd+0x14e>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    1269 <print_nc_ipadd+0x149>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
movzbl (%rax),%edx
shl    $0x8,%edx
mov    -0x28(%rbp),%rax
movzbl 0x1(%rax),%eax
or     %eax,%edx
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jne    1237 <print_nc_ipadd+0x117>
mov    -0x10(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1040 <BIO_puts@plt>
jmp    1256 <print_nc_ipadd+0x136>
cmpl   $0xf,-0x1c(%rbp)
je     1251 <print_nc_ipadd+0x131>
mov    -0x10(%rbp),%rdi
lea    0xdb6(%rip),%rsi
call   1040 <BIO_puts@plt>
jmp    1256 <print_nc_ipadd+0x136>
jmp    125b <print_nc_ipadd+0x13b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11dc <print_nc_ipadd+0xbc>
jmp    1280 <print_nc_ipadd+0x160>
mov    -0x10(%rbp),%rdi
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1030 <BIO_printf@plt>
jmp    1285 <print_nc_ipadd+0x165>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_nc_ipadd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rsi),%r15
mov    0x8(%rsi),%ebp
lea    0xec5(%rip),%rsi
call   1040 <BIO_puts@plt>
cmp    $0x8,%ebp
je     11a5 <print_nc_ipadd+0x85>
cmp    $0x20,%ebp
jne    11ea <print_nc_ipadd+0xca>
lea    0xec7(%rip),%r14
lea    0xec3(%rip),%r12
lea    0xe9f(%rip),%r13
xor    %ebp,%ebp
jmp    117c <print_nc_ipadd+0x5c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <BIO_puts@plt>
add    $0x1,%rbp
movzwl (%r15,%rbp,2),%edx
shl    $0x10,%edx
bswap  %edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
mov    %r12,%rsi
cmp    $0x7,%ebp
je     1170 <print_nc_ipadd+0x50>
cmp    $0xf,%ebp
je     11fb <print_nc_ipadd+0xdb>
mov    %r13,%rsi
jmp    1170 <print_nc_ipadd+0x50>
movzbl (%r15),%edx
movzbl 0x1(%r15),%ecx
movzbl 0x2(%r15),%r8d
movzbl 0x3(%r15),%r9d
movzbl 0x4(%r15),%r10d
movzbl 0x5(%r15),%r11d
movzbl 0x6(%r15),%r14d
movzbl 0x7(%r15),%ebp
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
push   %rbp
push   %r14
push   %r11
push   %r10
call   1030 <BIO_printf@plt>
add    $0x20,%rsp
jmp    11fb <print_nc_ipadd+0xdb>
lea    0xe30(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <BIO_printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i32 }
@.str = [4 x i8] c"IP:\00"
@.str.1 = [24 x i8] c"%d.%d.%d.%d/%d.%d.%d.%d\00"
@.str.2 = [3 x i8] c"%X\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [2 x i8] c":\00"
@.str.5 = [21 x i8] c"IP Address:<invalid>\00"
define i32 @print_nc_ipadd(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i8*, i8** %9
store i8* %10, i8** %7
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 1
%13 = load i32, i32* %12
store i32 %13, i32* %6
%14 = load i32*, i32** %3
%15 = call i32 @BIO_puts(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 8
br i1 %17, label %18, label %53
18: ; preds = %2
%19 = load i32*, i32** %3
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 4
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i64 5
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i64 6
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i64 7
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %27, i32 %31, i32 %35, i32 %39, i32 %43, i32 %47, i32 %51)
br label %96
53: ; preds = %2
%54 = load i32, i32* %6
%55 = icmp eq i32 %54, 32
br i1 %55, label %56, label %92
56: ; preds = %53
store i32 0, i32* %5
br label %57
57: ; preds = %88, %56
%58 = load i32, i32* %5
%59 = icmp slt i32 %58, 16
br i1 %59, label %60, label %91
60: ; preds = %57
%61 = load i32*, i32** %3
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i64 0
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = shl i32 %65, 8
%67 = load i8*, i8** %7
%68 = getelementptr inbounds i8, i8* %67, i64 1
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = or i32 %66, %70
%72 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %71)
%73 = load i8*, i8** %7
%74 = getelementptr inbounds i8, i8* %73, i64 2
store i8* %74, i8** %7
%75 = load i32, i32* %5
%76 = icmp eq i32 %75, 7
br i1 %76, label %77, label %80
77: ; preds = %60
%78 = load i32*, i32** %3
%79 = call i32 @BIO_puts(i32* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %87
80: ; preds = %60
%81 = load i32, i32* %5
%82 = icmp ne i32 %81, 15
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load i32*, i32** %3
%85 = call i32 @BIO_puts(i32* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %86
86: ; preds = %83, %80
br label %87
87: ; preds = %86, %77
br label %88
88: ; preds = %87
%89 = load i32, i32* %5
%90 = add nsw i32 %89, 1
store i32 %90, i32* %5
br label %57
91: ; preds = %57
br label %95
92: ; preds = %53
%93 = load i32*, i32** %3
%94 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %93, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %95
95: ; preds = %92, %91
br label %96
96: ; preds = %95, %18
ret i32 1
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i32 }
@.str = [4 x i8] c"IP:\00"
@.str.1 = [24 x i8] c"%d.%d.%d.%d/%d.%d.%d.%d\00"
@.str.2 = [3 x i8] c"%X\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [2 x i8] c":\00"
@.str.5 = [21 x i8] c"IP Address:<invalid>\00"
define i32 @print_nc_ipadd(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%4 = load i8*, i8** %3
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%6 = load i32, i32* %5
%7 = tail call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %50 [
i32 8, label %8
i32 32, label %33
]
8: ; preds = %2
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = getelementptr inbounds i8, i8* %4, i64 1
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = getelementptr inbounds i8, i8* %4, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = getelementptr inbounds i8, i8* %4, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = getelementptr inbounds i8, i8* %4, i64 4
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = getelementptr inbounds i8, i8* %4, i64 5
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = getelementptr inbounds i8, i8* %4, i64 6
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = getelementptr inbounds i8, i8* %4, i64 7
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %13, i32 %16, i32 %19, i32 %22, i32 %25, i32 %28, i32 %31)
br label %52
33: ; preds = %2, %46
%34 = phi i8* [ %44, %46 ], [ %4, %2 ]
%35 = phi i32 [ %49, %46 ], [ 0, %2 ]
%36 = load i8, i8* %34
%37 = zext i8 %36 to i32
%38 = shl nuw nsw i32 %37, 8
%39 = getelementptr inbounds i8, i8* %34, i64 1
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = or i32 %38, %41
%43 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds i8, i8* %34, i64 2
switch i32 %35, label %45 [
i32 7, label %46
i32 15, label %52
]
45: ; preds = %33
br label %46
46: ; preds = %33, %45
%47 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %45 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %33 ]
%48 = tail call i32 @BIO_puts(i32* %0, i8* %47)
%49 = add nuw nsw i32 %35, 1
br label %33
50: ; preds = %2
%51 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %33, %50, %8
ret i32 1
}