#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 */
int /*<<< orphan*/ atoi(char *);
int connect_to_tcp(char *, int /*<<< orphan*/, int, int);
int connect_to_unix(char *, int, int);
char *strchr(char *, char);
int uwsgi_connect_do(char *socket_name, int timeout, int async) {
  char *tcp_port = strchr(socket_name, ':');
  if (tcp_port) {
    tcp_port[0] = 0;
    tcp_port++;
    return connect_to_tcp(socket_name, atoi(tcp_port), timeout, async);
  }
  return connect_to_unix(socket_name, timeout, async);
}


x86 assembly (clang, -O0):
<uwsgi_connect_do>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ac <uwsgi_connect_do+0x6c>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <connect_to_tcp@plt>
mov    %eax,-0x4(%rbp)
jmp    11be <uwsgi_connect_do+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <connect_to_unix@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uwsgi_connect_do>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     117d <uwsgi_connect_do+0x3d>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <connect_to_tcp@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <connect_to_unix@plt>

LLVM IR (-O0):
define i32 @uwsgi_connect_do(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = call i8* @strchr(i8* %9, i8 signext 58)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %24
13: ; preds = %3
%14 = load i8*, i8** %8
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 0, i8* %15
%16 = load i8*, i8** %8
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %8
%18 = load i8*, i8** %5
%19 = load i8*, i8** %8
%20 = call i32 @atoi(i8* %19)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @connect_to_tcp(i8* %18, i32 %20, i32 %21, i32 %22)
store i32 %23, i32* %4
br label %29
24: ; preds = %3
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = call i32 @connect_to_unix(i8* %25, i32 %26, i32 %27)
store i32 %28, i32* %4
br label %29
29: ; preds = %24, %13
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @uwsgi_connect_do(i8* %0, i32 %1, i32 %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %3
store i8 0, i8* %4
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = tail call i32 @atoi(i8* %7)
%9 = tail call i32 @connect_to_tcp(i8* %0, i32 %8, i32 %1, i32 %2)
br label %12
10: ; preds = %3
%11 = tail call i32 @connect_to_unix(i8* %0, i32 %1, i32 %2)
br label %12
12: ; preds = %10, %6
%13 = phi i32 [ %9, %6 ], [ %11, %10 ]
ret i32 %13
}