#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*/ time_t;

/* Variables and functions */
scalar_t__ ChangeFile_modtime(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ Getmodtime(char *, int);
int USB_upload(char *, int);
int /*<<< orphan*/ free(char *);
char *localpath_to_serverpath(char *, int);
int moveFolder(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int rename(char *, char *);
int /*<<< orphan*/ test_if_dir(char *);
int USB_remo(char *localoldpath, char *localnewpath, int index) {
  char *serveroldpath, *servernewpath;
  serveroldpath = localpath_to_serverpath(localoldpath, index);
  servernewpath = localpath_to_serverpath(localnewpath, index);
  int res = rename(serveroldpath, servernewpath);
  if (res != 0) {
    if (!test_if_dir(localnewpath)) {
      res = USB_upload(localnewpath, index);
      if (res == 0) {
        time_t modtime = Getmodtime(servernewpath, index);
        if (ChangeFile_modtime(localnewpath, modtime, index)) {
          printf("ChangeFile_modtime failed!\n");
        }
      }
    } else {
      res = moveFolder(localoldpath, localnewpath, index);
    }
  }
  free(serveroldpath);
  free(servernewpath);
  return res;
}


x86 assembly (clang, -O0):
<USB_remo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <localpath_to_serverpath@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <localpath_to_serverpath@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <rename@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     125e <USB_remo+0xce>
mov    -0x10(%rbp),%rdi
call   1090 <test_if_dir@plt>
cmp    $0x0,%eax
jne    1246 <USB_remo+0xb6>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <USB_upload@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1241 <USB_remo+0xb1>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <Getmodtime@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10b0 <ChangeFile_modtime@plt>
cmp    $0x0,%rax
je     123c <USB_remo+0xac>
lea    0xdc9(%rip),%rdi
call   1050 <printf@plt>
jmp    1241 <USB_remo+0xb1>
jmp    1259 <USB_remo+0xc9>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <moveFolder@plt>
mov    %eax,-0x2c(%rbp)
jmp    125e <USB_remo+0xce>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USB_remo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r13
mov    %rdi,%r12
mov    %edx,%esi
call   1080 <localpath_to_serverpath@plt>
mov    %rax,%r14
mov    %r13,%rdi
mov    %ebp,%esi
call   1080 <localpath_to_serverpath@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   10a0 <rename@plt>
test   %eax,%eax
je     121d <USB_remo+0x8d>
mov    %r13,%rdi
call   1090 <test_if_dir@plt>
test   %eax,%eax
je     11e6 <USB_remo+0x56>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1060 <moveFolder@plt>
mov    %eax,%ebx
jmp    121f <USB_remo+0x8f>
mov    %r13,%rdi
mov    %ebp,%esi
call   1070 <USB_upload@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    121f <USB_remo+0x8f>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <Getmodtime@plt>
mov    %r13,%rdi
mov    %eax,%esi
mov    %ebp,%edx
call   10b0 <ChangeFile_modtime@plt>
test   %rax,%rax
je     121d <USB_remo+0x8d>
lea    0xde8(%rip),%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"ChangeFile_modtime failed!\0A\00"
define i32 @USB_remo(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = call i8* @localpath_to_serverpath(i8* %11, i32 %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i8* @localpath_to_serverpath(i8* %14, i32 %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = call i32 @rename(i8* %17, i8* %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %51
22: ; preds = %3
%23 = load i8*, i8** %5
%24 = call i32 @test_if_dir(i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %45, label %26
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = call i32 @USB_upload(i8* %27, i32 %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %26
%33 = load i8*, i8** %8
%34 = load i32, i32* %6
%35 = call i32 @Getmodtime(i8* %33, i32 %34)
store i32 %35, i32* %10
%36 = load i8*, i8** %5
%37 = load i32, i32* %10
%38 = load i32, i32* %6
%39 = call i64 @ChangeFile_modtime(i8* %36, i32 %37, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %32
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %32
br label %44
44: ; preds = %43, %26
br label %50
45: ; preds = %22
%46 = load i8*, i8** %4
%47 = load i8*, i8** %5
%48 = load i32, i32* %6
%49 = call i32 @moveFolder(i8* %46, i8* %47, i32 %48)
store i32 %49, i32* %9
br label %50
50: ; preds = %45, %44
br label %51
51: ; preds = %50, %3
%52 = load i8*, i8** %7
%53 = call i32 @free(i8* %52)
%54 = load i8*, i8** %8
%55 = call i32 @free(i8* %54)
%56 = load i32, i32* %9
ret i32 %56
}

LLVM IR (-O2):
@str = [27 x i8] c"ChangeFile_modtime failed!\00"
define i32 @USB_remo(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @localpath_to_serverpath(i8* %0, i32 %2)
%5 = tail call i8* @localpath_to_serverpath(i8* %1, i32 %2)
%6 = tail call i32 @rename(i8* %4, i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %3
%9 = tail call i32 @test_if_dir(i8* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = tail call i32 @USB_upload(i8* %1, i32 %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = tail call i32 @Getmodtime(i8* %5, i32 %2)
%16 = tail call i64 @ChangeFile_modtime(i8* %1, i32 %15, i32 %2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %22
20: ; preds = %8
%21 = tail call i32 @moveFolder(i8* %0, i8* %1, i32 %2)
br label %22
22: ; preds = %14, %18, %20, %11, %3
%23 = phi i32 [ %21, %20 ], [ %12, %11 ], [ 0, %3 ], [ 0, %18 ], [ 0, %14 ]
%24 = tail call i32 @free(i8* %4)
%25 = tail call i32 @free(i8* %5)
ret i32 %23
}