#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;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ destroyFIFO(char *);
int /*<<< orphan*/ exit(int);
int getpid();
int /*<<< orphan*/ logLine(char *, int, int, char *, char *);
scalar_t__ mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char **, int);
int /*<<< orphan*/ *sem_open(char *, int /*<<< orphan*/, int,
                             int /*<<< orphan*/);
int /*<<< orphan*/ sem_post(int /*<<< orphan*/ *);
int /*<<< orphan*/ sem_wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strcspn(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
int /*<<< orphan*/ write(int, char *, scalar_t__);
int main(int argc, char *argv[]) {
  if (argc != 4) {
    printf("Usage: %s <counter_fifo> <counter_index> <shm>\n", argv[0]);
    exit(1);
  }
  char *COUNTER_FIFO_NAME = argv[1];
  int COUNTER_INDEX = atoi(argv[2]);
  char SHM_NAME[80];
  strcpy(SHM_NAME, argv[3]);
  char pid_s[80];
  sprintf(pid_s, "%d", getpid());
  char CLIENT_FIFO_NAME[256] = "/tmp/fc_";
  strcat(CLIENT_FIFO_NAME, pid_s);
  if (mkfifo(CLIENT_FIFO_NAME, 0660) < 0)
    printf("\t#ERROR# Can't create client FIFO\n");
  else {
    printf("+ Created cliente: %s\n", CLIENT_FIFO_NAME);
  }
  char COUNTER_SEM_NAME[80] = "/";
  int helper = strcspn(COUNTER_FIFO_NAME, "_");
  strncat(COUNTER_SEM_NAME, COUNTER_FIFO_NAME + helper + 1,
          strlen(COUNTER_FIFO_NAME));
  sem_t *counter_sem = sem_open(COUNTER_SEM_NAME, 0, 0600, 0);
  int counter_fifo_fd;
  counter_fifo_fd = open(COUNTER_FIFO_NAME, O_WRONLY);
  if (counter_fifo_fd < 0) {
    printf("\t#ERROR# Couldn't open counter FIFO '%s'\n", COUNTER_FIFO_NAME);
    destroyFIFO(CLIENT_FIFO_NAME);
    exit(1);
  }
  sem_wait(counter_sem);
  logLine(SHM_NAME, 1, COUNTER_INDEX, "pede_atendimento", CLIENT_FIFO_NAME);
  write(counter_fifo_fd, CLIENT_FIFO_NAME, strlen(CLIENT_FIFO_NAME) + 1);
  close(counter_fifo_fd);
  int client_fifo_fd;
  client_fifo_fd = open(CLIENT_FIFO_NAME, O_RDONLY);
  if (client_fifo_fd < 0) {
    printf("\t#ERROR# Couldn't open client FIFO '%s'\n", CLIENT_FIFO_NAME);
    destroyFIFO(CLIENT_FIFO_NAME);
    exit(1);
  }
  sem_post(counter_sem);
  char fim_atendimento[256];
  read(client_fifo_fd, &fim_atendimento, 256 * sizeof(char));
  if (strcmp("fim_atendimento", fim_atendimento) == 0) {
    printf("- Client served: %s (Message: %s)\n", CLIENT_FIFO_NAME,
           fim_atendimento);
    logLine(SHM_NAME, 1, COUNTER_INDEX, "fim_atendimento", CLIENT_FIFO_NAME);
  } else {
    printf("#ERROR# Client '%s' didn't finish being served\n",
           CLIENT_FIFO_NAME);
  }
  close(client_fifo_fd);
  destroyFIFO(CLIENT_FIFO_NAME);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     12b2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xc0(%rbp),%rax
mov    %rax,-0x338(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x338(%rbp),%rdi
mov    %eax,%edx
lea    0xd2c(%rip),%rsi
call   1170 <sprintf@plt>
lea    -0x1c0(%rbp),%rdi
lea    0xe29(%rip),%rsi
mov    $0x100,%edx
call   1120 <memcpy@plt>
lea    -0x1c0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1160 <strcat@plt>
lea    -0x1c0(%rbp),%rdi
mov    $0x1b0,%esi
call   1110 <mkfifo@plt>
cmp    $0x0,%rax
jge    1362 <main+0xf2>
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1377 <main+0x107>
lea    -0x1c0(%rbp),%rsi
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1090 <memset@plt>
movb   $0x2f,-0x210(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xcd1(%rip),%rsi
call   10d0 <strcspn@plt>
mov    %eax,-0x214(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x348(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x214(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x340(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x348(%rbp),%rdi
mov    -0x340(%rbp),%rsi
mov    %rax,%rdx
call   10a0 <strncat@plt>
lea    -0x210(%rbp),%rdi
xor    %ecx,%ecx
mov    $0x180,%edx
mov    %ecx,%esi
call   1100 <sem_open@plt>
mov    %rax,-0x220(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2bbc(%rip),%rax
mov    (%rax),%esi
call   1140 <open@plt>
mov    %eax,-0x224(%rbp)
cmpl   $0x0,-0x224(%rbp)
jge    1456 <main+0x1e6>
mov    -0x18(%rbp),%rsi
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x1c0(%rbp),%rdi
call   1190 <destroyFIFO@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0x220(%rbp),%rdi
call   1040 <sem_wait@plt>
lea    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x1c0(%rbp),%r8
mov    $0x1,%esi
lea    0xc1d(%rip),%rcx
call   1130 <logLine@plt>
mov    -0x224(%rbp),%eax
mov    %eax,-0x354(%rbp)
lea    -0x1c0(%rbp),%rax
mov    %rax,-0x350(%rbp)
lea    -0x1c0(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x354(%rbp),%edi
mov    -0x350(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1050 <write@plt>
mov    -0x224(%rbp),%edi
call   10b0 <close@plt>
lea    -0x1c0(%rbp),%rdi
mov    0x2b0f(%rip),%rax
mov    (%rax),%esi
call   1140 <open@plt>
mov    %eax,-0x228(%rbp)
cmpl   $0x0,-0x228(%rbp)
jge    151e <main+0x2ae>
lea    -0x1c0(%rbp),%rsi
lea    0xba9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x1c0(%rbp),%rdi
call   1190 <destroyFIFO@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0x220(%rbp),%rdi
call   10c0 <sem_post@plt>
mov    -0x228(%rbp),%edi
lea    -0x330(%rbp),%rsi
mov    $0x100,%edx
call   10e0 <read@plt>
lea    -0x330(%rbp),%rsi
lea    0xb84(%rip),%rdi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    159e <main+0x32e>
lea    -0x1c0(%rbp),%rsi
lea    -0x330(%rbp),%rdx
lea    0xb70(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x1c0(%rbp),%r8
mov    $0x1,%esi
lea    0xb3f(%rip),%rcx
call   1130 <logLine@plt>
jmp    15b3 <main+0x343>
lea    -0x1c0(%rbp),%rsi
lea    0xb5a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x228(%rbp),%edi
call   10b0 <close@plt>
lea    -0x1c0(%rbp),%rdi
call   1190 <destroyFIFO@plt>
xor    %edi,%edi
call   1180 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2f0,%rsp
mov    %rsi,%rbp
cmp    $0x4,%edi
jne    1310 <main+0xa0>
mov    0x8(%rbp),%r12
mov    0x10(%rbp),%rdi
call   1150 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbp),%rsi
lea    0x50(%rsp),%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xd79(%rip),%rsi
lea    0x1a0(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
call   1170 <sprintf@plt>
lea    0xe70(%rip),%rsi
lea    0xa0(%rsp),%rbp
mov    $0x100,%edx
mov    %rbp,%rdi
call   1120 <memcpy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1160 <strcat@plt>
mov    %rbp,%rdi
mov    $0x1b0,%esi
call   1110 <mkfifo@plt>
test   %rax,%rax
jns    132c <main+0xbc>
lea    0xe0a(%rip),%rdi
call   1050 <puts@plt>
jmp    1342 <main+0xd2>
mov    0x0(%rbp),%rsi
lea    0xce5(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
lea    0xd00(%rip),%rdi
lea    0xa0(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movb   $0x2f,(%rsp)
lea    0xce2(%rip),%rsi
mov    %r12,%rdi
call   10d0 <strcspn@plt>
cltq
lea    (%r12,%rax,1),%rbp
add    $0x1,%rbp
mov    %r12,%rdi
call   1080 <strlen@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   10a0 <strncat@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x180,%edx
xor    %ecx,%ecx
call   1100 <sem_open@plt>
mov    %rax,%r15
mov    0x2c22(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   1140 <open@plt>
test   %eax,%eax
jns    13d7 <main+0x167>
lea    0xc89(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xa0(%rsp),%rdi
jmp    1453 <main+0x1e3>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <sem_wait@plt>
lea    0xc8e(%rip),%rcx
lea    0x50(%rsp),%rdi
lea    0xa0(%rsp),%rbx
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbx,%r8
call   1130 <logLine@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <write@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    0x2bbf(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1140 <open@plt>
test   %eax,%eax
jns    1462 <main+0x1f2>
lea    0xc49(%rip),%rdi
lea    0xa0(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1190 <destroyFIFO@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   10c0 <sem_post@plt>
lea    0x1f0(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   10e0 <read@plt>
lea    0xc26(%rip),%rdi
mov    %rbp,%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    14d6 <main+0x266>
lea    0xc22(%rip),%rdi
lea    0xa0(%rsp),%rbp
lea    0x1f0(%rsp),%rdx
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xbf1(%rip),%rcx
lea    0x50(%rsp),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbp,%r8
call   1130 <logLine@plt>
jmp    14ec <main+0x27c>
lea    0xc06(%rip),%rdi
lea    0xa0(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
lea    0xa0(%rsp),%rdi
call   1190 <destroyFIFO@plt>
xor    %edi,%edi
call   1180 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Usage: %s <counter_fifo> <counter_index> <shm>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@__const.main.CLIENT_FIFO_NAME = [256 x i8] c"/tmp/fc_\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [35 x i8] c"\09#ERROR# Can't create client FIFO\0A\00"
@.str.3 = [23 x i8] c"+ Created cliente: %s\0A\00"
@.str.4 = [2 x i8] c"_\00"
@O_WRONLY = global i32 0
@.str.5 = [42 x i8] c"\09#ERROR# Couldn't open counter FIFO '%s'\0A\00"
@.str.6 = [17 x i8] c"pede_atendimento\00"
@O_RDONLY = global i32 0
@.str.7 = [41 x i8] c"\09#ERROR# Couldn't open client FIFO '%s'\0A\00"
@.str.8 = [16 x i8] c"fim_atendimento\00"
@.str.9 = [35 x i8] c"- Client served: %s (Message: %s)\0A\00"
@.str.10 = [48 x i8] c"#ERROR# Client '%s' didn't finish being served\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca [256 x i8]
%11 = alloca [80 x i8]
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 4
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %6
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %7
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32 @strcpy(i8* %33, i8* %36)
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%39 = call i32 (...) @getpid()
%40 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = bitcast [256 x i8]* %10 to i8*
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%44 = call i32 @strcat(i8* %42, i8* %43)
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%46 = call i64 @mkfifo(i8* %45, i32 432)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %25
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %53
50: ; preds = %25
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %48
%54 = bitcast [80 x i8]* %11 to i8*
%55 = bitcast i8* %54 to [80 x i8]*
%56 = getelementptr inbounds [80 x i8], [80 x i8]* %55, i32 0, i32 0
store i8 47, i8* %56
%57 = load i8*, i8** %6
%58 = call i32 @strcspn(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 %58, i32* %12
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%60 = load i8*, i8** %6
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8*, i8** %6
%66 = call i64 @strlen(i8* %65)
%67 = call i32 @strncat(i8* %59, i8* %64, i64 %66)
%68 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%69 = call i32* @sem_open(i8* %68, i32 0, i32 384, i32 0)
store i32* %69, i32** %13
%70 = load i8*, i8** %6
%71 = load i32, i32* @O_WRONLY
%72 = call i32 @open(i8* %70, i32 %71)
store i32 %72, i32* %14
%73 = load i32, i32* %14
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %53
%76 = load i8*, i8** %6
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %76)
%78 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%79 = call i32 @destroyFIFO(i8* %78)
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %53
%82 = load i32*, i32** %13
%83 = call i32 @sem_wait(i32* %82)
%84 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%85 = load i32, i32* %7
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%87 = call i32 @logLine(i8* %84, i32 1, i32 %85, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %86)
%88 = load i32, i32* %14
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%91 = call i64 @strlen(i8* %90)
%92 = add nsw i64 %91, 1
%93 = call i32 @write(i32 %88, i8* %89, i64 %92)
%94 = load i32, i32* %14
%95 = call i32 @close(i32 %94)
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%97 = load i32, i32* @O_RDONLY
%98 = call i32 @open(i8* %96, i32 %97)
store i32 %98, i32* %15
%99 = load i32, i32* %15
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %81
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %102)
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%105 = call i32 @destroyFIFO(i8* %104)
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %81
%108 = load i32*, i32** %13
%109 = call i32 @sem_post(i32* %108)
%110 = load i32, i32* %15
%111 = bitcast [256 x i8]* %16 to i8**
%112 = call i32 @read(i32 %110, i8** %111, i32 256)
%113 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%114 = call i64 @strcmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %113)
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %124
116: ; preds = %107
%117 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%118 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i8* %117, i8* %118)
%120 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%121 = load i32, i32* %7
%122 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%123 = call i32 @logLine(i8* %120, i32 1, i32 %121, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %122)
br label %127
124: ; preds = %107
%125 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i8* %125)
br label %127
127: ; preds = %124, %116
%128 = load i32, i32* %15
%129 = call i32 @close(i32 %128)
%130 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%131 = call i32 @destroyFIFO(i8* %130)
%132 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage: %s <counter_fifo> <counter_index> <shm>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@__const.main.CLIENT_FIFO_NAME = [256 x i8] c"/tmp/fc_\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.3 = [23 x i8] c"+ Created cliente: %s\0A\00"
@.str.4 = [2 x i8] c"_\00"
@O_WRONLY = global i32 0
@.str.5 = [42 x i8] c"\09#ERROR# Couldn't open counter FIFO '%s'\0A\00"
@.str.6 = [17 x i8] c"pede_atendimento\00"
@O_RDONLY = global i32 0
@.str.7 = [41 x i8] c"\09#ERROR# Couldn't open client FIFO '%s'\0A\00"
@.str.8 = [16 x i8] c"fim_atendimento\00"
@.str.9 = [35 x i8] c"- Client served: %s (Message: %s)\0A\00"
@.str.10 = [48 x i8] c"#ERROR# Client '%s' didn't finish being served\0A\00"
@str = [34 x i8] c"\09#ERROR# Can't create client FIFO\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca [256 x i8]
%6 = alloca [80 x i8]
%7 = alloca [256 x i8]
%8 = icmp eq i32 %0, 4
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %19, i8* %21)
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%24 = call i32 (...) @getpid()
%25 = call i32 @sprintf(i8* %23, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%27 = call i32 @strcat(i8* %26, i8* %23)
%28 = call i64 @mkfifo(i8* %26, i32 432)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %13
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %34
32: ; preds = %13
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %34
34: ; preds = %32, %30
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
store i8 47, i8* %35
%36 = call i32 @strcspn(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %15, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i64 @strlen(i8* dereferenceable(1) %15)
%41 = call i32 @strncat(i8* %35, i8* %39, i64 %40)
%42 = call i32* @sem_open(i8* %35, i32 0, i32 384, i32 0)
%43 = load i32, i32* @O_WRONLY
%44 = call i32 @open(i8* %15, i32 %43)
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %34
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%48 = call i32 @destroyFIFO(i8* %26)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %34
%51 = call i32 @sem_wait(i32* %42)
%52 = call i32 @logLine(i8* %19, i32 1, i32 %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %26)
%53 = call i64 @strlen(i8* %26)
%54 = add nsw i64 %53, 1
%55 = call i32 @write(i32 %44, i8* %26, i64 %54)
%56 = call i32 @close(i32 %44)
%57 = load i32, i32* @O_RDONLY
%58 = call i32 @open(i8* %26, i32 %57)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %50
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %26)
%62 = call i32 @destroyFIFO(i8* %26)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %50
%65 = call i32 @sem_post(i32* %42)
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%67 = bitcast [256 x i8]* %7 to i8**
%68 = call i32 @read(i32 %58, i8** %67, i32 256)
%69 = call i64 @strcmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %66)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %64
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i8* %26, i8* %66)
%73 = call i32 @logLine(i8* %19, i32 1, i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %26)
br label %76
74: ; preds = %64
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i8* %26)
br label %76
76: ; preds = %74, %71
%77 = call i32 @close(i32 %58)
%78 = call i32 @destroyFIFO(i8* %26)
%79 = call i32 @exit(i32 0)
unreachable
}