#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 is_server_exist(char *, int);
char *localpath_to_serverpath(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int remove(char *);
int USB_rm(char *localpath, int index) {
  printf("USB_rm() - %s start\n", localpath);
  int res = 0;
  int exsit = is_server_exist(localpath, index);
  if (!exsit)
    return res;
  char *serverpath = localpath_to_serverpath(localpath, index);
  res = remove(serverpath);
  free(serverpath);
  return res;
}


x86 assembly (clang, -O0):
<USB_rm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <is_server_exist@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    119a <USB_rm+0x4a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <USB_rm+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <localpath_to_serverpath@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <remove@plt>
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USB_rm>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <is_server_exist@plt>
test   %eax,%eax
je     1198 <USB_rm+0x48>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <localpath_to_serverpath@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <remove@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
jmp    119a <USB_rm+0x4a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"USB_rm() - %s start\0A\00"
define i32 @USB_rm(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i8*, i8** %4
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %6
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = call i32 @is_server_exist(i8* %11, i32 %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = load i32, i32* %6
store i32 %17, i32* %3
br label %27
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = call i8* @localpath_to_serverpath(i8* %19, i32 %20)
store i8* %21, i8** %8
%22 = load i8*, i8** %8
%23 = call i32 @remove(i8* %22)
store i32 %23, i32* %6
%24 = load i8*, i8** %8
%25 = call i32 @free(i8* %24)
%26 = load i32, i32* %6
store i32 %26, i32* %3
br label %27
27: ; preds = %18, %16
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [21 x i8] c"USB_rm() - %s start\0A\00"
define i32 @USB_rm(i8* %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @is_server_exist(i8* %0, i32 %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i8* @localpath_to_serverpath(i8* %0, i32 %1)
%8 = tail call i32 @remove(i8* %7)
%9 = tail call i32 @free(i8* %7)
br label %10
10: ; preds = %2, %6
%11 = phi i32 [ %8, %6 ], [ 0, %2 ]
ret i32 %11
}