#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;
};
typedef scalar_t__ socklen_t;

/* Variables and functions */
int bsd_syscall_connect(int, void *, scalar_t__);
int uptcp_connect(int s, const struct sockaddr *name, socklen_t namelen) {
  do {
    unsigned char *ptr = (unsigned char *)(name);
    unsigned char ch = (unsigned char)((name)->sa_family);
    *ptr = (unsigned char)(namelen);
    ptr++;
    *ptr = (unsigned char)ch;
  } while (0);
  return bsd_syscall_connect(s, (void *)name, namelen);
}


x86 assembly (clang, -O0):
<uptcp_connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x21(%rbp),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <bsd_syscall_connect@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uptcp_connect>:
mov    (%rsi),%al
mov    %dl,(%rsi)
mov    %al,0x1(%rsi)
jmp    1030 <bsd_syscall_connect@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i64 }
define i32 @uptcp_connect(i32 %0, %struct.sockaddr* %1, i64 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8
store i32 %0, i32* %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
store i64 %2, i64* %6
br label %9
9: ; preds = %3
%10 = load %struct.sockaddr*, %struct.sockaddr** %5
%11 = bitcast %struct.sockaddr* %10 to i8*
store i8* %11, i8** %7
%12 = load %struct.sockaddr*, %struct.sockaddr** %5
%13 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = trunc i64 %14 to i8
store i8 %15, i8* %8
%16 = load i64, i64* %6
%17 = trunc i64 %16 to i8
%18 = load i8*, i8** %7
store i8 %17, i8* %18
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %7
%21 = load i8, i8* %8
%22 = load i8*, i8** %7
store i8 %21, i8* %22
br label %23
23: ; preds = %9
%24 = load i32, i32* %4
%25 = load %struct.sockaddr*, %struct.sockaddr** %5
%26 = bitcast %struct.sockaddr* %25 to i8*
%27 = load i64, i64* %6
%28 = call i32 @bsd_syscall_connect(i32 %24, i8* %26, i64 %27)
ret i32 %28
}

LLVM IR (-O2):
%struct.sockaddr = type { i64 }
define i32 @uptcp_connect(i32 %0, %struct.sockaddr* %1, i64 %2) {
%4 = bitcast %struct.sockaddr* %1 to i8*
%5 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %1, i64 0, i32 0
%6 = load i64, i64* %5
%7 = trunc i64 %6 to i8
%8 = trunc i64 %2 to i8
store i8 %8, i8* %4
%9 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %7, i8* %9
%10 = tail call i32 @bsd_syscall_connect(i32 %0, i8* %4, i64 %2)
ret i32 %10
}