#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 /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char);
int semget(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ shmat(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ shmdt(char *);
int shmget(int, int /*<<< orphan*/, int /*<<< orphan*/);
void mainasasa() {
  int shmid;
  int semid = semget(0XA, 0, 0);
  shmid = shmget(0XA, 0, 0);
  char *c;
  char *aux;
  c = aux = (char *)shmat(shmid, 0, 0);
  while (*c <= 'z') {
    P(semid, 1);
    printf("%c\n", *c);
    V(semid, 0);
  }
  shmdt(aux);
}


x86 assembly (clang, -O0):
<mainasasa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xa,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <semget@plt>
mov    %eax,-0x8(%rbp)
mov    $0xa,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <shmget@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1080 <shmat@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     11ed <mainasasa+0x7d>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1040 <P@plt>
mov    -0x10(%rbp),%rax
lea    0xe2a(%rip),%rdi
movsbl (%rax),%esi
call   1070 <printf@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1050 <V@plt>
jmp    11ae <mainasasa+0x3e>
mov    -0x18(%rbp),%rdi
call   1060 <shmdt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mainasasa>:
push   %rbp
push   %r14
push   %rbx
mov    $0xa,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <semget@plt>
mov    %eax,%ebp
mov    $0xa,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <shmget@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <shmat@plt>
mov    %rax,%rbx
cmpb   $0x7a,(%rax)
jg     11d5 <mainasasa+0x65>
lea    0xe54(%rip),%r14
nopl   0x0(%rax)
mov    %ebp,%edi
mov    $0x1,%esi
call   1040 <P@plt>
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1070 <printf@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <V@plt>
cmpb   $0x7b,(%rbx)
jl     11b0 <mainasasa+0x40>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <shmdt@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%c\0A\00"
define void @mainasasa() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = call i32 @semget(i32 10, i32 0, i32 0)
store i32 %5, i32* %2
%6 = call i32 @shmget(i32 10, i32 0, i32 0)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i64 @shmat(i32 %7, i32 0, i32 0)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
store i8* %9, i8** %3
br label %10
10: ; preds = %15, %0
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp sle i32 %13, 122
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i32, i32* %2
%17 = call i32 @P(i32 %16, i32 1)
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %19)
%21 = load i32, i32* %2
%22 = call i32 @V(i32 %21, i32 0)
br label %10
23: ; preds = %10
%24 = load i8*, i8** %4
%25 = call i32 @shmdt(i8* %24)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%c\0A\00"
define void @mainasasa() {
%1 = tail call i32 @semget(i32 10, i32 0, i32 0)
%2 = tail call i32 @shmget(i32 10, i32 0, i32 0)
%3 = tail call i64 @shmat(i32 %2, i32 0, i32 0)
%4 = inttoptr i64 %3 to i8*
%5 = load i8, i8* %4
%6 = icmp slt i8 %5, 123
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = tail call i32 @P(i32 %1, i32 1)
%9 = load i8, i8* %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%11 = tail call i32 @V(i32 %1, i32 0)
%12 = load i8, i8* %4
%13 = icmp slt i8 %12, 123
br i1 %13, label %7, label %14
14: ; preds = %7, %0
%15 = tail call i32 @shmdt(i8* %4)
ret void
}