#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 time_t;
struct stat {
  int st_mtime;
};

/* Variables and functions */
int /*<<< orphan*/ ChangeFile_modtime(char *, int, int);
int Getmodtime(char *, int);
char *localpath_to_serverpath(char *, int);
int /*<<< orphan*/ perror(char *);
int stat(char *, struct stat *);
int init_newer_file(char *localpath, int index) {
  char *serverpath;
  serverpath = localpath_to_serverpath(localpath, index);
  struct stat cli_info;
  if ((stat(localpath, &cli_info) == -1)) {
    perror("stat:");
    return -1;
  }
  time_t smb_modtime, d_modtime;
  smb_modtime = Getmodtime(serverpath, index);
  d_modtime = smb_modtime - cli_info.st_mtime;
  if (d_modtime == 0) {
    return 1;
  } else if (d_modtime == 1 || d_modtime == -1) {
    ChangeFile_modtime(localpath, smb_modtime, index);
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<init_newer_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <localpath_to_serverpath@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
jne    119d <init_newer_file+0x4d>
lea    0xe74(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <init_newer_file+0xb1>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <Getmodtime@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    11cb <init_newer_file+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    1201 <init_newer_file+0xb1>
cmpl   $0x1,-0x30(%rbp)
je     11df <init_newer_file+0x8f>
cmpl   $0xffffffff,-0x30(%rbp)
jne    11fa <init_newer_file+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <ChangeFile_modtime@plt>
movl   $0x1,-0x4(%rbp)
jmp    1201 <init_newer_file+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_newer_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
call   1050 <localpath_to_serverpath@plt>
mov    %rax,%rbp
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
je     11ad <init_newer_file+0x5d>
mov    %rbp,%rdi
mov    %r15d,%esi
call   1030 <Getmodtime@plt>
mov    %eax,%ecx
sub    (%rsp),%ecx
mov    $0x1,%r14d
cmp    $0x1,%ecx
je     1199 <init_newer_file+0x49>
test   %ecx,%ecx
je     11bf <init_newer_file+0x6f>
cmp    $0xffffffff,%ecx
jne    11a8 <init_newer_file+0x58>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15d,%edx
call   1070 <ChangeFile_modtime@plt>
jmp    11bf <init_newer_file+0x6f>
xor    %r14d,%r14d
jmp    11bf <init_newer_file+0x6f>
lea    0xe4c(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [6 x i8] c"stat:\00"
define i32 @init_newer_file(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = call i8* @localpath_to_serverpath(i8* %10, i32 %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %4
%14 = call i32 @stat(i8* %13, %struct.stat* %7)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %41
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = load i32, i32* %5
%21 = call i32 @Getmodtime(i8* %19, i32 %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%24 = load i32, i32* %23
%25 = sub nsw i32 %22, %24
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %18
store i32 1, i32* %3
br label %41
29: ; preds = %18
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 1
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i32, i32* %9
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %40
35: ; preds = %32, %29
%36 = load i8*, i8** %4
%37 = load i32, i32* %8
%38 = load i32, i32* %5
%39 = call i32 @ChangeFile_modtime(i8* %36, i32 %37, i32 %38)
store i32 1, i32* %3
br label %41
40: ; preds = %32
store i32 0, i32* %3
br label %41
41: ; preds = %40, %35, %28, %16
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [6 x i8] c"stat:\00"
define i32 @init_newer_file(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = tail call i8* @localpath_to_serverpath(i8* %0, i32 %1)
%5 = bitcast %struct.stat* %3 to i8*
%6 = call i32 @stat(i8* %0, %struct.stat* %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = tail call i32 @Getmodtime(i8* %4, i32 %1)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = sub nsw i32 %11, %13
switch i32 %14, label %17 [
i32 0, label %18
i32 -1, label %15
i32 1, label %15
]
15: ; preds = %10, %10
%16 = tail call i32 @ChangeFile_modtime(i8* %0, i32 %11, i32 %1)
br label %18
17: ; preds = %10
br label %18
18: ; preds = %10, %17, %15, %8
%19 = phi i32 [ -1, %8 ], [ 1, %15 ], [ 1, %10 ], [ 0, %17 ]
ret i32 %19
}