#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 */
typedef int /*<<< orphan*/ temp;

/* Variables and functions */
int /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *insert_suffix(char *, char *);
int is_server_exist(char *, int);
int /*<<< orphan*/ memset(char *, char, int);
char *my_malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
char *strrchr(char *, char);
char *change_same_name(char *localpath, int index, int flag) {
  int i = 1;
  char *filename = NULL;
  char *new_path = NULL;
  char *path = NULL;
  char temp[256] = {0};
  char suffix[6] = {0};
  char *p;
  p = strrchr(localpath, '/');
  if (p == NULL) {
    return NULL;
  }
  filename = my_malloc(strlen(p) + 1);
  if (filename == NULL)
    return NULL;
  sprintf(filename, "%s", p + 1);
  path = my_malloc(strlen(localpath) - strlen(p) + 1);
  if (path == NULL)
    return NULL;
  snprintf(path, strlen(localpath) - strlen(p) + 1, "%s", localpath);
  int exit = 1;
  while (exit) {
    int n = i;
    int j = 0;
    while ((n = (n / 10))) {
      j++;
    }
    memset(temp, '\0', sizeof(temp));
    snprintf(temp, 252 - j, "%s", filename);
    sprintf(suffix, "(%d)", i);
    char *new_name = insert_suffix(temp, suffix);
    if (new_name == NULL)
      return NULL;
    i++;
    new_path = my_malloc(strlen(path) + strlen(new_name) + 2);
    if (new_path == NULL)
      return NULL;
    sprintf(new_path, "%s/%s", path, new_name);
    if (flag == 0)
      exit = is_server_exist(new_path, index);
    else if (flag == 1) {
      if (access(new_path, F_OK) != 0)
        exit = 0;
    }
    free(new_name);
  }
  free(path);
  free(filename);
  return new_path;
}


x86 assembly (clang, -O0):
<change_same_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
lea    -0x146(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1090 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x150(%rbp)
jne    122a <change_same_name+0x8a>
movq   $0x0,-0x8(%rbp)
jmp    14d8 <change_same_name+0x338>
mov    -0x150(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1040 <my_malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    125c <change_same_name+0xbc>
movq   $0x0,-0x8(%rbp)
jmp    14d8 <change_same_name+0x338>
mov    -0x28(%rbp),%rdi
mov    -0x150(%rbp),%rdx
add    $0x1,%rdx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x16c(%rbp)
mov    -0x150(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x16c(%rbp),%edi
sub    %eax,%edi
add    $0x1,%edi
call   1040 <my_malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12c0 <change_same_name+0x120>
movq   $0x0,-0x8(%rbp)
jmp    14d8 <change_same_name+0x338>
mov    -0x38(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x17c(%rbp)
mov    -0x150(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x17c(%rbp),%esi
mov    -0x178(%rbp),%rdi
sub    %eax,%esi
add    $0x1,%esi
mov    -0x10(%rbp),%rcx
lea    0xd05(%rip),%rdx
call   1070 <snprintf@plt>
movl   $0x1,-0x154(%rbp)
cmpl   $0x0,-0x154(%rbp)
je     14be <change_same_name+0x31e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x158(%rbp)
movl   $0x0,-0x15c(%rbp)
mov    -0x158(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x158(%rbp)
cmp    $0x0,%eax
je     1363 <change_same_name+0x1c3>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    1332 <change_same_name+0x192>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
lea    -0x140(%rbp),%rdi
mov    $0xfc,%esi
sub    -0x15c(%rbp),%esi
mov    -0x28(%rbp),%rcx
lea    0xc75(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x146(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xc57(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    -0x146(%rbp),%rsi
call   1050 <insert_suffix@plt>
mov    %rax,-0x168(%rbp)
cmpq   $0x0,-0x168(%rbp)
jne    13e5 <change_same_name+0x245>
movq   $0x0,-0x8(%rbp)
jmp    14d8 <change_same_name+0x338>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x180(%rbp)
mov    -0x168(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x180(%rbp),%edi
add    %eax,%edi
add    $0x2,%edi
call   1040 <my_malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1435 <change_same_name+0x295>
movq   $0x0,-0x8(%rbp)
jmp    14d8 <change_same_name+0x338>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x168(%rbp),%rcx
lea    0xbba(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1473 <change_same_name+0x2d3>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <is_server_exist@plt>
mov    %eax,-0x154(%rbp)
jmp    14ad <change_same_name+0x30d>
cmpl   $0x1,-0x18(%rbp)
jne    14a8 <change_same_name+0x308>
mov    -0x30(%rbp),%rdi
mov    0x2b50(%rip),%rax
mov    (%rax),%esi
call   10b0 <access@plt>
cmp    $0x0,%rax
je     14a3 <change_same_name+0x303>
movl   $0x0,-0x154(%rbp)
jmp    14a8 <change_same_name+0x308>
jmp    14ad <change_same_name+0x30d>
mov    -0x168(%rbp),%rdi
call   1030 <free@plt>
jmp    1312 <change_same_name+0x172>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_same_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %edx,%ebp
mov    %esi,0x8(%rsp)
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
mov    $0x2f,%esi
call   1090 <strrchr@plt>
test   %rax,%rax
je     143e <change_same_name+0x28e>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edi
call   1040 <my_malloc@plt>
test   %rax,%rax
je     143e <change_same_name+0x28e>
mov    %rax,%r13
mov    %ebp,0xc(%rsp)
mov    %r15,%rsi
add    $0x1,%rsi
mov    %rax,%rdi
call   1060 <strcpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1070 <strlen@plt>
sub    %eax,%ebp
add    $0x1,%ebp
mov    %ebp,%edi
call   1040 <my_malloc@plt>
test   %rax,%rax
je     143e <change_same_name+0x28e>
mov    %rax,%r12
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1070 <strlen@plt>
sub    %eax,%ebp
add    $0x1,%ebp
lea    0xd31(%rip),%rdx
mov    %r12,0x18(%rsp)
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r14,%rcx
call   1080 <snprintf@plt>
movl   $0x1,0x4(%rsp)
mov    $0x1,%r14d
jmp    1334 <change_same_name+0x184>
nopl   0x0(%rax)
mov    0x2cd1(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10c0 <access@plt>
test   %rax,%rax
jne    1456 <change_same_name+0x2a6>
add    $0x1,%r14d
mov    %r13,%rdi
call   1030 <free@plt>
cmpl   $0x0,0x4(%rsp)
mov    %r12,%r13
je     1461 <change_same_name+0x2b1>
mov    $0x0,%eax
cmp    $0xa,%r14d
jb     1375 <change_same_name+0x1c5>
xor    %eax,%eax
mov    %r14d,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
lea    (%rdx,%rsi,1),%ecx
add    $0x1,%eax
add    %esi,%edx
add    $0x9,%edx
cmp    $0x12,%edx
ja     1350 <change_same_name+0x1a0>
mov    $0xfc,%ebp
sub    %eax,%ebp
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0xc6c(%rip),%rdx
mov    %r13,%r12
mov    %r13,%rcx
call   1080 <snprintf@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
lea    0xc4a(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <insert_suffix@plt>
test   %rax,%rax
je     143e <change_same_name+0x28e>
mov    %rax,%r13
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
call   1040 <my_malloc@plt>
test   %rax,%rax
je     143e <change_same_name+0x28e>
mov    %rax,%r15
mov    %rax,%rdi
lea    0xbfe(%rip),%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     1300 <change_same_name+0x150>
test   %eax,%eax
jne    131a <change_same_name+0x16a>
mov    %r15,%rdi
mov    0x8(%rsp),%esi
call   10b0 <is_server_exist@plt>
mov    %eax,0x4(%rsp)
jmp    131a <change_same_name+0x16a>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%r13
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
jmp    1441 <change_same_name+0x291>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"(%d)\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@F_OK = global i32 0
define i8* @change_same_name(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [256 x i8]
%13 = alloca [6 x i8]
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 1, i32* %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
%19 = bitcast [256 x i8]* %12 to i8*
%20 = bitcast [6 x i8]* %13 to i8*
%21 = load i8*, i8** %5
%22 = call i8* @strrchr(i8* %21, i8 signext 47)
store i8* %22, i8** %14
%23 = load i8*, i8** %14
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %3
store i8* null, i8** %4
br label %132
26: ; preds = %3
%27 = load i8*, i8** %14
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %28, 1
%30 = call i8* @my_malloc(i32 %29)
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %34
33: ; preds = %26
store i8* null, i8** %4
br label %132
34: ; preds = %26
%35 = load i8*, i8** %9
%36 = load i8*, i8** %14
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %5
%40 = call i32 @strlen(i8* %39)
%41 = load i8*, i8** %14
%42 = call i32 @strlen(i8* %41)
%43 = sub nsw i32 %40, %42
%44 = add nsw i32 %43, 1
%45 = call i8* @my_malloc(i32 %44)
store i8* %45, i8** %11
%46 = load i8*, i8** %11
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %34
store i8* null, i8** %4
br label %132
49: ; preds = %34
%50 = load i8*, i8** %11
%51 = load i8*, i8** %5
%52 = call i32 @strlen(i8* %51)
%53 = load i8*, i8** %14
%54 = call i32 @strlen(i8* %53)
%55 = sub nsw i32 %52, %54
%56 = add nsw i32 %55, 1
%57 = load i8*, i8** %5
%58 = call i32 @snprintf(i8* %50, i32 %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %57)
store i32 1, i32* %15
br label %59
59: ; preds = %123, %49
%60 = load i32, i32* %15
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %126
62: ; preds = %59
%63 = load i32, i32* %8
store i32 %63, i32* %16
store i32 0, i32* %17
br label %64
64: ; preds = %68, %62
%65 = load i32, i32* %16
%66 = sdiv i32 %65, 10
store i32 %66, i32* %16
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = load i32, i32* %17
%70 = add nsw i32 %69, 1
store i32 %70, i32* %17
br label %64
71: ; preds = %64
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%73 = call i32 @memset(i8* %72, i8 signext 0, i32 256)
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%75 = load i32, i32* %17
%76 = sub nsw i32 252, %75
%77 = load i8*, i8** %9
%78 = call i32 @snprintf(i8* %74, i32 %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %77)
%79 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%80 = load i32, i32* %8
%81 = call i32 (i8*, i8*, ...) @sprintf(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %80)
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%83 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%84 = call i8* @insert_suffix(i8* %82, i8* %83)
store i8* %84, i8** %18
%85 = load i8*, i8** %18
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %88
87: ; preds = %71
store i8* null, i8** %4
br label %132
88: ; preds = %71
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
%91 = load i8*, i8** %11
%92 = call i32 @strlen(i8* %91)
%93 = load i8*, i8** %18
%94 = call i32 @strlen(i8* %93)
%95 = add nsw i32 %92, %94
%96 = add nsw i32 %95, 2
%97 = call i8* @my_malloc(i32 %96)
store i8* %97, i8** %10
%98 = load i8*, i8** %10
%99 = icmp eq i8* %98, null
br i1 %99, label %100, label %101
100: ; preds = %88
store i8* null, i8** %4
br label %132
101: ; preds = %88
%102 = load i8*, i8** %10
%103 = load i8*, i8** %11
%104 = load i8*, i8** %18
%105 = call i32 (i8*, i8*, ...) @sprintf(i8* %102, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %103, i8* %104)
%106 = load i32, i32* %7
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %112
108: ; preds = %101
%109 = load i8*, i8** %10
%110 = load i32, i32* %6
%111 = call i32 @is_server_exist(i8* %109, i32 %110)
store i32 %111, i32* %15
br label %123
112: ; preds = %101
%113 = load i32, i32* %7
%114 = icmp eq i32 %113, 1
br i1 %114, label %115, label %122
115: ; preds = %112
%116 = load i8*, i8** %10
%117 = load i32, i32* @F_OK
%118 = call i64 @access(i8* %116, i32 %117)
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %115
store i32 0, i32* %15
br label %121
121: ; preds = %120, %115
br label %122
122: ; preds = %121, %112
br label %123
123: ; preds = %122, %108
%124 = load i8*, i8** %18
%125 = call i32 @free(i8* %124)
br label %59
126: ; preds = %59
%127 = load i8*, i8** %11
%128 = call i32 @free(i8* %127)
%129 = load i8*, i8** %9
%130 = call i32 @free(i8* %129)
%131 = load i8*, i8** %10
store i8* %131, i8** %4
br label %132
132: ; preds = %126, %100, %87, %48, %33, %25
%133 = load i8*, i8** %4
ret i8* %133
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"(%d)\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@F_OK = global i32 0
define i8* @change_same_name(i8* %0, i32 %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = alloca [6 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%9 = icmp eq i8* %8, null
br i1 %9, label %74, label %10
10: ; preds = %3
%11 = tail call i32 @strlen(i8* %8)
%12 = add nsw i32 %11, 1
%13 = tail call i8* @my_malloc(i32 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %74, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = tail call i8* @strcpy(i8* %13, i8* %16)
%18 = tail call i32 @strlen(i8* %0)
%19 = tail call i32 @strlen(i8* %8)
%20 = add i32 %18, 1
%21 = sub i32 %20, %19
%22 = tail call i8* @my_malloc(i32 %21)
%23 = icmp eq i8* %22, null
br i1 %23, label %74, label %24
24: ; preds = %15
%25 = tail call i32 @strlen(i8* %0)
%26 = tail call i32 @strlen(i8* %8)
%27 = add i32 %25, 1
%28 = sub i32 %27, %26
%29 = tail call i32 @snprintf(i8* %22, i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %30
30: ; preds = %24, %67
%31 = phi i32 [ 1, %24 ], [ %68, %67 ]
%32 = phi i32 [ 1, %24 ], [ %50, %67 ]
%33 = icmp ult i32 %32, 10
br i1 %33, label %41, label %34
34: ; preds = %30, %34
%35 = phi i32 [ %38, %34 ], [ 0, %30 ]
%36 = phi i32 [ %37, %34 ], [ %32, %30 ]
%37 = sdiv i32 %36, 10
%38 = add nuw nsw i32 %35, 1
%39 = add nsw i32 %37, 9
%40 = icmp ult i32 %39, 19
br i1 %40, label %41, label %34
41: ; preds = %34, %30
%42 = phi i32 [ 0, %30 ], [ %38, %34 ]
%43 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%44 = sub nsw i32 252, %42
%45 = call i32 @snprintf(i8* %6, i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%47 = call i8* @insert_suffix(i8* %6, i8* %7)
%48 = icmp eq i8* %47, null
br i1 %48, label %74, label %49
49: ; preds = %41
%50 = add nuw nsw i32 %32, 1
%51 = call i32 @strlen(i8* %22)
%52 = call i32 @strlen(i8* %47)
%53 = add i32 %51, 2
%54 = add i32 %53, %52
%55 = call i8* @my_malloc(i32 %54)
%56 = icmp eq i8* %55, null
br i1 %56, label %74, label %57
57: ; preds = %49
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %55, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %47)
switch i32 %2, label %67 [
i32 0, label %59
i32 1, label %61
]
59: ; preds = %57
%60 = call i32 @is_server_exist(i8* %55, i32 %1)
br label %67
61: ; preds = %57
%62 = load i32, i32* @F_OK
%63 = call i64 @access(i8* %55, i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %61
%66 = call i32 @free(i8* %47)
br label %71
67: ; preds = %61, %59, %57
%68 = phi i32 [ %60, %59 ], [ %31, %57 ], [ %31, %61 ]
%69 = call i32 @free(i8* %47)
%70 = icmp eq i32 %68, 0
br i1 %70, label %71, label %30
71: ; preds = %67, %65
%72 = call i32 @free(i8* %22)
%73 = call i32 @free(i8* %13)
br label %74
74: ; preds = %49, %41, %71, %15, %10, %3
%75 = phi i8* [ null, %3 ], [ null, %10 ], [ null, %15 ], [ %55, %71 ], [ null, %41 ], [ null, %49 ]
ret i8* %75
}