#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 */

/* Variables and functions */
char *do_nofail(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int, unsigned int,
                           unsigned int, unsigned int);
int sscanf(char const *, char *, unsigned int *, unsigned int *);
int /*<<< orphan*/ strdup(char *);
char *convert_teredo(const char *s) {
  char *new;
  unsigned int a, b;
  if (sscanf(s, "2001:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%x:%x", &a, &b) != 2)
    return do_nofail((strdup("0.0.0.0")),
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/"
                     "master/deps/whois/whois.c",
                     1292);
  a ^= 0xffff;
  b ^= 0xffff;
  new = do_nofail((malloc(sizeof("255.255.255.255"))),
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/"
                  "master/deps/whois/whois.c",
                  1296);
  sprintf(new, "%u.%u.%u.%u", a >> 8, a & 0xff, b >> 8, b & 0xff);
  return new;
}


x86 assembly (clang, -O0):
<convert_teredo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     11a5 <convert_teredo+0x55>
lea    0xeaa(%rip),%rdi
call   1070 <strdup@plt>
mov    %eax,%edi
lea    0xea4(%rip),%rsi
mov    $0x50c,%edx
call   1050 <do_nofail@plt>
mov    %rax,-0x8(%rbp)
jmp    1216 <convert_teredo+0xc6>
mov    -0x1c(%rbp),%eax
xor    $0xffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
xor    $0xffff,%eax
mov    %eax,-0x20(%rbp)
mov    $0x10,%edi
call   1030 <malloc@plt>
mov    %eax,%edi
lea    0xe68(%rip),%rsi
mov    $0x510,%edx
call   1050 <do_nofail@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
shr    $0x8,%edx
mov    -0x1c(%rbp),%ecx
and    $0xff,%ecx
mov    -0x20(%rbp),%r8d
shr    $0x8,%r8d
mov    -0x20(%rbp),%r9d
and    $0xff,%r9d
lea    0xeb7(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_teredo>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1040 <sscanf@plt>
cmp    $0x2,%eax
jne    11c8 <convert_teredo+0x78>
xorl   $0xffff,0xc(%rsp)
xorl   $0xffff,0x8(%rsp)
mov    $0x10,%edi
call   1030 <malloc@plt>
lea    0xea5(%rip),%rsi
mov    %eax,%edi
mov    $0x510,%edx
call   1050 <do_nofail@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
movzbl %dl,%ecx
shr    $0x8,%edx
mov    0x8(%rsp),%r8d
movzbl %r8b,%r9d
shr    $0x8,%r8d
lea    0xf02(%rip),%rsi
mov    %rax,%rdi
call   1060 <sprintf@plt>
jmp    11ea <convert_teredo+0x9a>
lea    0xe5f(%rip),%rdi
call   1070 <strdup@plt>
lea    0xe5b(%rip),%rsi
mov    %eax,%edi
mov    $0x50c,%edx
call   1050 <do_nofail@plt>
mov    %rax,%rbx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"2001:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%x:%x\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@.str.2 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/master/deps/whois/whois.c\00"
@.str.3 = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @convert_teredo(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6)
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = call i8* @do_nofail(i32 %11, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 1292)
store i8* %12, i8** %2
br label %31
13: ; preds = %1
%14 = load i32, i32* %5
%15 = xor i32 %14, 65535
store i32 %15, i32* %5
%16 = load i32, i32* %6
%17 = xor i32 %16, 65535
store i32 %17, i32* %6
%18 = call i32 @malloc(i32 16)
%19 = call i8* @do_nofail(i32 %18, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 1296)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = lshr i32 %21, 8
%23 = load i32, i32* %5
%24 = and i32 %23, 255
%25 = load i32, i32* %6
%26 = lshr i32 %25, 8
%27 = load i32, i32* %6
%28 = and i32 %27, 255
%29 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %24, i32 %26, i32 %28)
%30 = load i8*, i8** %4
store i8* %30, i8** %2
br label %31
31: ; preds = %13, %10
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@.str = [46 x i8] c"2001:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%x:%x\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@.str.2 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/master/deps/whois/whois.c\00"
@.str.3 = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @convert_teredo(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%7 = icmp eq i32 %6, 2
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i32 @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = call i8* @do_nofail(i32 %9, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 1292)
br label %25
11: ; preds = %1
%12 = load i32, i32* %2
%13 = xor i32 %12, 65535
store i32 %13, i32* %2
%14 = load i32, i32* %3
%15 = xor i32 %14, 65535
store i32 %15, i32* %3
%16 = call i32 @malloc(i32 16)
%17 = call i8* @do_nofail(i32 %16, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 1296)
%18 = load i32, i32* %2
%19 = lshr i32 %18, 8
%20 = and i32 %18, 255
%21 = load i32, i32* %3
%22 = lshr i32 %21, 8
%23 = and i32 %21, 255
%24 = call i32 @sprintf(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %20, i32 %22, i32 %23)
br label %25
25: ; preds = %11, %8
%26 = phi i8* [ %10, %8 ], [ %17, %11 ]
ret i8* %26
}