#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;
typedef scalar_t__ pid_t;

/* Variables and functions */
int atoi(char *);
scalar_t__ fork();
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
scalar_t__ getpid();
scalar_t__ getppid();
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int sem_init(int /*<<< orphan*/ *, int, int);
int sem_post(int /*<<< orphan*/ *);
int sem_wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int, long, long, long);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  sem_t *sem_lock;
  int shared = 1;
  int value = 1;
  pid_t pid = 0;
  int i, num = 0;
  char buf[200];
  char *c;
  printf("_POSIX_SEMAPHORES is not defined \n");
  return 2;
  if ((2 != argc) || ((num = atoi(argv[1])) <= 0)) {
    printf("Setting num_of_processes to default value: %d\n", 5);
    num = 5;
  }
  if ((sem_lock = malloc(sizeof(sem_t))) == NULL) {
    perror("malloc");
    return 2;
  }
  if (sem_init(sem_lock, shared, value) == -1) {
    perror("sem_init didn't return success\n");
    return 2;
  }
  for (i = 1; i < num; i++)
    switch ((pid = fork())) {
    case -1:
      perror("fork");
      return 2;
    case 0:
      break;
    default:
      sleep(2);
      break;
    }
  sprintf(buf,
          "%d process_ID: %ld parent_process_ID: %ld "
          "child_process_ID: %ld\n",
          i, (long)getpid(), (long)getppid(), (long)pid);
  if (sem_wait(sem_lock) == -1) {
    perror("sem_wait didn't return success\n");
    return 2;
  }
  for (i = 1; i <= 10; i++) {
    c = buf;
    while (*c != '\n') {
      fputc(*c, stdout);
      c++;
    }
    fputc('\n', stdout);
  }
  if (sem_post(sem_lock) == -1) {
    perror("sem_wait didn't return success\n");
    return 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x2,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"_POSIX_SEMAPHORES is not defined \0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca [200 x i8]
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 1, i32* %8
store i64 0, i64* %9
store i32 0, i32* %11
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
ret i32 2
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [34 x i8] c"_POSIX_SEMAPHORES is not defined \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
ret i32 2
}