#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*/ snprintf(char *, int, char *, char *);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ unlink(char const *);
void cleanupDCOPsocket(char *buffer) {
  char cmd[4096];
  const char *socket_file;
  int l;
  l = strlen(buffer);
  if (!l)
    return;
  buffer[l - 1] = '\0';
  socket_file = strchr(buffer, ':');
  if (socket_file)
    socket_file++;
  if (socket_file)
    unlink(socket_file);
  snprintf(cmd, 4096, "iceauth remove netid='%s'", buffer);
  system(cmd);
}


x86 assembly (clang, -O0):
<cleanupDCOPsocket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x101c(%rbp)
cmpl   $0x0,-0x101c(%rbp)
jne    1180 <cleanupDCOPsocket+0x30>
jmp    120b <cleanupDCOPsocket+0xbb>
mov    -0x8(%rbp),%rax
mov    -0x101c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
je     11c9 <cleanupDCOPsocket+0x79>
mov    -0x1018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
je     11e3 <cleanupDCOPsocket+0x93>
mov    -0x1018(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1000,%esi
lea    0xe06(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <system@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanupDCOPsocket>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     11ad <cleanupDCOPsocket+0x5d>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     118b <cleanupDCOPsocket+0x3b>
add    $0x1,%rax
mov    %rax,%rdi
call   1030 <unlink@plt>
lea    0xe6e(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %rbx,%rcx
call   1070 <snprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"iceauth remove netid='%s'\00"
define void @cleanupDCOPsocket(i8* %0) {
%2 = alloca i8*
%3 = alloca [4096 x i8]
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
br label %36
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
store i8 0, i8* %16
%17 = load i8*, i8** %2
%18 = call i8* @strchr(i8* %17, i8 signext 58)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %11
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
br label %24
24: ; preds = %21, %11
%25 = load i8*, i8** %4
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = call i32 @unlink(i8* %28)
br label %30
30: ; preds = %27, %24
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%32 = load i8*, i8** %2
%33 = call i32 @snprintf(i8* %31, i32 4096, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%35 = call i32 @system(i8* %34)
br label %36
36: ; preds = %30, %10
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"iceauth remove netid='%s'\00"
define void @cleanupDCOPsocket(i8* %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %1
%7 = add nsw i32 %4, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 0, i8* %9
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = tail call i32 @unlink(i8* %13)
br label %15
15: ; preds = %12, %6
%16 = call i32 @snprintf(i8* %3, i32 4096, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = call i32 @system(i8* %3)
br label %18
18: ; preds = %1, %15
ret void
}