#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ add_user_to_list(char *);
int /*<<< orphan*/ delete_user_from_list(char *);
scalar_t__ fork();
int /*<<< orphan*/ init_bad_users_list();
int is_user_in_bad_list_cleint(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printf_bad_users_list();
int /*<<< orphan*/ remove_bad_users_list();
int /*<<< orphan*/ setgid(int);
int /*<<< orphan*/ setuid(int);
int /*<<< orphan*/ sleep(int);
int main() {
  pid_t pid = fork();
  if (pid == 0) {
    printf("init shared memory\n");
    init_bad_users_list();
    add_user_to_list("pepelac1");
    add_user_to_list("pepelac2");
    add_user_to_list("pepelac3");
    add_user_to_list("pepelac4");
    add_user_to_list("pepelac5");
    printf_bad_users_list();
    sleep(10);
    printf("Add existing user pepelac 4\n");
    add_user_to_list("pepelac4");
    printf_bad_users_list();
    printf("Delete user pepelac 4\n");
    delete_user_from_list("pepelac4");
    printf_bad_users_list();
    sleep(10);
    printf("Delete all users\n");
    delete_user_from_list("pepelac1");
    delete_user_from_list("pepelac2");
    delete_user_from_list("pepelac3");
    delete_user_from_list("pepelac5");
    printf_bad_users_list();
    sleep(10);
    remove_bad_users_list();
  } else {
    setuid(500);
    setgid(500);
    printf("Is peplac4 in list %d\n", is_user_in_bad_list_cleint("pepelac4"));
    sleep(3);
    printf("Is peplac4 in list %d\n", is_user_in_bad_list_cleint("pepelac4"));
    sleep(10);
    printf("Is peplac4 in list %d\n", is_user_in_bad_list_cleint("pepelac4"));
    sleep(10);
    printf("Is peplac4 in list %d\n", is_user_in_bad_list_cleint("pepelac4"));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12de <main+0x12e>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <init_bad_users_list@plt>
lea    0xe23(%rip),%rdi
call   1070 <add_user_to_list@plt>
lea    0xe20(%rip),%rdi
call   1070 <add_user_to_list@plt>
lea    0xe1d(%rip),%rdi
call   1070 <add_user_to_list@plt>
lea    0xe1a(%rip),%rdi
call   1070 <add_user_to_list@plt>
lea    0xe17(%rip),%rdi
call   1070 <add_user_to_list@plt>
mov    $0x0,%al
call   1050 <printf_bad_users_list@plt>
mov    $0xa,%edi
call   10c0 <sleep@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde3(%rip),%rdi
call   1070 <add_user_to_list@plt>
mov    $0x0,%al
call   1050 <printf_bad_users_list@plt>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc2(%rip),%rdi
call   1080 <delete_user_from_list@plt>
mov    $0x0,%al
call   1050 <printf_bad_users_list@plt>
mov    $0xa,%edi
call   10c0 <sleep@plt>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7c(%rip),%rdi
call   1080 <delete_user_from_list@plt>
lea    0xd79(%rip),%rdi
call   1080 <delete_user_from_list@plt>
lea    0xd76(%rip),%rdi
call   1080 <delete_user_from_list@plt>
lea    0xd7c(%rip),%rdi
call   1080 <delete_user_from_list@plt>
mov    $0x0,%al
call   1050 <printf_bad_users_list@plt>
mov    $0xa,%edi
call   10c0 <sleep@plt>
mov    $0x0,%al
call   1060 <remove_bad_users_list@plt>
jmp    1380 <main+0x1d0>
mov    $0x1f4,%edi
call   10b0 <setuid@plt>
mov    $0x1f4,%edi
call   1090 <setgid@plt>
lea    0xd36(%rip),%rdi
call   1030 <is_user_in_bad_list_cleint@plt>
mov    %eax,%esi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3,%edi
call   10c0 <sleep@plt>
lea    0xd10(%rip),%rdi
call   1030 <is_user_in_bad_list_cleint@plt>
mov    %eax,%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   10c0 <sleep@plt>
lea    0xcea(%rip),%rdi
call   1030 <is_user_in_bad_list_cleint@plt>
mov    %eax,%esi
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   10c0 <sleep@plt>
lea    0xcc4(%rip),%rdi
call   1030 <is_user_in_bad_list_cleint@plt>
mov    %eax,%esi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
je     126e <main+0xae>
mov    $0x1f4,%edi
call   10c0 <setuid@plt>
mov    $0x1f4,%edi
call   10a0 <setgid@plt>
lea    0xe27(%rip),%r14
mov    %r14,%rdi
call   1040 <is_user_in_bad_list_cleint@plt>
lea    0xe2a(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%edi
call   10d0 <sleep@plt>
mov    %r14,%rdi
call   1040 <is_user_in_bad_list_cleint@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   10d0 <sleep@plt>
mov    %r14,%rdi
call   1040 <is_user_in_bad_list_cleint@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   10d0 <sleep@plt>
mov    %r14,%rdi
call   1040 <is_user_in_bad_list_cleint@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1361 <main+0x1a1>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10b0 <init_bad_users_list@plt>
lea    0xd78(%rip),%r14
mov    %r14,%rdi
call   1080 <add_user_to_list@plt>
lea    0xd72(%rip),%r15
mov    %r15,%rdi
call   1080 <add_user_to_list@plt>
lea    0xd6c(%rip),%r12
mov    %r12,%rdi
call   1080 <add_user_to_list@plt>
lea    0xd66(%rip),%rbx
mov    %rbx,%rdi
call   1080 <add_user_to_list@plt>
lea    0xd60(%rip),%r13
mov    %r13,%rdi
call   1080 <add_user_to_list@plt>
xor    %eax,%eax
call   1060 <printf_bad_users_list@plt>
mov    $0xa,%edi
call   10d0 <sleep@plt>
lea    0xd73(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <add_user_to_list@plt>
xor    %eax,%eax
call   1060 <printf_bad_users_list@plt>
lea    0xd74(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <delete_user_from_list@plt>
xor    %eax,%eax
call   1060 <printf_bad_users_list@plt>
mov    $0xa,%edi
call   10d0 <sleep@plt>
lea    0xd65(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1090 <delete_user_from_list@plt>
mov    %r15,%rdi
call   1090 <delete_user_from_list@plt>
mov    %r12,%rdi
call   1090 <delete_user_from_list@plt>
mov    %r13,%rdi
call   1090 <delete_user_from_list@plt>
xor    %eax,%eax
call   1060 <printf_bad_users_list@plt>
mov    $0xa,%edi
call   10d0 <sleep@plt>
xor    %eax,%eax
call   1070 <remove_bad_users_list@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"init shared memory\0A\00"
@.str.1 = [9 x i8] c"pepelac1\00"
@.str.2 = [9 x i8] c"pepelac2\00"
@.str.3 = [9 x i8] c"pepelac3\00"
@.str.4 = [9 x i8] c"pepelac4\00"
@.str.5 = [9 x i8] c"pepelac5\00"
@.str.6 = [29 x i8] c"Add existing user pepelac 4\0A\00"
@.str.7 = [23 x i8] c"Delete user pepelac 4\0A\00"
@.str.8 = [18 x i8] c"Delete all users\0A\00"
@.str.9 = [23 x i8] c"Is peplac4 in list %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i64 (...) @fork()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %31
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @init_bad_users_list()
%9 = call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (...) @printf_bad_users_list()
%15 = call i32 @sleep(i32 10)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (...) @printf_bad_users_list()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (...) @printf_bad_users_list()
%22 = call i32 @sleep(i32 10)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 (...) @printf_bad_users_list()
%29 = call i32 @sleep(i32 10)
%30 = call i32 (...) @remove_bad_users_list()
br label %45
31: ; preds = %0
%32 = call i32 @setuid(i32 500)
%33 = call i32 @setgid(i32 500)
%34 = call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %34)
%36 = call i32 @sleep(i32 3)
%37 = call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %37)
%39 = call i32 @sleep(i32 10)
%40 = call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %40)
%42 = call i32 @sleep(i32 10)
%43 = call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %31, %6
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"pepelac1\00"
@.str.2 = [9 x i8] c"pepelac2\00"
@.str.3 = [9 x i8] c"pepelac3\00"
@.str.4 = [9 x i8] c"pepelac4\00"
@.str.5 = [9 x i8] c"pepelac5\00"
@.str.9 = [23 x i8] c"Is peplac4 in list %d\0A\00"
@str = [19 x i8] c"init shared memory\00"
@str.10 = [28 x i8] c"Add existing user pepelac 4\00"
@str.11 = [22 x i8] c"Delete user pepelac 4\00"
@str.12 = [17 x i8] c"Delete all users\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %28
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (...) @init_bad_users_list()
%6 = tail call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 (...) @printf_bad_users_list()
%12 = tail call i32 @sleep(i32 10)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
%14 = tail call i32 @add_user_to_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 (...) @printf_bad_users_list()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%17 = tail call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i32 (...) @printf_bad_users_list()
%19 = tail call i32 @sleep(i32 10)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%21 = tail call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @delete_user_from_list(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%25 = tail call i32 (...) @printf_bad_users_list()
%26 = tail call i32 @sleep(i32 10)
%27 = tail call i32 (...) @remove_bad_users_list()
br label %42
28: ; preds = %0
%29 = tail call i32 @setuid(i32 500)
%30 = tail call i32 @setgid(i32 500)
%31 = tail call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %31)
%33 = tail call i32 @sleep(i32 3)
%34 = tail call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %34)
%36 = tail call i32 @sleep(i32 10)
%37 = tail call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %37)
%39 = tail call i32 @sleep(i32 10)
%40 = tail call i32 @is_user_in_bad_list_cleint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %28, %3
ret i32 0
}