#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;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ inet_ntop(int /*<<< orphan*/, struct sockaddr_in6 *, char *, int);
int inet_pton(int /*<<< orphan*/, char const *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char const *, char *);
int main() {
  const char *rfc5952ly_correct = "2001:db8:0:1:1:1:1:1";
  const char *rfc5952ly_incorrect = "2001:db8::1:1:1:1:1";
  char outbuf[100];
  struct sockaddr_in6 addr6;
  if (inet_pton(AF_INET6, rfc5952ly_correct, (char *)&addr6) == -1) {
    fprintf(stderr, "Bug in inet_pton() call\n");
    exit(1);
  }
  if (inet_ntop(AF_INET6, &addr6, outbuf, 100) == 0) {
    fprintf(stderr, "Bug in inet_ntop() call\n");
    exit(2);
  }
  if (strcasecmp(rfc5952ly_correct, outbuf) == 0) {
    printf("Congratulations, your inet_ntop() conforms to RFC 5952 4.2.2\n");
  } else if (strcasecmp(rfc5952ly_incorrect, outbuf) == 0) {
    printf("ATTENTION: Your system's inet_ntop() violates RFC 5952 4.2.2!\n");
  } else {
    printf("ATTENTION: Your system's inet_ntop() may violate RFC 5952.\n");
    printf("Interestingly, rather than the expected\n \"%s\" (correct) or\n",
           rfc5952ly_correct);
    printf(" \"%s\" (incorrect), your system generates:\n \"%s\".\n",
           rfc5952ly_incorrect, outbuf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe91(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
lea    -0x88(%rbp),%rdx
call   1070 <inet_pton@plt>
cmp    $0xffffffff,%eax
jne    11c9 <main+0x69>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rdx
lea    -0x88(%rbp),%rsi
mov    $0x64,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    1210 <main+0xb0>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    123a <main+0xda>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129f <main+0x13f>
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1264 <main+0x104>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129a <main+0x13a>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129f <main+0x13f>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    0x2e69(%rip),%rbx
mov    (%rbx),%edi
lea    0xe78(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1080 <inet_pton@plt>
cmp    $0xffffffff,%eax
je     1243 <main+0xd3>
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    $0x64,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     1262 <main+0xf2>
lea    0xe3f(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     1223 <main+0xb3>
lea    0xe3e(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     122c <main+0xbc>
lea    0xedc(%rip),%rdi
call   1050 <puts@plt>
lea    0xe62(%rip),%rdi
lea    0xe00(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe89(%rip),%rdi
lea    0xe00(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1238 <main+0xc8>
lea    0xf18(%rip),%rdi
jmp    1233 <main+0xc3>
lea    0xed1(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
@.str = [21 x i8] c"2001:db8:0:1:1:1:1:1\00"
@.str.1 = [20 x i8] c"2001:db8::1:1:1:1:1\00"
@AF_INET6 = global i32 0
@stderr = global i32 0
@.str.2 = [25 x i8] c"Bug in inet_pton() call\0A\00"
@.str.3 = [25 x i8] c"Bug in inet_ntop() call\0A\00"
@.str.4 = [62 x i8] c"Congratulations, your inet_ntop() conforms to RFC 5952 4.2.2\0A\00"
@.str.5 = [63 x i8] c"ATTENTION: Your system's inet_ntop() violates RFC 5952 4.2.2!\0A\00"
@.str.6 = [60 x i8] c"ATTENTION: Your system's inet_ntop() may violate RFC 5952.\0A\00"
@.str.7 = [60 x i8] c"Interestingly, rather than the expected\0A \22%s\22 (correct) or\0A\00"
@.str.8 = [50 x i8] c" \22%s\22 (incorrect), your system generates:\0A \22%s\22.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [100 x i8]
%5 = alloca %struct.sockaddr_in6
store i32 0, i32* %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %3
%6 = load i32, i32* @AF_INET6
%7 = load i8*, i8** %2
%8 = bitcast %struct.sockaddr_in6* %5 to i8*
%9 = call i32 @inet_pton(i32 %6, i8* %7, i8* %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32, i32* @AF_INET6
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = call i64 @inet_ntop(i32 %16, %struct.sockaddr_in6* %5, i8* %17, i32 100)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @exit(i32 2)
unreachable
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%27 = call i64 @strcasecmp(i8* %25, i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
br label %46
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%34 = call i64 @strcasecmp(i8* %32, i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
br label %45
38: ; preds = %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%40 = load i8*, i8** %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %3
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i8* %42, i8* %43)
br label %45
45: ; preds = %38, %36
br label %46
46: ; preds = %45, %29
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32 }
@.str = [21 x i8] c"2001:db8:0:1:1:1:1:1\00"
@.str.1 = [20 x i8] c"2001:db8::1:1:1:1:1\00"
@AF_INET6 = global i32 0
@stderr = global i32 0
@.str.2 = [25 x i8] c"Bug in inet_pton() call\0A\00"
@.str.3 = [25 x i8] c"Bug in inet_ntop() call\0A\00"
@.str.7 = [60 x i8] c"Interestingly, rather than the expected\0A \22%s\22 (correct) or\0A\00"
@.str.8 = [50 x i8] c" \22%s\22 (incorrect), your system generates:\0A \22%s\22.\0A\00"
@str = [59 x i8] c"ATTENTION: Your system's inet_ntop() may violate RFC 5952.\00"
@str.9 = [62 x i8] c"ATTENTION: Your system's inet_ntop() violates RFC 5952 4.2.2!\00"
@str.10 = [61 x i8] c"Congratulations, your inet_ntop() conforms to RFC 5952 4.2.2\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca %struct.sockaddr_in6
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.sockaddr_in6* %2 to i8*
%5 = load i32, i32* @AF_INET6
%6 = call i32 @inet_pton(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = load i32, i32* @AF_INET6
%14 = call i64 @inet_ntop(i32 %13, %struct.sockaddr_in6* %2, i8* %3, i32 100)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 2)
unreachable
20: ; preds = %12
%21 = call i64 @strcasecmp(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.10, i64 0, i64 0))
br label %34
25: ; preds = %20
%26 = call i64 @strcasecmp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.9, i64 0, i64 0))
br label %34
30: ; preds = %25
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %34
34: ; preds = %28, %30, %23
ret i32 0
}