#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 in_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ INET6_ADDRSTRLEN;
int /*<<< orphan*/ b64_decode(char *, char *, int);
int /*<<< orphan*/ bzero(char *, int);
char const *inet_ntoa(struct in_addr);
char const *inet_ntop(int /*<<< orphan*/, char *, char *, int /*<<< orphan*/);
int strlen(char *);
const char *decode_ip(char *buf) {
  char targ[25];
  char blah[128];
  bzero(blah, 128);
  b64_decode(buf, targ, 25);
  if (strlen(buf) <= 8)
    return inet_ntoa(*(struct in_addr *)targ);
  else
    return (inet_ntop(AF_INET6, targ, blah, INET6_ADDRSTRLEN));
}


x86 assembly (clang, -O0):
<decode_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0xb0(%rbp),%rdi
mov    $0x80,%esi
call   1070 <bzero@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x19,%edx
call   1050 <b64_decode@plt>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x8,%eax
jg     11a5 <decode_ip+0x55>
mov    -0x30(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x8(%rbp)
jmp    11cb <decode_ip+0x7b>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
mov    0x2e28(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_ip>:
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,%rbx
lea    0x20(%rsp),%rdi
mov    $0x80,%esi
call   1070 <bzero@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x19,%edx
call   1050 <b64_decode@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x8,%eax
jg     1191 <decode_ip+0x41>
mov    (%rsp),%edi
call   1040 <inet_ntoa@plt>
jmp    11b0 <decode_ip+0x60>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rsi
lea    0x20(%rsp),%rdx
call   1030 <inet_ntop@plt>
add    $0xa0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@AF_INET6 = global i32 0
@INET6_ADDRSTRLEN = global i32 0
define i8* @decode_ip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [25 x i8]
%5 = alloca [128 x i8]
store i8* %0, i8** %3
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 128)
%8 = load i8*, i8** %3
%9 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%10 = call i32 @b64_decode(i8* %8, i8* %9, i32 25)
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = icmp sle i32 %12, 8
br i1 %13, label %14, label %20
14: ; preds = %1
%15 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%16 = bitcast i8* %15 to %struct.in_addr*
%17 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i8* @inet_ntoa(i32 %18)
store i8* %19, i8** %2
br label %26
20: ; preds = %1
%21 = load i32, i32* @AF_INET6
%22 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* @INET6_ADDRSTRLEN
%25 = call i8* @inet_ntop(i32 %21, i8* %22, i8* %23, i32 %24)
store i8* %25, i8** %2
br label %26
26: ; preds = %20, %14
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@AF_INET6 = global i32 0
@INET6_ADDRSTRLEN = global i32 0
define i8* @decode_ip(i8* %0) {
%2 = alloca [25 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @bzero(i8* %5, i32 128)
%7 = call i32 @b64_decode(i8* %0, i8* %4, i32 25)
%8 = call i32 @strlen(i8* %0)
%9 = icmp slt i32 %8, 9
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = bitcast [25 x i8]* %2 to i32*
%12 = load i32, i32* %11
%13 = call i8* @inet_ntoa(i32 %12)
br label %18
14: ; preds = %1
%15 = load i32, i32* @AF_INET6
%16 = load i32, i32* @INET6_ADDRSTRLEN
%17 = call i8* @inet_ntop(i32 %15, i8* %4, i8* %5, i32 %16)
br label %18
18: ; preds = %14, %10
%19 = phi i8* [ %13, %10 ], [ %17, %14 ]
ret i8* %19
}