#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 */
struct stat {
  long long st_size;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ usleep(int);
int is_smb_file_copying(char *serverpath, int index) {
  long long int d_value;
  struct stat old_info = {0}, new_info = {0};
  stat(serverpath, &old_info);
  usleep(1000 * 1000);
  stat(serverpath, &new_info);
  d_value = new_info.st_size - old_info.st_size;
  if (d_value)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<is_smb_file_copying>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <stat@plt>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x40(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a6 <is_smb_file_copying+0x76>
movl   $0x1,-0x4(%rbp)
jmp    11ad <is_smb_file_copying+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_smb_file_copying>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%rsi
call   1030 <stat@plt>
mov    $0xf4240,%edi
call   1040 <usleep@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <stat@plt>
mov    (%rsp),%rcx
xor    %eax,%eax
cmp    0x10(%rsp),%rcx
setne  %al
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
define i32 @is_smb_file_copying(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca %struct.stat
%8 = alloca %struct.stat
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = bitcast %struct.stat* %7 to i8*
%10 = bitcast %struct.stat* %8 to i8*
%11 = load i8*, i8** %4
%12 = call i32 @stat(i8* %11, %struct.stat* %7)
%13 = call i32 @usleep(i32 1000000)
%14 = load i8*, i8** %4
%15 = call i32 @stat(i8* %14, %struct.stat* %8)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%17 = load i64, i64* %16
%18 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%19 = load i64, i64* %18
%20 = sub nsw i64 %17, %19
store i64 %20, i64* %6
%21 = load i64, i64* %6
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %2
store i32 1, i32* %3
br label %25
24: ; preds = %2
store i32 0, i32* %3
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
define i32 @is_smb_file_copying(i8* nocapture %0, i32 %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = call i32 @stat(i8* %0, %struct.stat* %3)
%8 = tail call i32 @usleep(i32 1000000)
%9 = call i32 @stat(i8* %0, %struct.stat* %4)
%10 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i64, i64* %12
%14 = icmp ne i64 %11, %13
%15 = zext i1 %14 to i32
ret i32 %15
}