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

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ *SEM_FAILED;
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ memcpy(void *, int *, int);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *sem_open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sem_post(int /*<<< orphan*/ *);
int /*<<< orphan*/ sem_wait(int /*<<< orphan*/ *);
int shm_open(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sleep(int);
void reader() {
  sem_t *read_bin_sem = sem_open("/read_bin_sem", O_RDWR);
  if (read_bin_sem == SEM_FAILED) {
    die("sem_open()");
  }
  sem_t *rw_bin_sem = sem_open("/rw_bin_sem", O_RDWR);
  if (rw_bin_sem == SEM_FAILED) {
    die("sem_open()");
  }
  int shm_fd1;
  if ((shm_fd1 = shm_open("/buffer", O_RDWR, 0666)) < 0) {
    die("shm_open()");
  }
  void *buffer_addr =
      mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd1, 0);
  int shm_fd2;
  if ((shm_fd2 = shm_open("/reader_counter", O_RDWR, 0666)) < 0) {
    die("shm_open()");
  }
  void *reader_counter_addr =
      mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd2, 0);
  int reader_counter = 0;
  int value = 0;
  while (1) {
    sleep(1);
    if (value == 10) {
      munmap(buffer_addr, sizeof(int));
      munmap(reader_counter_addr, sizeof(int));
      exit(0);
    }
    sem_wait(read_bin_sem);
    memcpy(&reader_counter, reader_counter_addr, sizeof(int));
    reader_counter++;
    memcpy(reader_counter_addr, &reader_counter, sizeof(int));
    if (reader_counter == 1) {
      sem_wait(rw_bin_sem);
    }
    sem_post(read_bin_sem);
    memcpy(&value, buffer_addr, sizeof(int));
    printf("The reader (%lu) reads the value %d\n", getpid(), value);
    sem_wait(read_bin_sem);
    memcpy(&reader_counter, reader_counter_addr, sizeof(int));
    reader_counter--;
    memcpy(reader_counter_addr, &reader_counter, sizeof(int));
    if (reader_counter == 0) {
      sem_post(rw_bin_sem);
    }
    sem_post(read_bin_sem);
  }
}


x86 assembly (clang, -O0):
<reader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
lea    0xe28(%rip),%rdi
call   1080 <sem_open@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%rax
jne    1201 <reader+0x41>
lea    0xe12(%rip),%rdi
call   10b0 <die@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
lea    0xe08(%rip),%rdi
call   1080 <sem_open@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2dab(%rip),%rcx
cmp    (%rcx),%rax
jne    123a <reader+0x7a>
lea    0xdd9(%rip),%rdi
call   10b0 <die@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
lea    0xddb(%rip),%rdi
mov    $0x1b6,%edx
call   10d0 <shm_open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    126c <reader+0xac>
lea    0xdc6(%rip),%rdi
call   10b0 <die@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edx
mov    0x2d44(%rip),%rax
or     (%rax),%edx
mov    0x2d63(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
lea    0xd88(%rip),%rdi
mov    $0x1b6,%edx
call   10d0 <shm_open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12d2 <reader+0x112>
lea    0xd60(%rip),%rdi
call   10b0 <die@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edx
mov    0x2cde(%rip),%rax
or     (%rax),%edx
mov    0x2cfd(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    $0x1,%edi
call   10e0 <sleep@plt>
cmpl   $0xa,-0x38(%rbp)
jne    134b <reader+0x18b>
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   10a0 <munmap@plt>
mov    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   10a0 <munmap@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <sem_wait@plt>
lea    -0x34(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
cmpl   $0x1,-0x34(%rbp)
jne    1394 <reader+0x1d4>
mov    -0x10(%rbp),%rdi
call   1030 <sem_wait@plt>
mov    -0x8(%rbp),%rdi
call   1070 <sem_post@plt>
lea    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x38(%rbp),%edx
lea    0xc86(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <sem_wait@plt>
lea    -0x34(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
cmpl   $0x0,-0x34(%rbp)
jne    1410 <reader+0x250>
mov    -0x10(%rbp),%rdi
call   1070 <sem_post@plt>
mov    -0x8(%rbp),%rdi
call   1070 <sem_post@plt>
jmp    1314 <reader+0x154>

x86 assembly (clang, -O2):
<reader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e03(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xe21(%rip),%rdi
call   1080 <sem_open@plt>
mov    %rax,%r12
mov    0x2de2(%rip),%rbx
cmp    (%rbx),%rax
jne    11ff <reader+0x3f>
lea    0xe14(%rip),%rdi
call   10b0 <die@plt>
mov    0x0(%rbp),%esi
lea    0xe10(%rip),%rdi
call   1080 <sem_open@plt>
mov    %rax,0x10(%rsp)
cmp    (%rbx),%rax
jne    1224 <reader+0x64>
lea    0xdef(%rip),%rdi
call   10b0 <die@plt>
mov    0x0(%rbp),%esi
lea    0xdf7(%rip),%rdi
mov    $0x1b6,%edx
call   10d0 <shm_open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    124a <reader+0x8a>
lea    0xde8(%rip),%rdi
call   10b0 <die@plt>
mov    0x2da7(%rip),%rax
mov    0x2d68(%rip),%r13
mov    0x0(%r13),%edx
or     (%rax),%edx
mov    0x2d83(%rip),%r14
mov    (%r14),%ecx
xor    %edi,%edi
mov    $0x4,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%r15
mov    0x0(%rbp),%esi
lea    0xdb1(%rip),%rdi
mov    $0x1b6,%edx
call   10d0 <shm_open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    12a3 <reader+0xe3>
lea    0xd8f(%rip),%rdi
call   10b0 <die@plt>
mov    0x0(%r13),%edx
mov    0x2d4a(%rip),%rax
or     (%rax),%edx
mov    (%r14),%ecx
xor    %edi,%edi
mov    $0x4,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0x1,%edi
call   10e0 <sleep@plt>
lea    0x8(%rsp),%r13
lea    0xc(%rsp),%rbp
lea    0xd55(%rip),%r14
jmp    137a <reader+0x1ba>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1070 <sem_post@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %r12,%rdi
call   1030 <sem_wait@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
addl   $0xffffffff,0x8(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
cmpl   $0x0,0x8(%rsp)
je     13d0 <reader+0x210>
mov    %r12,%rdi
call   1070 <sem_post@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
cmpl   $0xa,0xc(%rsp)
je     13dc <reader+0x21c>
mov    %r12,%rdi
call   1030 <sem_wait@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
addl   $0x1,0x8(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
cmpl   $0x1,0x8(%rsp)
jne    1300 <reader+0x140>
mov    0x10(%rsp),%rdi
call   1030 <sem_wait@plt>
jmp    1300 <reader+0x140>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
call   1070 <sem_post@plt>
jmp    1361 <reader+0x1a1>
mov    %r15,%rdi
mov    $0x4,%esi
call   10a0 <munmap@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   10a0 <munmap@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/read_bin_sem\00"
@O_RDWR = global i32 0
@SEM_FAILED = global i32* null
@.str.1 = [11 x i8] c"sem_open()\00"
@.str.2 = [12 x i8] c"/rw_bin_sem\00"
@.str.3 = [8 x i8] c"/buffer\00"
@.str.4 = [11 x i8] c"shm_open()\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.5 = [16 x i8] c"/reader_counter\00"
@.str.6 = [37 x i8] c"The reader (%lu) reads the value %d\0A\00"
define void @reader() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = load i32, i32* @O_RDWR
%10 = call i32* @sem_open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32* %10, i32** %1
%11 = load i32*, i32** %1
%12 = load i32*, i32** @SEM_FAILED
%13 = icmp eq i32* %11, %12
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = load i32, i32* @O_RDWR
%18 = call i32* @sem_open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %17)
store i32* %18, i32** %2
%19 = load i32*, i32** %2
%20 = load i32*, i32** @SEM_FAILED
%21 = icmp eq i32* %19, %20
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = load i32, i32* @O_RDWR
%26 = call i32 @shm_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 438)
store i32 %26, i32* %3
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @PROT_WRITE
%33 = or i32 %31, %32
%34 = load i32, i32* @MAP_SHARED
%35 = load i32, i32* %3
%36 = call i8* @mmap(i32* null, i32 4, i32 %33, i32 %34, i32 %35, i32 0)
store i8* %36, i8** %4
%37 = load i32, i32* @O_RDWR
%38 = call i32 @shm_open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %37, i32 438)
store i32 %38, i32* %5
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %30
%41 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40, %30
%43 = load i32, i32* @PROT_READ
%44 = load i32, i32* @PROT_WRITE
%45 = or i32 %43, %44
%46 = load i32, i32* @MAP_SHARED
%47 = load i32, i32* %5
%48 = call i8* @mmap(i32* null, i32 4, i32 %45, i32 %46, i32 %47, i32 0)
store i8* %48, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %49
49: ; preds = %42, %100
%50 = call i32 @sleep(i32 1)
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 10
br i1 %52, label %53, label %59
53: ; preds = %49
%54 = load i8*, i8** %4
%55 = call i32 @munmap(i8* %54, i32 4)
%56 = load i8*, i8** %6
%57 = call i32 @munmap(i8* %56, i32 4)
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %49
%60 = load i32*, i32** %1
%61 = call i32 @sem_wait(i32* %60)
%62 = bitcast i32* %7 to i8*
%63 = load i8*, i8** %6
%64 = bitcast i8* %63 to i32*
%65 = call i32 @memcpy(i8* %62, i32* %64, i32 4)
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
%68 = load i8*, i8** %6
%69 = call i32 @memcpy(i8* %68, i32* %7, i32 4)
%70 = load i32, i32* %7
%71 = icmp eq i32 %70, 1
br i1 %71, label %72, label %75
72: ; preds = %59
%73 = load i32*, i32** %2
%74 = call i32 @sem_wait(i32* %73)
br label %75
75: ; preds = %72, %59
%76 = load i32*, i32** %1
%77 = call i32 @sem_post(i32* %76)
%78 = bitcast i32* %8 to i8*
%79 = load i8*, i8** %4
%80 = bitcast i8* %79 to i32*
%81 = call i32 @memcpy(i8* %78, i32* %80, i32 4)
%82 = call i32 (...) @getpid()
%83 = load i32, i32* %8
%84 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %82, i32 %83)
%85 = load i32*, i32** %1
%86 = call i32 @sem_wait(i32* %85)
%87 = bitcast i32* %7 to i8*
%88 = load i8*, i8** %6
%89 = bitcast i8* %88 to i32*
%90 = call i32 @memcpy(i8* %87, i32* %89, i32 4)
%91 = load i32, i32* %7
%92 = add nsw i32 %91, -1
store i32 %92, i32* %7
%93 = load i8*, i8** %6
%94 = call i32 @memcpy(i8* %93, i32* %7, i32 4)
%95 = load i32, i32* %7
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %75
%98 = load i32*, i32** %2
%99 = call i32 @sem_post(i32* %98)
br label %100
100: ; preds = %97, %75
%101 = load i32*, i32** %1
%102 = call i32 @sem_post(i32* %101)
br label %49
}

LLVM IR (-O2):
@.str = [14 x i8] c"/read_bin_sem\00"
@O_RDWR = global i32 0
@SEM_FAILED = global i32* null
@.str.1 = [11 x i8] c"sem_open()\00"
@.str.2 = [12 x i8] c"/rw_bin_sem\00"
@.str.3 = [8 x i8] c"/buffer\00"
@.str.4 = [11 x i8] c"shm_open()\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.5 = [16 x i8] c"/reader_counter\00"
@.str.6 = [37 x i8] c"The reader (%lu) reads the value %d\0A\00"
define void @reader() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @O_RDWR
%4 = tail call i32* @sem_open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32*, i32** @SEM_FAILED
%6 = icmp eq i32* %4, %5
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* @O_RDWR
%11 = tail call i32* @sem_open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** @SEM_FAILED
%13 = icmp eq i32* %11, %12
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
%17 = load i32, i32* @O_RDWR
%18 = tail call i32 @shm_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 438)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @PROT_WRITE
%25 = or i32 %24, %23
%26 = load i32, i32* @MAP_SHARED
%27 = tail call i8* @mmap(i32* null, i32 4, i32 %25, i32 %26, i32 %18, i32 0)
%28 = load i32, i32* @O_RDWR
%29 = tail call i32 @shm_open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %28, i32 438)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %22
%32 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %22, %31
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @PROT_WRITE
%36 = or i32 %35, %34
%37 = load i32, i32* @MAP_SHARED
%38 = tail call i8* @mmap(i32* null, i32 4, i32 %36, i32 %37, i32 %29, i32 0)
%39 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%40 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%41 = call i32 @sleep(i32 1)
%42 = bitcast i8* %38 to i32*
%43 = bitcast i8* %27 to i32*
br label %48
44: ; preds = %73
%45 = call i32 @munmap(i8* %27, i32 4)
%46 = call i32 @munmap(i8* %38, i32 4)
%47 = call i32 @exit(i32 0)
unreachable
48: ; preds = %33, %73
%49 = call i32 @sem_wait(i32* %4)
%50 = call i32 @memcpy(i8* %39, i32* %42, i32 4)
%51 = load i32, i32* %1
%52 = add nsw i32 %51, 1
store i32 %52, i32* %1
%53 = call i32 @memcpy(i8* %38, i32* %1, i32 4)
%54 = load i32, i32* %1
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %58
56: ; preds = %48
%57 = call i32 @sem_wait(i32* %11)
br label %58
58: ; preds = %56, %48
%59 = call i32 @sem_post(i32* %4)
%60 = call i32 @memcpy(i8* %40, i32* %43, i32 4)
%61 = call i32 (...) @getpid()
%62 = load i32, i32* %2
%63 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %61, i32 %62)
%64 = call i32 @sem_wait(i32* %4)
%65 = call i32 @memcpy(i8* %39, i32* %42, i32 4)
%66 = load i32, i32* %1
%67 = add nsw i32 %66, -1
store i32 %67, i32* %1
%68 = call i32 @memcpy(i8* %38, i32* %1, i32 4)
%69 = load i32, i32* %1
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %58
%72 = call i32 @sem_post(i32* %11)
br label %73
73: ; preds = %71, %58
%74 = call i32 @sem_post(i32* %4)
%75 = call i32 @sleep(i32 1)
%76 = load i32, i32* %2
%77 = icmp eq i32 %76, 10
br i1 %77, label %44, label %48
}