#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*/ free(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *my_malloc(size_t);
int /*<<< orphan*/ set_re_cmd(char *, char *, char *, char *, char *, char *,
                              int);
int /*<<< orphan*/ snprintf(char *, scalar_t__, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
int handle_rename_socket(char *buf, int i) {
  char *oldpath;
  char *oldpath_1;
  char *oldpath_2;
  char *newpath;
  char *newpath_1;
  char *newpath_2;
  char cmd_name[512] = {0};
  char oldname[512] = {0};
  char newname[512] = {0};
  char *path;
  char *temp;
  char *ch = buf;
  int k = 0;
  while (*ch != '\n') {
    k++;
    ch++;
  }
  memcpy(cmd_name, buf, k);
  char *p = NULL;
  ch++;
  k++;
  temp = my_malloc((size_t)(strlen(ch) + 1));
  if (temp == NULL)
    return -1;
  strcpy(temp, ch);
  p = strchr(temp, '\n');
  path = my_malloc((size_t)(strlen(temp) - strlen(p) + 1));
  if (p == NULL)
    return -1;
  snprintf(path, strlen(temp) - strlen(p) + 1, "%s", temp);
  p++;
  char *p1 = NULL;
  p1 = strchr(p, '\n');
  if (p1 != NULL)
    strncpy(oldname, p, strlen(p) - strlen(p1));
  p1++;
  strcpy(newname, p1);
  oldpath = my_malloc((size_t)(strlen(path) + strlen(oldname) + 2));
  if (oldpath == NULL)
    return -1;
  oldpath_1 = my_malloc((size_t)(strlen(path) + strlen(oldname) + 3));
  if (oldpath_1 == NULL)
    return -1;
  oldpath_2 = my_malloc((size_t)(strlen(path) + strlen(oldname) + 3));
  if (oldpath_2 == NULL)
    return -1;
  newpath = my_malloc((size_t)(strlen(path) + strlen(newname) + 2));
  if (newpath == NULL)
    return -1;
  newpath_1 = my_malloc((size_t)(strlen(path) + strlen(newname) + 3));
  if (newpath_1 == NULL)
    return -1;
  newpath_2 = my_malloc((size_t)(strlen(path) + strlen(newname) + 3));
  if (newpath_2 == NULL)
    return -1;
  sprintf(oldpath, "%s/%s", path, oldname);
  sprintf(oldpath_1, "%s/%s\n", path, oldname);
  sprintf(oldpath_2, "%s/%s/", path, oldname);
  sprintf(newpath, "%s/%s", path, newname);
  sprintf(newpath_1, "%s/%s\n", path, newname);
  sprintf(newpath_2, "%s/%s/", path, newname);
  free(path);
  free(temp);
  set_re_cmd(oldpath, oldpath_1, oldpath_2, newpath, newpath_1, newpath_2, i);
  free(oldpath);
  free(oldpath_1);
  free(oldpath_2);
  free(newpath);
  free(newpath_1);
  free(newpath_2);
  return 0;
}


x86 assembly (clang, -O0):
<handle_rename_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6f0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x250(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10b0 <memset@plt>
lea    -0x450(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10b0 <memset@plt>
lea    -0x650(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10b0 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x668(%rbp)
movl   $0x0,-0x66c(%rbp)
mov    -0x668(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1249 <handle_rename_socket+0x99>
mov    -0x66c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x66c(%rbp)
mov    -0x668(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x668(%rbp)
jmp    1210 <handle_rename_socket+0x60>
lea    -0x250(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x66c(%rbp),%edx
call   10c0 <memcpy@plt>
movq   $0x0,-0x678(%rbp)
mov    -0x668(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x668(%rbp)
mov    -0x66c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x66c(%rbp)
mov    -0x668(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x660(%rbp)
cmpq   $0x0,-0x660(%rbp)
jne    12c4 <handle_rename_socket+0x114>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x660(%rbp),%rdi
mov    -0x668(%rbp),%rsi
call   1070 <strcpy@plt>
mov    -0x660(%rbp),%rdi
mov    $0xa,%esi
call   1090 <strchr@plt>
mov    %rax,-0x678(%rbp)
mov    -0x660(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x688(%rbp)
mov    -0x678(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x688(%rbp),%rdi
sub    %rax,%rdi
add    $0x1,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x658(%rbp)
cmpq   $0x0,-0x678(%rbp)
jne    1342 <handle_rename_socket+0x192>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x658(%rbp),%rax
mov    %rax,-0x690(%rbp)
mov    -0x660(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x698(%rbp)
mov    -0x678(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x698(%rbp),%rsi
mov    -0x690(%rbp),%rdi
sub    %rax,%rsi
add    $0x1,%rsi
mov    -0x660(%rbp),%rcx
lea    0xc71(%rip),%rdx
call   10a0 <snprintf@plt>
mov    -0x678(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x678(%rbp)
movq   $0x0,-0x680(%rbp)
mov    -0x678(%rbp),%rdi
mov    $0xa,%esi
call   1090 <strchr@plt>
mov    %rax,-0x680(%rbp)
cmpq   $0x0,-0x680(%rbp)
je     1432 <handle_rename_socket+0x282>
lea    -0x450(%rbp),%rax
mov    %rax,-0x6a8(%rbp)
mov    -0x678(%rbp),%rax
mov    %rax,-0x6a0(%rbp)
mov    -0x678(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6b0(%rbp)
mov    -0x680(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6b0(%rbp),%rdx
mov    -0x6a8(%rbp),%rdi
mov    -0x6a0(%rbp),%rsi
sub    %rax,%rdx
call   1060 <strncpy@plt>
mov    -0x680(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x680(%rbp)
lea    -0x650(%rbp),%rdi
mov    -0x680(%rbp),%rsi
call   1070 <strcpy@plt>
mov    -0x658(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6b8(%rbp)
lea    -0x450(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6b8(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    14a4 <handle_rename_socket+0x2f4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x658(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6c0(%rbp)
lea    -0x450(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6c0(%rbp),%rdi
add    %rax,%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    14f1 <handle_rename_socket+0x341>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x658(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6c8(%rbp)
lea    -0x450(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6c8(%rbp),%rdi
add    %rax,%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    153e <handle_rename_socket+0x38e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x658(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6d0(%rbp)
lea    -0x650(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6d0(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    158b <handle_rename_socket+0x3db>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x658(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6d8(%rbp)
lea    -0x650(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6d8(%rbp),%rdi
add    %rax,%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    15d8 <handle_rename_socket+0x428>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x658(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x6e0(%rbp)
lea    -0x650(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x6e0(%rbp),%rdi
add    %rax,%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1625 <handle_rename_socket+0x475>
movl   $0xffffffff,-0x4(%rbp)
jmp    1751 <handle_rename_socket+0x5a1>
mov    -0x20(%rbp),%rdi
mov    -0x658(%rbp),%rdx
lea    -0x450(%rbp),%rcx
lea    0x9c2(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x658(%rbp),%rdx
lea    -0x450(%rbp),%rcx
lea    0x9aa(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x658(%rbp),%rdx
lea    -0x450(%rbp),%rcx
lea    0x993(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x658(%rbp),%rdx
lea    -0x650(%rbp),%rcx
lea    0x968(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x658(%rbp),%rdx
lea    -0x650(%rbp),%rcx
lea    0x950(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x658(%rbp),%rdx
lea    -0x650(%rbp),%rcx
lea    0x939(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x658(%rbp),%rdi
call   1040 <free@plt>
mov    -0x660(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    -0x14(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <set_re_cmd@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x6f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_rename_socket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x638,%rsp
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0x430(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x200,%edx
xor    %esi,%esi
call   10b0 <memset@plt>
lea    0x230(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   10b0 <memset@plt>
lea    0x30(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   10b0 <memset@plt>
cmpb   $0xa,(%rbx)
mov    %rbx,%r14
je     1221 <handle_rename_socket+0x71>
xor    %ebp,%ebp
nopl   0x0(%rax)
cmpb   $0xa,0x1(%rbx,%rbp,1)
lea    0x1(%rbp),%rbp
jne    1210 <handle_rename_socket+0x60>
mov    %rbp,%r14
add    %rbx,%r14
lea    0x430(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   10c0 <memcpy@plt>
add    $0x1,%r14
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <my_malloc@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strcpy@plt>
mov    %r13,%rdi
mov    $0xa,%esi
call   1090 <strchr@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1080 <strlen@plt>
sub    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <my_malloc@plt>
test   %rbp,%rbp
je     154e <handle_rename_socket+0x39e>
mov    %rax,%r14
mov    %r12d,0x14(%rsp)
mov    %r13,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1080 <strlen@plt>
sub    %rax,%rbx
add    $0x1,%rbx
lea    0xd3a(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rcx
call   10a0 <snprintf@plt>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0xa,%esi
call   1090 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1319 <handle_rename_socket+0x169>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1080 <strlen@plt>
sub    %rax,%r12
lea    0x230(%rsp),%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1060 <strncpy@plt>
add    $0x1,%rbx
lea    0x30(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <strcpy@plt>
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbx
lea    0x230(%rsp),%rdi
call   1080 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x2,%rdi
call   1050 <my_malloc@plt>
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
mov    %rax,%r12
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbx
lea    0x230(%rsp),%rdi
call   1080 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
mov    %rax,%rbx
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbp
lea    0x230(%rsp),%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
mov    %rax,0x28(%rsp)
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbp
lea    0x30(%rsp),%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x2,%rdi
call   1050 <my_malloc@plt>
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
mov    %rax,0x20(%rsp)
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbp
lea    0x30(%rsp),%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
mov    %rax,0x18(%rsp)
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rax,%rbp
lea    0x30(%rsp),%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x3,%rdi
call   1050 <my_malloc@plt>
test   %rax,%rax
je     154e <handle_rename_socket+0x39e>
lea    0xbaf(%rip),%rsi
lea    0x230(%rsp),%rbp
mov    %rax,%r15
mov    %r12,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10d0 <sprintf@plt>
lea    0xb95(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10d0 <sprintf@plt>
lea    0xb87(%rip),%rsi
mov    0x28(%rsp),%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10d0 <sprintf@plt>
lea    0x30(%rsp),%rbp
mov    0x20(%rsp),%rdi
lea    0xb59(%rip),%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10d0 <sprintf@plt>
mov    0x18(%rsp),%rdi
lea    0xb48(%rip),%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10d0 <sprintf@plt>
mov    %r15,%rdi
lea    0xb3a(%rip),%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   10d0 <sprintf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r13,%rdi
call   1040 <free@plt>
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    0x28(%rsp),%rbp
mov    %rbp,%rdx
mov    0x20(%rsp),%r13
mov    %r13,%rcx
mov    0x18(%rsp),%r14
mov    %r14,%r8
mov    %r15,%r9
call   1030 <set_re_cmd@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %r13,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x638,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [7 x i8] c"%s/%s\0A\00"
@.str.3 = [7 x i8] c"%s/%s/\00"
define i32 @handle_rename_socket(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [512 x i8]
%13 = alloca [512 x i8]
%14 = alloca [512 x i8]
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%21 = bitcast [512 x i8]* %12 to i8*
%22 = bitcast [512 x i8]* %13 to i8*
%23 = bitcast [512 x i8]* %14 to i8*
%24 = load i8*, i8** %4
store i8* %24, i8** %17
store i32 0, i32* %18
br label %25
25: ; preds = %30, %2
%26 = load i8*, i8** %17
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* %18
%32 = add nsw i32 %31, 1
store i32 %32, i32* %18
%33 = load i8*, i8** %17
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %17
br label %25
35: ; preds = %25
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%37 = load i8*, i8** %4
%38 = load i32, i32* %18
%39 = call i32 @memcpy(i8* %36, i8* %37, i32 %38)
store i8* null, i8** %19
%40 = load i8*, i8** %17
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %17
%42 = load i32, i32* %18
%43 = add nsw i32 %42, 1
store i32 %43, i32* %18
%44 = load i8*, i8** %17
%45 = call i64 @strlen(i8* %44)
%46 = add nsw i64 %45, 1
%47 = call i8* @my_malloc(i64 %46)
store i8* %47, i8** %16
%48 = load i8*, i8** %16
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %51
50: ; preds = %35
store i32 -1, i32* %3
br label %212
51: ; preds = %35
%52 = load i8*, i8** %16
%53 = load i8*, i8** %17
%54 = call i32 @strcpy(i8* %52, i8* %53)
%55 = load i8*, i8** %16
%56 = call i8* @strchr(i8* %55, i8 signext 10)
store i8* %56, i8** %19
%57 = load i8*, i8** %16
%58 = call i64 @strlen(i8* %57)
%59 = load i8*, i8** %19
%60 = call i64 @strlen(i8* %59)
%61 = sub nsw i64 %58, %60
%62 = add nsw i64 %61, 1
%63 = call i8* @my_malloc(i64 %62)
store i8* %63, i8** %15
%64 = load i8*, i8** %19
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %67
66: ; preds = %51
store i32 -1, i32* %3
br label %212
67: ; preds = %51
%68 = load i8*, i8** %15
%69 = load i8*, i8** %16
%70 = call i64 @strlen(i8* %69)
%71 = load i8*, i8** %19
%72 = call i64 @strlen(i8* %71)
%73 = sub nsw i64 %70, %72
%74 = add nsw i64 %73, 1
%75 = load i8*, i8** %16
%76 = call i32 @snprintf(i8* %68, i64 %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %75)
%77 = load i8*, i8** %19
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %19
store i8* null, i8** %20
%79 = load i8*, i8** %19
%80 = call i8* @strchr(i8* %79, i8 signext 10)
store i8* %80, i8** %20
%81 = load i8*, i8** %20
%82 = icmp ne i8* %81, null
br i1 %82, label %83, label %92
83: ; preds = %67
%84 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%85 = load i8*, i8** %19
%86 = load i8*, i8** %19
%87 = call i64 @strlen(i8* %86)
%88 = load i8*, i8** %20
%89 = call i64 @strlen(i8* %88)
%90 = sub nsw i64 %87, %89
%91 = call i32 @strncpy(i8* %84, i8* %85, i64 %90)
br label %92
92: ; preds = %83, %67
%93 = load i8*, i8** %20
%94 = getelementptr inbounds i8, i8* %93, i32 1
store i8* %94, i8** %20
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%96 = load i8*, i8** %20
%97 = call i32 @strcpy(i8* %95, i8* %96)
%98 = load i8*, i8** %15
%99 = call i64 @strlen(i8* %98)
%100 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%101 = call i64 @strlen(i8* %100)
%102 = add nsw i64 %99, %101
%103 = add nsw i64 %102, 2
%104 = call i8* @my_malloc(i64 %103)
store i8* %104, i8** %6
%105 = load i8*, i8** %6
%106 = icmp eq i8* %105, null
br i1 %106, label %107, label %108
107: ; preds = %92
store i32 -1, i32* %3
br label %212
108: ; preds = %92
%109 = load i8*, i8** %15
%110 = call i64 @strlen(i8* %109)
%111 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%112 = call i64 @strlen(i8* %111)
%113 = add nsw i64 %110, %112
%114 = add nsw i64 %113, 3
%115 = call i8* @my_malloc(i64 %114)
store i8* %115, i8** %7
%116 = load i8*, i8** %7
%117 = icmp eq i8* %116, null
br i1 %117, label %118, label %119
118: ; preds = %108
store i32 -1, i32* %3
br label %212
119: ; preds = %108
%120 = load i8*, i8** %15
%121 = call i64 @strlen(i8* %120)
%122 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%123 = call i64 @strlen(i8* %122)
%124 = add nsw i64 %121, %123
%125 = add nsw i64 %124, 3
%126 = call i8* @my_malloc(i64 %125)
store i8* %126, i8** %8
%127 = load i8*, i8** %8
%128 = icmp eq i8* %127, null
br i1 %128, label %129, label %130
129: ; preds = %119
store i32 -1, i32* %3
br label %212
130: ; preds = %119
%131 = load i8*, i8** %15
%132 = call i64 @strlen(i8* %131)
%133 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%134 = call i64 @strlen(i8* %133)
%135 = add nsw i64 %132, %134
%136 = add nsw i64 %135, 2
%137 = call i8* @my_malloc(i64 %136)
store i8* %137, i8** %9
%138 = load i8*, i8** %9
%139 = icmp eq i8* %138, null
br i1 %139, label %140, label %141
140: ; preds = %130
store i32 -1, i32* %3
br label %212
141: ; preds = %130
%142 = load i8*, i8** %15
%143 = call i64 @strlen(i8* %142)
%144 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%145 = call i64 @strlen(i8* %144)
%146 = add nsw i64 %143, %145
%147 = add nsw i64 %146, 3
%148 = call i8* @my_malloc(i64 %147)
store i8* %148, i8** %10
%149 = load i8*, i8** %10
%150 = icmp eq i8* %149, null
br i1 %150, label %151, label %152
151: ; preds = %141
store i32 -1, i32* %3
br label %212
152: ; preds = %141
%153 = load i8*, i8** %15
%154 = call i64 @strlen(i8* %153)
%155 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%156 = call i64 @strlen(i8* %155)
%157 = add nsw i64 %154, %156
%158 = add nsw i64 %157, 3
%159 = call i8* @my_malloc(i64 %158)
store i8* %159, i8** %11
%160 = load i8*, i8** %11
%161 = icmp eq i8* %160, null
br i1 %161, label %162, label %163
162: ; preds = %152
store i32 -1, i32* %3
br label %212
163: ; preds = %152
%164 = load i8*, i8** %6
%165 = load i8*, i8** %15
%166 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%167 = call i32 @sprintf(i8* %164, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %165, i8* %166)
%168 = load i8*, i8** %7
%169 = load i8*, i8** %15
%170 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%171 = call i32 @sprintf(i8* %168, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %169, i8* %170)
%172 = load i8*, i8** %8
%173 = load i8*, i8** %15
%174 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%175 = call i32 @sprintf(i8* %172, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %173, i8* %174)
%176 = load i8*, i8** %9
%177 = load i8*, i8** %15
%178 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%179 = call i32 @sprintf(i8* %176, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %177, i8* %178)
%180 = load i8*, i8** %10
%181 = load i8*, i8** %15
%182 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%183 = call i32 @sprintf(i8* %180, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %181, i8* %182)
%184 = load i8*, i8** %11
%185 = load i8*, i8** %15
%186 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%187 = call i32 @sprintf(i8* %184, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %185, i8* %186)
%188 = load i8*, i8** %15
%189 = call i32 @free(i8* %188)
%190 = load i8*, i8** %16
%191 = call i32 @free(i8* %190)
%192 = load i8*, i8** %6
%193 = load i8*, i8** %7
%194 = load i8*, i8** %8
%195 = load i8*, i8** %9
%196 = load i8*, i8** %10
%197 = load i8*, i8** %11
%198 = load i32, i32* %5
%199 = call i32 @set_re_cmd(i8* %192, i8* %193, i8* %194, i8* %195, i8* %196, i8* %197, i32 %198)
%200 = load i8*, i8** %6
%201 = call i32 @free(i8* %200)
%202 = load i8*, i8** %7
%203 = call i32 @free(i8* %202)
%204 = load i8*, i8** %8
%205 = call i32 @free(i8* %204)
%206 = load i8*, i8** %9
%207 = call i32 @free(i8* %206)
%208 = load i8*, i8** %10
%209 = call i32 @free(i8* %208)
%210 = load i8*, i8** %11
%211 = call i32 @free(i8* %210)
store i32 0, i32* %3
br label %212
212: ; preds = %163, %162, %151, %140, %129, %118, %107, %66, %50
%213 = load i32, i32* %3
ret i32 %213
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [7 x i8] c"%s/%s\0A\00"
@.str.3 = [7 x i8] c"%s/%s/\00"
define i32 @handle_rename_socket(i8* %0, i32 %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 10
br i1 %10, label %18, label %11
11: ; preds = %2, %11
%12 = phi i32 [ %14, %11 ], [ 0, %2 ]
%13 = phi i8* [ %15, %11 ], [ %0, %2 ]
%14 = add nuw nsw i32 %12, 1
%15 = getelementptr inbounds i8, i8* %13, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %11
18: ; preds = %11, %2
%19 = phi i8* [ %0, %2 ], [ %15, %11 ]
%20 = phi i32 [ 0, %2 ], [ %14, %11 ]
%21 = call i32 @memcpy(i8* %6, i8* %0, i32 %20)
%22 = getelementptr inbounds i8, i8* %19, i64 1
%23 = call i64 @strlen(i8* %22)
%24 = add nsw i64 %23, 1
%25 = call i8* @my_malloc(i64 %24)
%26 = icmp eq i8* %25, null
br i1 %26, label %110, label %27
27: ; preds = %18
%28 = call i32 @strcpy(i8* %25, i8* %22)
%29 = call i8* @strchr(i8* %25, i8 signext 10)
%30 = call i64 @strlen(i8* %25)
%31 = call i64 @strlen(i8* dereferenceable(1) %29)
%32 = add i64 %30, 1
%33 = sub i64 %32, %31
%34 = call i8* @my_malloc(i64 %33)
%35 = icmp eq i8* %29, null
br i1 %35, label %110, label %36
36: ; preds = %27
%37 = call i64 @strlen(i8* %25)
%38 = call i64 @strlen(i8* %29)
%39 = add i64 %37, 1
%40 = sub i64 %39, %38
%41 = call i32 @snprintf(i8* %34, i64 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
%42 = getelementptr inbounds i8, i8* %29, i64 1
%43 = call i8* @strchr(i8* %42, i8 signext 10)
%44 = icmp eq i8* %43, null
br i1 %44, label %50, label %45
45: ; preds = %36
%46 = call i64 @strlen(i8* %42)
%47 = call i64 @strlen(i8* %43)
%48 = sub nsw i64 %46, %47
%49 = call i32 @strncpy(i8* %7, i8* %42, i64 %48)
br label %50
50: ; preds = %45, %36
%51 = getelementptr inbounds i8, i8* %43, i64 1
%52 = call i32 @strcpy(i8* %8, i8* %51)
%53 = call i64 @strlen(i8* dereferenceable(1) %34)
%54 = call i64 @strlen(i8* %7)
%55 = add i64 %53, 2
%56 = add i64 %55, %54
%57 = call i8* @my_malloc(i64 %56)
%58 = icmp eq i8* %57, null
br i1 %58, label %110, label %59
59: ; preds = %50
%60 = call i64 @strlen(i8* dereferenceable(1) %34)
%61 = call i64 @strlen(i8* %7)
%62 = add i64 %60, 3
%63 = add i64 %62, %61
%64 = call i8* @my_malloc(i64 %63)
%65 = icmp eq i8* %64, null
br i1 %65, label %110, label %66
66: ; preds = %59
%67 = call i64 @strlen(i8* dereferenceable(1) %34)
%68 = call i64 @strlen(i8* %7)
%69 = add i64 %67, 3
%70 = add i64 %69, %68
%71 = call i8* @my_malloc(i64 %70)
%72 = icmp eq i8* %71, null
br i1 %72, label %110, label %73
73: ; preds = %66
%74 = call i64 @strlen(i8* dereferenceable(1) %34)
%75 = call i64 @strlen(i8* %8)
%76 = add i64 %74, 2
%77 = add i64 %76, %75
%78 = call i8* @my_malloc(i64 %77)
%79 = icmp eq i8* %78, null
br i1 %79, label %110, label %80
80: ; preds = %73
%81 = call i64 @strlen(i8* dereferenceable(1) %34)
%82 = call i64 @strlen(i8* %8)
%83 = add i64 %81, 3
%84 = add i64 %83, %82
%85 = call i8* @my_malloc(i64 %84)
%86 = icmp eq i8* %85, null
br i1 %86, label %110, label %87
87: ; preds = %80
%88 = call i64 @strlen(i8* dereferenceable(1) %34)
%89 = call i64 @strlen(i8* %8)
%90 = add i64 %88, 3
%91 = add i64 %90, %89
%92 = call i8* @my_malloc(i64 %91)
%93 = icmp eq i8* %92, null
br i1 %93, label %110, label %94
94: ; preds = %87
%95 = call i32 @sprintf(i8* %57, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %7)
%96 = call i32 @sprintf(i8* %64, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %7)
%97 = call i32 @sprintf(i8* %71, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %34, i8* %7)
%98 = call i32 @sprintf(i8* %78, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %8)
%99 = call i32 @sprintf(i8* %85, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %8)
%100 = call i32 @sprintf(i8* %92, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %34, i8* %8)
%101 = call i32 @free(i8* %34)
%102 = call i32 @free(i8* %25)
%103 = call i32 @set_re_cmd(i8* %57, i8* %64, i8* %71, i8* %78, i8* %85, i8* %92, i32 %1)
%104 = call i32 @free(i8* %57)
%105 = call i32 @free(i8* %64)
%106 = call i32 @free(i8* %71)
%107 = call i32 @free(i8* %78)
%108 = call i32 @free(i8* %85)
%109 = call i32 @free(i8* %92)
br label %110
110: ; preds = %94, %50, %59, %66, %73, %80, %87, %27, %18
%111 = phi i32 [ -1, %18 ], [ -1, %27 ], [ 0, %94 ], [ -1, %50 ], [ -1, %59 ], [ -1, %66 ], [ -1, %73 ], [ -1, %80 ], [ -1, %87 ]
ret i32 %111
}