#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*/ exit(int);
scalar_t__ isspace(int);
char *strchr(char *, char);
scalar_t__ strlen(char *);
int /*<<< orphan*/ uwsgi_log(char *);
int /*<<< orphan*/ uwsgi_nuclear_blast();
char *generate_socket_name(char *socket_name) {
  char *asterisk = strchr(socket_name, '*');
  char *tcp_port;
  int i;
  char *ptr = socket_name;
  for (i = 0; i < (int)strlen(socket_name); i++) {
    if (isspace((int)socket_name[i])) {
      ptr++;
    } else {
      break;
    }
  }
  socket_name = ptr;
  if (socket_name[0] == 0) {
    uwsgi_log("invalid/empty uwsgi socket name\n");
    exit(1);
  }
  tcp_port = strchr(socket_name, ':');
  if (!tcp_port)
    return socket_name;
  if (asterisk) {
    uwsgi_log("your system does not support ifaddrs subsystem\n");
    uwsgi_nuclear_blast();
  }
  return socket_name;
}


x86 assembly (clang, -O0):
<generate_socket_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    11ee <generate_socket_name+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11d6 <generate_socket_name+0x76>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11db <generate_socket_name+0x7b>
jmp    11ee <generate_socket_name+0x8e>
jmp    11e0 <generate_socket_name+0x80>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <generate_socket_name+0x2d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    121c <generate_socket_name+0xbc>
lea    0xdf3(%rip),%rdi
call   1060 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1246 <generate_socket_name+0xe6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    126c <generate_socket_name+0x10c>
cmpq   $0x0,-0x18(%rbp)
je     1264 <generate_socket_name+0x104>
lea    0xdc9(%rip),%rdi
call   1060 <uwsgi_log@plt>
mov    $0x0,%al
call   1080 <uwsgi_nuclear_blast@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_socket_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x2a,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11b5 <generate_socket_name+0x55>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15,%rbx,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11b2 <generate_socket_name+0x52>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1190 <generate_socket_name+0x30>
add    %rbx,%r15
cmpb   $0x0,(%r15)
je     11ee <generate_socket_name+0x8e>
mov    %r15,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11e5 <generate_socket_name+0x85>
test   %r14,%r14
je     11e5 <generate_socket_name+0x85>
lea    0xe48(%rip),%rdi
call   1060 <uwsgi_log@plt>
xor    %eax,%eax
call   1080 <uwsgi_nuclear_blast@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe0b(%rip),%rdi
call   1060 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"invalid/empty uwsgi socket name\0A\00"
@.str.1 = [48 x i8] c"your system does not support ifaddrs subsystem\0A\00"
define i8* @generate_socket_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @strchr(i8* %8, i8 signext 42)
store i8* %9, i8** %4
%10 = load i8*, i8** %3
store i8* %10, i8** %7
store i32 0, i32* %6
br label %11
11: ; preds = %31, %1
%12 = load i32, i32* %6
%13 = load i8*, i8** %3
%14 = call i64 @strlen(i8* %13)
%15 = trunc i64 %14 to i32
%16 = icmp slt i32 %12, %15
br i1 %16, label %17, label %34
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i64 @isspace(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %17
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
br label %30
29: ; preds = %17
br label %34
30: ; preds = %26
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %11
34: ; preds = %29, %11
%35 = load i8*, i8** %7
store i8* %35, i8** %3
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %34
%42 = call i32 @uwsgi_log(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34
%45 = load i8*, i8** %3
%46 = call i8* @strchr(i8* %45, i8 signext 58)
store i8* %46, i8** %5
%47 = load i8*, i8** %5
%48 = icmp ne i8* %47, null
br i1 %48, label %51, label %49
49: ; preds = %44
%50 = load i8*, i8** %3
store i8* %50, i8** %2
br label %59
51: ; preds = %44
%52 = load i8*, i8** %4
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = call i32 @uwsgi_log(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%56 = call i32 (...) @uwsgi_nuclear_blast()
br label %57
57: ; preds = %54, %51
%58 = load i8*, i8** %3
store i8* %58, i8** %2
br label %59
59: ; preds = %57, %49
%60 = load i8*, i8** %2
ret i8* %60
}

LLVM IR (-O2):
@.str = [33 x i8] c"invalid/empty uwsgi socket name\0A\00"
@.str.1 = [48 x i8] c"your system does not support ifaddrs subsystem\0A\00"
define i8* @generate_socket_name(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 42)
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %1, %14
%7 = phi i64 [ %16, %14 ], [ 0, %1 ]
%8 = phi i8* [ %15, %14 ], [ %0, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = tail call i64 @isspace(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %6
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = add nuw nsw i64 %7, 1
%17 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%18 = shl i64 %17, 32
%19 = ashr exact i64 %18, 32
%20 = icmp slt i64 %16, %19
br i1 %20, label %6, label %21
21: ; preds = %14, %6, %1
%22 = phi i8* [ %0, %1 ], [ %8, %6 ], [ %15, %14 ]
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %21
%29 = tail call i8* @strchr(i8* %22, i8 signext 58)
%30 = icmp eq i8* %29, null
%31 = icmp eq i8* %2, null
%32 = select i1 %30, i1 true, i1 %31
br i1 %32, label %36, label %33
33: ; preds = %28
%34 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%35 = tail call i32 (...) @uwsgi_nuclear_blast()
br label %36
36: ; preds = %33, %28
ret i8* %22
}