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

/* Variables and functions */
int /*<<< orphan*/ P(int, int);
int /*<<< orphan*/ V(int, int);
int /*<<< orphan*/ ini_sem();
int /*<<< orphan*/ printf(char *);
int semget(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
void mainpa() {
  ini_sem();
  int semid = semget(0XA, 0, 0);
  while (1) {
    P(semid, 2);
    printf("A\n");
    sleep(1);
    V(semid, 0);
    P(semid, 3);
    printf("A\n");
    sleep(1);
    V(semid, 1);
  }
}


x86 assembly (clang, -O0):
<mainpa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <ini_sem@plt>
mov    $0xa,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <semget@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1040 <P@plt>
lea    0xe6c(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1050 <V@plt>
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1040 <P@plt>
lea    0xe3f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1050 <V@plt>
jmp    1180 <mainpa+0x20>

x86 assembly (clang, -O2):
<mainpa>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <ini_sem@plt>
mov    $0xa,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <semget@plt>
mov    %eax,%ebx
lea    0xe7e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <P@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <V@plt>
mov    %ebx,%edi
mov    $0x3,%esi
call   1050 <P@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1060 <V@plt>
jmp    1190 <mainpa+0x30>

LLVM IR (-O0):
@.str = [3 x i8] c"A\0A\00"
define void @mainpa() {
%1 = alloca i32
%2 = call i32 (...) @ini_sem()
%3 = call i32 @semget(i32 10, i32 0, i32 0)
store i32 %3, i32* %1
br label %4
4: ; preds = %0, %4
%5 = load i32, i32* %1
%6 = call i32 @P(i32 %5, i32 2)
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @sleep(i32 1)
%9 = load i32, i32* %1
%10 = call i32 @V(i32 %9, i32 0)
%11 = load i32, i32* %1
%12 = call i32 @P(i32 %11, i32 3)
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @sleep(i32 1)
%15 = load i32, i32* %1
%16 = call i32 @V(i32 %15, i32 1)
br label %4
}

LLVM IR (-O2):
@str.1 = [2 x i8] c"A\00"
define void @mainpa() {
%1 = tail call i32 (...) @ini_sem()
%2 = tail call i32 @semget(i32 10, i32 0, i32 0)
br label %3
3: ; preds = %3, %0
%4 = tail call i32 @P(i32 %2, i32 2)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.1, i64 0, i64 0))
%6 = tail call i32 @sleep(i32 1)
%7 = tail call i32 @V(i32 %2, i32 0)
%8 = tail call i32 @P(i32 %2, i32 3)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.1, i64 0, i64 0))
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @V(i32 %2, i32 1)
br label %3
}