#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*/ pthread_mutexattr_t;
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ PTHREAD_PROCESS_SHARED;
int fork();
int /*<<< orphan*/ ftruncate(int, int);
char *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutexattr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutexattr_setpshared(int /*<<< orphan*/ *,
                                                int /*<<< orphan*/);
int shm_open(char *, int, int);
int /*<<< orphan*/ shm_unlink(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  int *x;
  int rt;
  int shm_id;
  char *addnum = "myadd";
  char *ptr;
  pthread_mutex_t mutex;
  pthread_mutexattr_t mutexattr;
  pthread_mutexattr_init(&mutexattr);
  pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
  rt = fork();
  if (rt == 0) {
    shm_id = shm_open(addnum, O_RDWR, 0);
    ptr =
        mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, shm_id, 0);
    x = (int *)ptr;
    for (int i = 0; i < 10; i++) {
      pthread_mutex_lock(&mutex);
      (*x)++;
      printf("x++:%d\n", *x);
      pthread_mutex_unlock(&mutex);
      sleep(1);
    }
  } else {
    shm_id = shm_open(addnum, O_RDWR | O_CREAT, 0644);
    ftruncate(shm_id, sizeof(int));
    ptr =
        mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, shm_id, 0);
    x = (int *)ptr;
    for (int i = 0; i < 10; i++) {
      pthread_mutex_lock(&mutex);
      (*x) += 2;
      printf("x+=2:%d\n", *x);
      pthread_mutex_unlock(&mutex);
      sleep(1);
    }
  }
  shm_unlink(addnum);
  munmap(ptr, sizeof(int));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe2a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
call   10a0 <pthread_mutexattr_init@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1060 <pthread_mutexattr_setpshared@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    12b9 <main+0xf9>
mov    -0x20(%rbp),%rdi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <shm_open@plt>
mov    %eax,-0x18(%rbp)
mov    0x2dc9(%rip),%rax
mov    (%rax),%edx
mov    0x2d90(%rip),%rax
or     (%rax),%edx
mov    0x2da7(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    12b4 <main+0xf4>
lea    -0x2c(%rbp),%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xd78(%rip),%rdi
call   1040 <printf@plt>
lea    -0x2c(%rbp),%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1263 <main+0xa3>
jmp    1382 <main+0x1c2>
mov    -0x20(%rbp),%rdi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    0x2d2b(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1090 <shm_open@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   1050 <ftruncate@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
mov    0x2cc7(%rip),%rax
or     (%rax),%edx
mov    0x2cde(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    137d <main+0x1bd>
lea    -0x2c(%rbp),%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xcb7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x2c(%rbp),%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    132c <main+0x16c>
jmp    1382 <main+0x1c2>
mov    -0x20(%rbp),%rdi
call   10b0 <shm_unlink@plt>
mov    -0x28(%rbp),%rdi
mov    $0x4,%esi
call   1080 <munmap@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <pthread_mutexattr_init@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <pthread_mutexattr_setpshared@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
mov    0x2ddb(%rip),%rcx
mov    (%rcx),%esi
test   %eax,%eax
je     13e6 <main+0x226>
mov    0x2df2(%rip),%rax
or     (%rax),%esi
lea    0xdf1(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <shm_open@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x4,%esi
call   1050 <ftruncate@plt>
mov    0x2dc2(%rip),%rax
mov    0x2d8b(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2da0(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x4,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
lea    0xd9c(%rip),%r15
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x2,%esi
jmp    15ae <main+0x3ee>
lea    0xc13(%rip),%rdi
xor    %edx,%edx
call   1090 <shm_open@plt>
mov    0x2bf5(%rip),%rcx
mov    0x2bbe(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2bd3(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    $0x4,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
lea    0xbc7(%rip),%r15
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    %r14,%rdi
call   10e0 <pthread_mutex_lock@plt>
mov    (%rbx),%esi
add    $0x1,%esi
mov    %esi,(%rbx)
mov    %r15,%rdi
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
lea    0xa2d(%rip),%rdi
call   10b0 <shm_unlink@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1080 <munmap@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"myadd\00"
@PTHREAD_PROCESS_SHARED = global i32 0
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.1 = [8 x i8] c"x++:%d\0A\00"
@O_CREAT = global i32 0
@.str.2 = [9 x i8] c"x+=2:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
%11 = call i32 @pthread_mutexattr_init(i32* %8)
%12 = load i32, i32* @PTHREAD_PROCESS_SHARED
%13 = call i32 @pthread_mutexattr_setpshared(i32* %8, i32 %12)
%14 = call i32 (...) @fork()
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %46
17: ; preds = %0
%18 = load i8*, i8** %5
%19 = load i32, i32* @O_RDWR
%20 = call i32 @shm_open(i8* %18, i32 %19, i32 0)
store i32 %20, i32* %4
%21 = load i32, i32* @PROT_READ
%22 = load i32, i32* @PROT_WRITE
%23 = or i32 %21, %22
%24 = load i32, i32* @MAP_SHARED
%25 = load i32, i32* %4
%26 = call i8* @mmap(i32* null, i32 4, i32 %23, i32 %24, i32 %25, i32 0)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = bitcast i8* %27 to i32*
store i32* %28, i32** %2
store i32 0, i32* %9
br label %29
29: ; preds = %42, %17
%30 = load i32, i32* %9
%31 = icmp slt i32 %30, 10
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = call i32 @pthread_mutex_lock(i32* %7)
%34 = load i32*, i32** %2
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 1
store i32 %36, i32* %34
%37 = load i32*, i32** %2
%38 = load i32, i32* %37
%39 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = call i32 @pthread_mutex_unlock(i32* %7)
%41 = call i32 @sleep(i32 1)
br label %42
42: ; preds = %32
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %29
45: ; preds = %29
br label %79
46: ; preds = %0
%47 = load i8*, i8** %5
%48 = load i32, i32* @O_RDWR
%49 = load i32, i32* @O_CREAT
%50 = or i32 %48, %49
%51 = call i32 @shm_open(i8* %47, i32 %50, i32 420)
store i32 %51, i32* %4
%52 = load i32, i32* %4
%53 = call i32 @ftruncate(i32 %52, i32 4)
%54 = load i32, i32* @PROT_READ
%55 = load i32, i32* @PROT_WRITE
%56 = or i32 %54, %55
%57 = load i32, i32* @MAP_SHARED
%58 = load i32, i32* %4
%59 = call i8* @mmap(i32* null, i32 4, i32 %56, i32 %57, i32 %58, i32 0)
store i8* %59, i8** %6
%60 = load i8*, i8** %6
%61 = bitcast i8* %60 to i32*
store i32* %61, i32** %2
store i32 0, i32* %10
br label %62
62: ; preds = %75, %46
%63 = load i32, i32* %10
%64 = icmp slt i32 %63, 10
br i1 %64, label %65, label %78
65: ; preds = %62
%66 = call i32 @pthread_mutex_lock(i32* %7)
%67 = load i32*, i32** %2
%68 = load i32, i32* %67
%69 = add nsw i32 %68, 2
store i32 %69, i32* %67
%70 = load i32*, i32** %2
%71 = load i32, i32* %70
%72 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %71)
%73 = call i32 @pthread_mutex_unlock(i32* %7)
%74 = call i32 @sleep(i32 1)
br label %75
75: ; preds = %65
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
br label %62
78: ; preds = %62
br label %79
79: ; preds = %78, %45
%80 = load i8*, i8** %5
%81 = call i32 @shm_unlink(i8* %80)
%82 = load i8*, i8** %6
%83 = call i32 @munmap(i8* %82, i32 4)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"myadd\00"
@PTHREAD_PROCESS_SHARED = global i32 0
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.1 = [8 x i8] c"x++:%d\0A\00"
@O_CREAT = global i32 0
@.str.2 = [9 x i8] c"x+=2:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @pthread_mutexattr_init(i32* %2)
%6 = load i32, i32* @PTHREAD_PROCESS_SHARED
%7 = call i32 @pthread_mutexattr_setpshared(i32* %2, i32 %6)
%8 = call i32 (...) @fork()
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @O_RDWR
br i1 %9, label %11, label %77
11: ; preds = %0
%12 = call i32 @shm_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10, i32 0)
%13 = load i32, i32* @PROT_READ
%14 = load i32, i32* @PROT_WRITE
%15 = or i32 %14, %13
%16 = load i32, i32* @MAP_SHARED
%17 = call i8* @mmap(i32* null, i32 4, i32 %15, i32 %16, i32 %12, i32 0)
%18 = bitcast i8* %17 to i32*
%19 = call i32 @pthread_mutex_lock(i32* %1)
%20 = load i32, i32* %18
%21 = add nsw i32 %20, 1
store i32 %21, i32* %18
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @pthread_mutex_unlock(i32* %1)
%24 = call i32 @sleep(i32 1)
%25 = call i32 @pthread_mutex_lock(i32* %1)
%26 = load i32, i32* %18
%27 = add nsw i32 %26, 1
store i32 %27, i32* %18
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = call i32 @pthread_mutex_unlock(i32* %1)
%30 = call i32 @sleep(i32 1)
%31 = call i32 @pthread_mutex_lock(i32* %1)
%32 = load i32, i32* %18
%33 = add nsw i32 %32, 1
store i32 %33, i32* %18
%34 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = call i32 @pthread_mutex_unlock(i32* %1)
%36 = call i32 @sleep(i32 1)
%37 = call i32 @pthread_mutex_lock(i32* %1)
%38 = load i32, i32* %18
%39 = add nsw i32 %38, 1
store i32 %39, i32* %18
%40 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = call i32 @pthread_mutex_unlock(i32* %1)
%42 = call i32 @sleep(i32 1)
%43 = call i32 @pthread_mutex_lock(i32* %1)
%44 = load i32, i32* %18
%45 = add nsw i32 %44, 1
store i32 %45, i32* %18
%46 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %45)
%47 = call i32 @pthread_mutex_unlock(i32* %1)
%48 = call i32 @sleep(i32 1)
%49 = call i32 @pthread_mutex_lock(i32* %1)
%50 = load i32, i32* %18
%51 = add nsw i32 %50, 1
store i32 %51, i32* %18
%52 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = call i32 @pthread_mutex_unlock(i32* %1)
%54 = call i32 @sleep(i32 1)
%55 = call i32 @pthread_mutex_lock(i32* %1)
%56 = load i32, i32* %18
%57 = add nsw i32 %56, 1
store i32 %57, i32* %18
%58 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %57)
%59 = call i32 @pthread_mutex_unlock(i32* %1)
%60 = call i32 @sleep(i32 1)
%61 = call i32 @pthread_mutex_lock(i32* %1)
%62 = load i32, i32* %18
%63 = add nsw i32 %62, 1
store i32 %63, i32* %18
%64 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %63)
%65 = call i32 @pthread_mutex_unlock(i32* %1)
%66 = call i32 @sleep(i32 1)
%67 = call i32 @pthread_mutex_lock(i32* %1)
%68 = load i32, i32* %18
%69 = add nsw i32 %68, 1
store i32 %69, i32* %18
%70 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = call i32 @pthread_mutex_unlock(i32* %1)
%72 = call i32 @sleep(i32 1)
%73 = call i32 @pthread_mutex_lock(i32* %1)
%74 = load i32, i32* %18
%75 = add nsw i32 %74, 1
store i32 %75, i32* %18
%76 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %75)
br label %146
77: ; preds = %0
%78 = load i32, i32* @O_CREAT
%79 = or i32 %78, %10
%80 = call i32 @shm_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %79, i32 420)
%81 = call i32 @ftruncate(i32 %80, i32 4)
%82 = load i32, i32* @PROT_READ
%83 = load i32, i32* @PROT_WRITE
%84 = or i32 %83, %82
%85 = load i32, i32* @MAP_SHARED
%86 = call i8* @mmap(i32* null, i32 4, i32 %84, i32 %85, i32 %80, i32 0)
%87 = bitcast i8* %86 to i32*
%88 = call i32 @pthread_mutex_lock(i32* %1)
%89 = load i32, i32* %87
%90 = add nsw i32 %89, 2
store i32 %90, i32* %87
%91 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = call i32 @pthread_mutex_unlock(i32* %1)
%93 = call i32 @sleep(i32 1)
%94 = call i32 @pthread_mutex_lock(i32* %1)
%95 = load i32, i32* %87
%96 = add nsw i32 %95, 2
store i32 %96, i32* %87
%97 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %96)
%98 = call i32 @pthread_mutex_unlock(i32* %1)
%99 = call i32 @sleep(i32 1)
%100 = call i32 @pthread_mutex_lock(i32* %1)
%101 = load i32, i32* %87
%102 = add nsw i32 %101, 2
store i32 %102, i32* %87
%103 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %102)
%104 = call i32 @pthread_mutex_unlock(i32* %1)
%105 = call i32 @sleep(i32 1)
%106 = call i32 @pthread_mutex_lock(i32* %1)
%107 = load i32, i32* %87
%108 = add nsw i32 %107, 2
store i32 %108, i32* %87
%109 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %108)
%110 = call i32 @pthread_mutex_unlock(i32* %1)
%111 = call i32 @sleep(i32 1)
%112 = call i32 @pthread_mutex_lock(i32* %1)
%113 = load i32, i32* %87
%114 = add nsw i32 %113, 2
store i32 %114, i32* %87
%115 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %114)
%116 = call i32 @pthread_mutex_unlock(i32* %1)
%117 = call i32 @sleep(i32 1)
%118 = call i32 @pthread_mutex_lock(i32* %1)
%119 = load i32, i32* %87
%120 = add nsw i32 %119, 2
store i32 %120, i32* %87
%121 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %120)
%122 = call i32 @pthread_mutex_unlock(i32* %1)
%123 = call i32 @sleep(i32 1)
%124 = call i32 @pthread_mutex_lock(i32* %1)
%125 = load i32, i32* %87
%126 = add nsw i32 %125, 2
store i32 %126, i32* %87
%127 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %126)
%128 = call i32 @pthread_mutex_unlock(i32* %1)
%129 = call i32 @sleep(i32 1)
%130 = call i32 @pthread_mutex_lock(i32* %1)
%131 = load i32, i32* %87
%132 = add nsw i32 %131, 2
store i32 %132, i32* %87
%133 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %132)
%134 = call i32 @pthread_mutex_unlock(i32* %1)
%135 = call i32 @sleep(i32 1)
%136 = call i32 @pthread_mutex_lock(i32* %1)
%137 = load i32, i32* %87
%138 = add nsw i32 %137, 2
store i32 %138, i32* %87
%139 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %138)
%140 = call i32 @pthread_mutex_unlock(i32* %1)
%141 = call i32 @sleep(i32 1)
%142 = call i32 @pthread_mutex_lock(i32* %1)
%143 = load i32, i32* %87
%144 = add nsw i32 %143, 2
store i32 %144, i32* %87
%145 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %144)
br label %146
146: ; preds = %77, %11
%147 = phi i8* [ %17, %11 ], [ %86, %77 ]
%148 = call i32 @pthread_mutex_unlock(i32* %1)
%149 = call i32 @sleep(i32 1)
%150 = call i32 @shm_unlink(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%151 = call i32 @munmap(i8* %147, i32 4)
ret i32 0
}