#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 {
  int st_mode;
};
typedef int mode_t;

/* Variables and functions */
int S_IRUSR;
int S_IXUSR;
int /*<<< orphan*/ chmod(char *, int);
int /*<<< orphan*/ logInfoMessages(char *, char *);
int stat(char *, struct stat *);
int lockAllFiles(char *path) {
  int status;
  struct stat buffer;
  struct stat st;
  mode_t mode;
  stat(path, &st);
  mode = st.st_mode & 33188;
  mode &= ~(S_IRUSR);
  mode |= S_IXUSR;
  chmod(path, mode);
  status = stat(path, &buffer);
  logInfoMessages("locking folder", path);
  return status;
}


x86 assembly (clang, -O0):
<lockAllFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x18(%rbp),%eax
and    $0x81a4,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <chmod@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1030 <logInfoMessages@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lockAllFiles>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%esi
not    %esi
and    0x8(%rsp),%esi
and    $0x81a4,%esi
mov    0x2e89(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1050 <chmod@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
mov    %eax,%ebp
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
call   1030 <logInfoMessages@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IRUSR = global i32 0
@S_IXUSR = global i32 0
@.str = [15 x i8] c"locking folder\00"
define i32 @lockAllFiles(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.stat
%5 = alloca %struct.stat
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @stat(i8* %7, %struct.stat* %5)
%9 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%10 = load i32, i32* %9
%11 = and i32 %10, 33188
store i32 %11, i32* %6
%12 = load i32, i32* @S_IRUSR
%13 = xor i32 %12, -1
%14 = load i32, i32* %6
%15 = and i32 %14, %13
store i32 %15, i32* %6
%16 = load i32, i32* @S_IXUSR
%17 = load i32, i32* %6
%18 = or i32 %17, %16
store i32 %18, i32* %6
%19 = load i8*, i8** %2
%20 = load i32, i32* %6
%21 = call i32 @chmod(i8* %19, i32 %20)
%22 = load i8*, i8** %2
%23 = call i32 @stat(i8* %22, %struct.stat* %4)
store i32 %23, i32* %3
%24 = load i8*, i8** %2
%25 = call i32 @logInfoMessages(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@S_IRUSR = global i32 0
@S_IXUSR = global i32 0
@.str = [15 x i8] c"locking folder\00"
define i32 @lockAllFiles(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %2 to i8*
%5 = bitcast %struct.stat* %3 to i8*
%6 = call i32 @stat(i8* %0, %struct.stat* %3)
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%8 = load i32, i32* %7
%9 = and i32 %8, 33188
%10 = load i32, i32* @S_IRUSR
%11 = xor i32 %10, -1
%12 = and i32 %9, %11
%13 = load i32, i32* @S_IXUSR
%14 = or i32 %12, %13
%15 = tail call i32 @chmod(i8* %0, i32 %14)
%16 = call i32 @stat(i8* %0, %struct.stat* %2)
%17 = tail call i32 @logInfoMessages(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
ret i32 %16
}