#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 /*<<< orphan*/);
int /*<<< orphan*/ V(int, int);
int /*<<< orphan*/ maincr(int, int);
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 mainaa12() {
  maincr(1, 2);
  int shmid;
  int semid = semget(0XA, 0, 0);
  shmid = shmget(0XA, 0, 0);
  char *c;
  char l = 'a';
  char *aux;
  c = (char *)shmat(shmid, 0, 0);
  aux = c;
  while (l <= 'z' + 1) {
    P(semid, 0);
    *c = l;
    l++;
    V(semid, 1);
  }
  shmdt(aux);
}


x86 assembly (clang, -O0):
<mainaa12>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1,%edi
mov    $0x2,%esi
call   1060 <maincr@plt>
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)
movb   $0x61,-0x11(%rbp)
mov    -0x4(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1080 <shmat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x7b,%eax
jg     11ff <mainaa12+0x8f>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <P@plt>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <V@plt>
jmp    11c5 <mainaa12+0x55>
mov    -0x20(%rbp),%rdi
call   1070 <shmdt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mainaa12>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%edi
mov    $0x2,%esi
call   1060 <maincr@plt>
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,%r14
mov    $0x61,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <P@plt>
mov    %bl,(%r14)
add    $0x1,%bl
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <V@plt>
cmp    $0x7c,%bl
jne    11c0 <mainaa12+0x50>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <shmdt@plt>

LLVM IR (-O0):
define void @mainaa12() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
%6 = call i32 @maincr(i32 1, i32 2)
%7 = call i32 @semget(i32 10, i32 0, i32 0)
store i32 %7, i32* %2
%8 = call i32 @shmget(i32 10, i32 0, i32 0)
store i32 %8, i32* %1
store i8 97, i8* %4
%9 = load i32, i32* %1
%10 = call i64 @shmat(i32 %9, i32 0, i32 0)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = load i8*, i8** %3
store i8* %12, i8** %5
br label %13
13: ; preds = %17, %0
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp sle i32 %15, 123
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %2
%19 = call i32 @P(i32 %18, i32 0)
%20 = load i8, i8* %4
%21 = load i8*, i8** %3
store i8 %20, i8* %21
%22 = load i8, i8* %4
%23 = add i8 %22, 1
store i8 %23, i8* %4
%24 = load i32, i32* %2
%25 = call i32 @V(i32 %24, i32 1)
br label %13
26: ; preds = %13
%27 = load i8*, i8** %5
%28 = call i32 @shmdt(i8* %27)
ret void
}

LLVM IR (-O2):
define void @mainaa12() {
%1 = tail call i32 @maincr(i32 1, i32 2)
%2 = tail call i32 @semget(i32 10, i32 0, i32 0)
%3 = tail call i32 @shmget(i32 10, i32 0, i32 0)
%4 = tail call i64 @shmat(i32 %3, i32 0, i32 0)
%5 = inttoptr i64 %4 to i8*
br label %6
6: ; preds = %0, %6
%7 = phi i8 [ 97, %0 ], [ %9, %6 ]
%8 = tail call i32 @P(i32 %2, i32 0)
store i8 %7, i8* %5
%9 = add nuw nsw i8 %7, 1
%10 = tail call i32 @V(i32 %2, i32 1)
%11 = icmp eq i8 %9, 124
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = tail call i32 @shmdt(i8* %5)
ret void
}