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

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ change_password(char *, char *, char *);
int /*<<< orphan*/ chmod(char *, int);
char *concat(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, long *, char *);
int /*<<< orphan*/ printf(char *, long, char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ sleep(int);
void update_user_info(char *filename, char *username, char *password) {
  char *filelck = concat(filename, ".lck");
  while (1) {
    if (access(filelck, F_OK) == -1) {
      break;
    }
    FILE *fp = fopen(filelck, "r");
    long long_pid;
    char operation[10];
    fscanf(fp, "%ld %s", &long_pid, operation);
    fclose(fp);
    printf("%ld, %s. Wait for file unlock...\n", long_pid, operation);
    sleep(1);
  }
  FILE *fd = fopen(filelck, "ab+");
  chmod(filelck, S_IRUSR | S_IWUSR | S_IROTH);
  fclose(fd);
  change_password(filename, username, password);
  remove(filelck);
}


x86 assembly (clang, -O0):
<update_user_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1060 <concat@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
jne    11e8 <update_user_info+0x48>
jmp    1240 <update_user_info+0xa0>
mov    -0x20(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x3a(%rbp),%rcx
lea    0xdfc(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rsi
lea    -0x3a(%rbp),%rdx
lea    0xde2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
jmp    11c8 <update_user_info+0x28>
mov    -0x20(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
mov    0x2d80(%rip),%rax
or     (%rax),%esi
mov    0x2d67(%rip),%rax
or     (%rax),%esi
call   1080 <chmod@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10c0 <change_password@plt>
mov    -0x20(%rbp),%rdi
call   1030 <remove@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_user_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
lea    0xe41(%rip),%rsi
mov    %rdi,0x8(%rsp)
call   1060 <concat@plt>
mov    %rax,%rbx
mov    0x2ded(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rax,%rdi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     1259 <update_user_info+0xb9>
lea    0x20(%rsp),%r14
lea    0x2e(%rsp),%r15
lea    0xe1a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
lea    0xdfb(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
lea    0xdeb(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1070 <fscanf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    0x20(%rsp),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
jne    1200 <update_user_info+0x60>
lea    0xdd0(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    0x2d61(%rip),%rcx
mov    0x2d72(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    %rax,%rbp
mov    0x2d54(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1080 <chmod@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x18(%rsp),%rdx
call   10c0 <change_password@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".lck\00"
@F_OK = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%ld %s\00"
@.str.3 = [34 x i8] c"%ld, %s. Wait for file unlock...\0A\00"
@.str.4 = [4 x i8] c"ab+\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IROTH = global i32 0
define void @update_user_info(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca [10 x i8]
%11 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = load i8*, i8** %4
%13 = call i8* @concat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %7
br label %14
14: ; preds = %3, %20
%15 = load i8*, i8** %7
%16 = load i32, i32* @F_OK
%17 = call i32 @access(i8* %15, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %14
br label %32
20: ; preds = %14
%21 = load i8*, i8** %7
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %8
%23 = load i32*, i32** %8
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%25 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %9, i8* %24)
%26 = load i32*, i32** %8
%27 = call i32 @fclose(i32* %26)
%28 = load i64, i64* %9
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %28, i8* %29)
%31 = call i32 @sleep(i32 1)
br label %14
32: ; preds = %19
%33 = load i8*, i8** %7
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32* %34, i32** %11
%35 = load i8*, i8** %7
%36 = load i32, i32* @S_IRUSR
%37 = load i32, i32* @S_IWUSR
%38 = or i32 %36, %37
%39 = load i32, i32* @S_IROTH
%40 = or i32 %38, %39
%41 = call i32 @chmod(i8* %35, i32 %40)
%42 = load i32*, i32** %11
%43 = call i32 @fclose(i32* %42)
%44 = load i8*, i8** %4
%45 = load i8*, i8** %5
%46 = load i8*, i8** %6
%47 = call i32 @change_password(i8* %44, i8* %45, i8* %46)
%48 = load i8*, i8** %7
%49 = call i32 @remove(i8* %48)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".lck\00"
@F_OK = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%ld %s\00"
@.str.3 = [34 x i8] c"%ld, %s. Wait for file unlock...\0A\00"
@.str.4 = [4 x i8] c"ab+\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IROTH = global i32 0
define void @update_user_info(i8* %0, i8* %1, i8* %2) {
%4 = alloca i64
%5 = alloca [10 x i8]
%6 = tail call i8* @concat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @F_OK
%8 = call i32 @access(i8* %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %23, label %10
10: ; preds = %3
%11 = bitcast i64* %4 to i8*
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
br label %13
13: ; preds = %10, %13
%14 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %4, i8* %12)
%16 = call i32 @fclose(i32* %14)
%17 = load i64, i64* %4
%18 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %17, i8* %12)
%19 = call i32 @sleep(i32 1)
%20 = load i32, i32* @F_OK
%21 = call i32 @access(i8* %6, i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %13
23: ; preds = %13, %3
%24 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32, i32* @S_IRUSR
%26 = load i32, i32* @S_IWUSR
%27 = or i32 %26, %25
%28 = load i32, i32* @S_IROTH
%29 = or i32 %27, %28
%30 = call i32 @chmod(i8* %6, i32 %29)
%31 = call i32 @fclose(i32* %24)
%32 = call i32 @change_password(i8* %0, i8* %1, i8* %2)
%33 = call i32 @remove(i8* %6)
ret void
}