#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 {
  scalar_t__ sa_family;
  int /*<<< orphan*/ sa_data;
};
typedef int /*<<< orphan*/ sqlite3_stmt;

/* Variables and functions */
scalar_t__ AF_INET6;
int /*<<< orphan*/ SQLITE_TRANSIENT;
int sqlite3_bind_blob(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *, int,
                      int /*<<< orphan*/);
int sqlite3_bind_address(sqlite3_stmt *stmt, int index, struct sockaddr *sa) {
  return sqlite3_bind_blob(stmt, index, &sa->sa_data,
                           sa->sa_family == AF_INET6 ? 16 : 4,
                           SQLITE_TRANSIENT);
}


x86 assembly (clang, -O0):
<sqlite3_bind_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
mov    0x2ea8(%rip),%rax
mov    (%rax),%r9
mov    $0x4,%ecx
mov    $0x10,%eax
cmp    %r9,%r8
cmove  %eax,%ecx
mov    0x2e7e(%rip),%rax
mov    (%rax),%r8d
call   1030 <sqlite3_bind_blob@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite3_bind_address>:
mov    (%rdx),%rax
add    $0x8,%rdx
mov    0x2eca(%rip),%rcx
cmp    (%rcx),%rax
mov    $0x10,%eax
mov    $0x4,%ecx
cmove  %eax,%ecx
mov    0x2ea3(%rip),%rax
mov    (%rax),%r8d
jmp    1030 <sqlite3_bind_blob@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i64, i32 }
@AF_INET6 = global i64 0
@SQLITE_TRANSIENT = global i32 0
define i32 @sqlite3_bind_address(i32* %0, i32 %1, %struct.sockaddr* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.sockaddr*
store i32* %0, i32** %4
store i32 %1, i32* %5
store %struct.sockaddr* %2, %struct.sockaddr** %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %5
%9 = load %struct.sockaddr*, %struct.sockaddr** %6
%10 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %9, i32 0, i32 1
%11 = load %struct.sockaddr*, %struct.sockaddr** %6
%12 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @AF_INET6
%15 = icmp eq i64 %13, %14
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 16, i32 4
%18 = load i32, i32* @SQLITE_TRANSIENT
%19 = call i32 @sqlite3_bind_blob(i32* %7, i32 %8, i32* %10, i32 %17, i32 %18)
ret i32 %19
}

LLVM IR (-O2):
%struct.sockaddr = type { i64, i32 }
@AF_INET6 = global i64 0
@SQLITE_TRANSIENT = global i32 0
define i32 @sqlite3_bind_address(i32* %0, i32 %1, %struct.sockaddr* %2) {
%4 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %2, i64 0, i32 1
%5 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %2, i64 0, i32 0
%6 = load i64, i64* %5
%7 = load i64, i64* @AF_INET6
%8 = icmp eq i64 %6, %7
%9 = select i1 %8, i32 16, i32 4
%10 = load i32, i32* @SQLITE_TRANSIENT
%11 = tail call i32 @sqlite3_bind_blob(i32* %0, i32 %1, i32* %4, i32 %9, i32 %10)
ret i32 %11
}