#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ debugLog(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, unsigned int);
int /*<<< orphan*/ sscanf(char const *, char *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *);
const char *ipv4_bindstring(const char *ipv4, unsigned int port) {
  static char buffer[32];
  union {
    uint8_t b[4];
    uint32_t bin;
  } ip_s;
  sscanf(ipv4, "%hhu.%hhu.%hhu.%hhu", &(ip_s.b[0]), &(ip_s.b[1]), &(ip_s.b[2]),
         &(ip_s.b[3]));
  sprintf(buffer, "%08X:%04X", ip_s.bin, port);
  debugLog(LOG_DEBUG, "Bindstring \"%s\"\n", buffer);
  return buffer;
}


x86 assembly (clang, -O0):
<ipv4_bindstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x20(%rbp),%rcx
add    $0x4,%rcx
lea    -0x20(%rbp),%r8
add    $0x8,%r8
lea    -0x20(%rbp),%r9
add    $0xc,%r9
lea    0xe9a(%rip),%rsi
call   1040 <sscanf@plt>
mov    -0x20(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0x2ed8(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1050 <sprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
lea    0x2eb5(%rip),%rdx
call   1030 <debugLog@plt>
lea    0x2ea9(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipv4_bindstring>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
lea    0xc(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0x14(%rsp),%r9
lea    0xeb2(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0x8(%rsp),%edx
lea    0x2eed(%rip),%rbx
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdx
call   1030 <debugLog@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%union.anon = type { [4 x i32] }
@ipv4_bindstring.buffer = internal global [32 x i8] zeroinitializer
@.str = [20 x i8] c"%hhu.%hhu.%hhu.%hhu\00"
@.str.1 = [10 x i8] c"%08X:%04X\00"
@LOG_DEBUG = global i32 0
@.str.2 = [17 x i8] c"Bindstring \22%s\22\0A\00"
define i8* @ipv4_bindstring(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %union.anon
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast %union.anon* %5 to [4 x i32]*
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%9 = bitcast %union.anon* %5 to [4 x i32]*
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
%11 = bitcast %union.anon* %5 to [4 x i32]*
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %11, i64 0, i64 2
%13 = bitcast %union.anon* %5 to [4 x i32]*
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %13, i64 0, i64 3
%15 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %8, i32* %10, i32* %12, i32* %14)
%16 = bitcast %union.anon* %5 to i32*
%17 = load i32, i32* %16
%18 = load i32, i32* %4
%19 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipv4_bindstring.buffer, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* @LOG_DEBUG
%21 = call i32 @debugLog(i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipv4_bindstring.buffer, i64 0, i64 0))
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipv4_bindstring.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
%union.anon = type { [4 x i32] }
@ipv4_bindstring.buffer = internal global [32 x i8] zeroinitializer
@.str = [20 x i8] c"%hhu.%hhu.%hhu.%hhu\00"
@.str.1 = [10 x i8] c"%08X:%04X\00"
@LOG_DEBUG = global i32 0
@.str.2 = [17 x i8] c"Bindstring \22%s\22\0A\00"
define i8* @ipv4_bindstring(i8* nocapture %0, i32 %1) {
%3 = alloca %union.anon
%4 = bitcast %union.anon* %3 to i8*
%5 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0, i64 0
%6 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0, i64 1
%7 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0, i64 2
%8 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0, i64 3
%9 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8)
%10 = load i32, i32* %5
%11 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @ipv4_bindstring.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %1)
%12 = load i32, i32* @LOG_DEBUG
%13 = call i32 @debugLog(i32 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipv4_bindstring.buffer, i64 0, i64 0))
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipv4_bindstring.buffer, i64 0, i64 0)
}