#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_udp(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strchr(char *, char);
char *uwsgi_concat2(char *, char *);
int uwsgi_connect_udp(char *socket_name) {
  int fd = -1;
  char *zeroed_socket_name = uwsgi_concat2(socket_name, (char *)"");
  char *udp_port = strchr(zeroed_socket_name, ':');
  if (!udp_port)
    goto end;
  *udp_port = 0;
  udp_port++;
  fd = connect_to_udp(zeroed_socket_name, atoi(udp_port));
end:
  free(zeroed_socket_name);
  return fd;
}


x86 assembly (clang, -O0):
<uwsgi_connect_udp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1070 <uwsgi_concat2@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1199 <uwsgi_connect_udp+0x49>
jmp    11cb <uwsgi_connect_udp+0x7b>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <connect_to_udp@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uwsgi_connect_udp>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rsi
call   1070 <uwsgi_concat2@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1191 <uwsgi_connect_udp+0x41>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <connect_to_udp@plt>
mov    %eax,%ebp
jmp    1196 <uwsgi_connect_udp+0x46>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @uwsgi_connect_udp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
store i32 -1, i32* %3
%6 = load i8*, i8** %2
%7 = call i8* @uwsgi_concat2(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @strchr(i8* %8, i8 signext 58)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
br label %21
13: ; preds = %1
%14 = load i8*, i8** %5
store i8 0, i8* %14
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %5
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = call i32 @atoi(i8* %18)
%20 = call i32 @connect_to_udp(i8* %17, i32 %19)
store i32 %20, i32* %3
br label %21
21: ; preds = %13, %12
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
%24 = load i32, i32* %3
ret i32 %24
}

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