#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 */
struct sembuf {
  int sem_num;
  int sem_op;
  scalar_t__ sem_flg;
};
typedef int key_t;

/* Variables and functions */
scalar_t__ EAGAIN;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ IPC_NOWAIT;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ftok(char *, int);
int /*<<< orphan*/ printf(char *);
int semget(int, int, int);
int semop(int, struct sembuf *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char **argv) {
  key_t key;
  int semid;
  struct sembuf w;
  if ((key = ftok("init.c", 5)) == -1) {
    fprintf(stderr, "Problem ftok : %s.\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((semid = semget(key, 5, 0600)) == 1) {
    fprintf(stderr,
            "Problem semget : %s.\n Peut être que la sémaphore n'as pas encore "
            "été créée?",
            strerror(errno));
    exit(EXIT_FAILURE);
  }
  do {
    w.sem_num = 1;
    w.sem_op = 0;
    w.sem_flg = 0;
    if (semop(semid, &w, 1) == -1) {
      fprintf(stderr,
              "Problem wait sem : %s.\n Avez vous enlevé la semaphore alors "
              "que le bus contenais quelques personnes?\n",
              strerror(errno));
      exit(EXIT_FAILURE);
    }
    w.sem_num = 0;
    w.sem_op = -1;
    w.sem_flg = IPC_NOWAIT;
    if ((semop(semid, &w, 1) == -1) && errno != EAGAIN) {
      fprintf(stderr, "Problem en rentrant dans le bus : %s.\n",
              strerror(errno));
      exit(EXIT_FAILURE);
    }
  } while (errno == EAGAIN);
  printf("j'ai réussi à rentrer dans le bus\n");
  w.sem_num = 3;
  w.sem_op = 0;
  w.sem_flg = 0;
  if (semop(semid, &w, 1) == -1) {
    fprintf(stderr, "Probleme en attendant que le bus parte : %s.\n",
            strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("Le bus est partis\n");
  w.sem_num = 2;
  w.sem_op = 0;
  w.sem_flg = 0;
  if (semop(semid, &w, 1) == -1) {
    fprintf(stderr, "Probleme en essayant de descendre du bus : %s.\n",
            strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("j'attends pour sortir du bus\n");
  w.sem_num = 0;
  w.sem_op = 1;
  w.sem_flg = 0;
  if (semop(semid, &w, 1) == -1) {
    fprintf(stderr, "Probleme en essayant de descendre du bus : %s.\n",
            strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("je suis sortis du bus\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x5,%esi
call   1080 <ftok@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11de <main+0x6e>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xe3c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
mov    $0x180,%edx
call   1030 <semget@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x1,%eax
jne    1237 <main+0xc7>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xdf7(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    123c <main+0xcc>
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    12a7 <main+0x137>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d51(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xdd9(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movl   $0x0,-0x28(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    0x2d34(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    1332 <main+0x1c2>
mov    0x2cec(%rip),%rax
mov    (%rax),%rax
mov    0x2cc2(%rip),%rcx
cmp    (%rcx),%rax
je     1332 <main+0x1c2>
mov    0x2cda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2cc6(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xdb5(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1337 <main+0x1c7>
mov    0x2c92(%rip),%rax
mov    (%rax),%rax
mov    0x2c68(%rip),%rcx
cmp    (%rcx),%rax
je     123c <main+0xcc>
lea    0xda3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x3,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    13c8 <main+0x258>
mov    0x2c44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2c30(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xd6b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xd7f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    143f <main+0x2cf>
mov    0x2bcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2bb9(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xd35(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2b90(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xd4b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    14b6 <main+0x346>
mov    0x2b56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2b42(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xcbe(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2b19(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xcf2(%rip),%rdi
call   1040 <printf@plt>
mov    0x2af7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe7b(%rip),%rdi
mov    $0x5,%esi
call   1080 <ftok@plt>
cmp    $0xffffffff,%eax
jne    11b8 <main+0x48>
mov    0x2e3d(%rip),%rax
mov    (%rax),%ebx
mov    0x2e2c(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
lea    0xe54(%rip),%rsi
jmp    138e <main+0x21e>
mov    %eax,%edi
mov    $0x5,%esi
mov    $0x180,%edx
call   1030 <semget@plt>
cmp    $0x1,%eax
jne    11f2 <main+0x82>
mov    0x2e03(%rip),%rax
mov    (%rax),%ebx
mov    0x2df2(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
lea    0xe2e(%rip),%rsi
jmp    138e <main+0x21e>
mov    %eax,%ebx
lea    0x8(%rsp),%r14
movabs $0xffffffff00000000,%r12
mov    0x2de6(%rip),%r13
mov    0x2dbf(%rip),%r15
mov    0x2d98(%rip),%rbp
jmp    1229 <main+0xb9>
nopw   0x0(%rax,%rax,1)
cmp    %rcx,%rdi
jne    12b7 <main+0x147>
movq   $0x1,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
je     129a <main+0x12a>
mov    %r12,0x8(%rsp)
mov    0x0(%r13),%rax
mov    %rax,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <semop@plt>
mov    (%r15),%rdi
mov    0x0(%rbp),%rcx
cmp    $0xffffffff,%eax
jne    1220 <main+0xb0>
cmp    %rcx,%rdi
mov    %rdi,%rcx
je     1220 <main+0xb0>
mov    0x2d51(%rip),%rax
mov    (%rax),%ebx
call   1090 <strerror@plt>
lea    0xe3f(%rip),%rsi
jmp    138e <main+0x21e>
mov    0x2d37(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rdi
call   1090 <strerror@plt>
lea    0xdbb(%rip),%rsi
jmp    138e <main+0x21e>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
movq   $0x3,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    1308 <main+0x198>
mov    0x2ce6(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rdi
call   1090 <strerror@plt>
lea    0xdf8(%rip),%rsi
jmp    138e <main+0x21e>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
movq   $0x2,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
je     1376 <main+0x206>
lea    0xe4c(%rip),%rdi
call   1040 <puts@plt>
movabs $0x100000000,%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1060 <semop@plt>
cmp    $0xffffffff,%eax
jne    13a6 <main+0x236>
mov    0x2c5b(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rdi
call   1090 <strerror@plt>
lea    0xd9b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xdff(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.sembuf = type { i32, i32, i64 }
@.str = [7 x i8] c"init.c\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Problem ftok : %s.\0A\00"
@errno = global i64 0
@EXIT_FAILURE = global i32 0
@.str.2 = [82 x i8] c"Problem semget : %s.\0A Peut \C3\AAtre que la s\C3\A9maphore n'as pas encore \C3\A9t\C3\A9 cr\C3\A9\C3\A9e?\00"
@.str.3 = [103 x i8] c"Problem wait sem : %s.\0A Avez vous enlev\C3\A9 la semaphore alors que le bus contenais quelques personnes?\0A\00"
@IPC_NOWAIT = global i64 0
@EAGAIN = global i64 0
@.str.4 = [39 x i8] c"Problem en rentrant dans le bus : %s.\0A\00"
@.str.5 = [37 x i8] c"j'ai r\C3\A9ussi \C3\A0 rentrer dans le bus\0A\00"
@.str.6 = [46 x i8] c"Probleme en attendant que le bus parte : %s.\0A\00"
@.str.7 = [19 x i8] c"Le bus est partis\0A\00"
@.str.8 = [48 x i8] c"Probleme en essayant de descendre du bus : %s.\0A\00"
@.str.9 = [30 x i8] c"j'attends pour sortir du bus\0A\00"
@.str.10 = [23 x i8] c"je suis sortis du bus\0A\00"
@EXIT_SUCCESS = 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 %struct.sembuf
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @ftok(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 5)
store i32 %9, i32* %6
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i64, i64* @errno
%14 = call i8* @strerror(i64 %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i32, i32* %6
%20 = call i32 @semget(i32 %19, i32 5, i32 384)
store i32 %20, i32* %7
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = load i64, i64* @errno
%25 = call i8* @strerror(i64 %24)
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %18
br label %30
30: ; preds = %64, %29
%31 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 0
store i32 1, i32* %31
%32 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 1
store i32 0, i32* %32
%33 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 2
store i64 0, i64* %33
%34 = load i32, i32* %7
%35 = call i32 @semop(i32 %34, %struct.sembuf* %8, i32 1)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %44
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = load i64, i64* @errno
%40 = call i8* @strerror(i64 %39)
%41 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %30
%45 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 0
store i32 0, i32* %45
%46 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 1
store i32 -1, i32* %46
%47 = load i64, i64* @IPC_NOWAIT
%48 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 2
store i64 %47, i64* %48
%49 = load i32, i32* %7
%50 = call i32 @semop(i32 %49, %struct.sembuf* %8, i32 1)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %63
52: ; preds = %44
%53 = load i64, i64* @errno
%54 = load i64, i64* @EAGAIN
%55 = icmp ne i64 %53, %54
br i1 %55, label %56, label %63
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = load i64, i64* @errno
%59 = call i8* @strerror(i64 %58)
%60 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %52, %44
br label %64
64: ; preds = %63
%65 = load i64, i64* @errno
%66 = load i64, i64* @EAGAIN
%67 = icmp eq i64 %65, %66
br i1 %67, label %30, label %68
68: ; preds = %64
%69 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%70 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 0
store i32 3, i32* %70
%71 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 1
store i32 0, i32* %71
%72 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 2
store i64 0, i64* %72
%73 = load i32, i32* %7
%74 = call i32 @semop(i32 %73, %struct.sembuf* %8, i32 1)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %83
76: ; preds = %68
%77 = load i32, i32* @stderr
%78 = load i64, i64* @errno
%79 = call i8* @strerror(i64 %78)
%80 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8* %79)
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %68
%84 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%85 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 0
store i32 2, i32* %85
%86 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 1
store i32 0, i32* %86
%87 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 2
store i64 0, i64* %87
%88 = load i32, i32* %7
%89 = call i32 @semop(i32 %88, %struct.sembuf* %8, i32 1)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %98
91: ; preds = %83
%92 = load i32, i32* @stderr
%93 = load i64, i64* @errno
%94 = call i8* @strerror(i64 %93)
%95 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %94)
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %83
%99 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%100 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 0
store i32 0, i32* %100
%101 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 1
store i32 1, i32* %101
%102 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 2
store i64 0, i64* %102
%103 = load i32, i32* %7
%104 = call i32 @semop(i32 %103, %struct.sembuf* %8, i32 1)
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %113
106: ; preds = %98
%107 = load i32, i32* @stderr
%108 = load i64, i64* @errno
%109 = call i8* @strerror(i64 %108)
%110 = call i32 @fprintf(i32 %107, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %109)
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %98
%114 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
%115 = load i32, i32* @EXIT_SUCCESS
%116 = call i32 @exit(i32 %115)
unreachable
}

LLVM IR (-O2):
%struct.sembuf = type { i32, i32, i64 }
@.str = [7 x i8] c"init.c\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Problem ftok : %s.\0A\00"
@errno = global i64 0
@EXIT_FAILURE = global i32 0
@.str.2 = [82 x i8] c"Problem semget : %s.\0A Peut \C3\AAtre que la s\C3\A9maphore n'as pas encore \C3\A9t\C3\A9 cr\C3\A9\C3\A9e?\00"
@.str.3 = [103 x i8] c"Problem wait sem : %s.\0A Avez vous enlev\C3\A9 la semaphore alors que le bus contenais quelques personnes?\0A\00"
@IPC_NOWAIT = global i64 0
@EAGAIN = global i64 0
@.str.4 = [39 x i8] c"Problem en rentrant dans le bus : %s.\0A\00"
@.str.6 = [46 x i8] c"Probleme en attendant que le bus parte : %s.\0A\00"
@.str.8 = [48 x i8] c"Probleme en essayant de descendre du bus : %s.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [36 x i8] c"j'ai r\C3\A9ussi \C3\A0 rentrer dans le bus\00"
@str.11 = [18 x i8] c"Le bus est partis\00"
@str.12 = [29 x i8] c"j'attends pour sortir du bus\00"
@str.13 = [22 x i8] c"je suis sortis du bus\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sembuf
%4 = bitcast %struct.sembuf* %3 to i8*
%5 = tail call i32 @ftok(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 5)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i64, i64* @errno
%10 = tail call i8* @strerror(i64 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = tail call i32 @semget(i32 %5, i32 5, i32 384)
%16 = icmp eq i32 %15, 1
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i64 0, i32 0
%19 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i64 0, i32 1
%20 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i64 0, i32 2
br label %28
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = load i64, i64* @errno
%24 = tail call i8* @strerror(i64 %23)
%25 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %17, %52
store i32 1, i32* %18
store i32 0, i32* %19
store i64 0, i64* %20
%29 = call i32 @semop(i32 %15, %struct.sembuf* %3, i32 1)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i64, i64* @errno
%34 = call i8* @strerror(i64 %33)
%35 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %28
store i32 0, i32* %18
store i32 -1, i32* %19
%39 = load i64, i64* @IPC_NOWAIT
store i64 %39, i64* %20
%40 = call i32 @semop(i32 %15, %struct.sembuf* %3, i32 1)
%41 = icmp eq i32 %40, -1
%42 = load i64, i64* @errno
%43 = load i64, i64* @EAGAIN
br i1 %41, label %44, label %52
44: ; preds = %38
%45 = icmp eq i64 %42, %43
br i1 %45, label %52, label %46
46: ; preds = %44
%47 = load i32, i32* @stderr
%48 = call i8* @strerror(i64 %42)
%49 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %38, %44
%53 = phi i64 [ %42, %44 ], [ %43, %38 ]
%54 = icmp eq i64 %42, %53
br i1 %54, label %28, label %55
55: ; preds = %52
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
store i32 3, i32* %18
store i32 0, i32* %19
store i64 0, i64* %20
%57 = call i32 @semop(i32 %15, %struct.sembuf* %3, i32 1)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %66
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = load i64, i64* @errno
%62 = call i8* @strerror(i64 %61)
%63 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %55
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
store i32 2, i32* %18
store i32 0, i32* %19
store i64 0, i64* %20
%68 = call i32 @semop(i32 %15, %struct.sembuf* %3, i32 1)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %77
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = load i64, i64* @errno
%73 = call i8* @strerror(i64 %72)
%74 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %73)
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %66
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
store i32 0, i32* %18
store i32 1, i32* %19
store i64 0, i64* %20
%79 = call i32 @semop(i32 %15, %struct.sembuf* %3, i32 1)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %88
81: ; preds = %77
%82 = load i32, i32* @stderr
%83 = load i64, i64* @errno
%84 = call i8* @strerror(i64 %83)
%85 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %77
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
%90 = load i32, i32* @EXIT_SUCCESS
%91 = call i32 @exit(i32 %90)
unreachable
}