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

/* Variables and functions */
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ pthread_kill(scalar_t__, int /*<<< orphan*/);
int unlink(char *);
void cleanup(int rvisualizer, int rcollector, pthread_t idCollector,
             int rworkers, pthread_t *idWorker, int nwork) {
  int j;
  if (rvisualizer) {
    kill(rvisualizer, SIGKILL);
  }
  j = unlink("./tmp/visual.sck");
  if (rcollector) {
    pthread_kill(idCollector, SIGKILL);
  }
  for (j = 0; j < nwork; j++) {
    if (idWorker[j] > 0) {
      pthread_kill(idWorker[j], SIGKILL);
    }
  }
}


x86 assembly (clang, -O0):
<cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1168 <cleanup+0x38>
mov    -0x4(%rbp),%edi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
lea    0xe91(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1193 <cleanup+0x63>
mov    -0x10(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1040 <pthread_kill@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e6 <cleanup+0xb6>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jle    11d3 <cleanup+0xa3>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
call   1040 <pthread_kill@plt>
jmp    11d8 <cleanup+0xa8>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119a <cleanup+0x6a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanup>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r15d
mov    %r8,%r12
mov    %rdx,%r14
mov    %esi,%ebp
test   %edi,%edi
je     1155 <cleanup+0x25>
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
lea    0xea4(%rip),%rdi
call   1030 <unlink@plt>
test   %ebp,%ebp
je     1176 <cleanup+0x46>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1040 <pthread_kill@plt>
test   %r15d,%r15d
jle    11ac <cleanup+0x7c>
mov    %r15d,%ebp
xor    %ebx,%ebx
mov    0x2e59(%rip),%r14
jmp    1199 <cleanup+0x69>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11ac <cleanup+0x7c>
mov    (%r12,%rbx,8),%rdi
test   %rdi,%rdi
jle    1190 <cleanup+0x60>
mov    (%r14),%esi
call   1040 <pthread_kill@plt>
jmp    1190 <cleanup+0x60>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SIGKILL = global i32 0
@.str = [17 x i8] c"./tmp/visual.sck\00"
define void @cleanup(i32 %0, i32 %1, i64 %2, i32 %3, i64* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i64 %2, i64* %9
store i32 %3, i32* %10
store i64* %4, i64** %11
store i32 %5, i32* %12
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %6
%17 = load i32, i32* %7
%18 = load i32, i32* @SIGKILL
%19 = call i32 @kill(i32 %17, i32 %18)
br label %20
20: ; preds = %16, %6
%21 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %13
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i64, i64* %9
%26 = load i32, i32* @SIGKILL
%27 = call i32 @pthread_kill(i64 %25, i32 %26)
br label %28
28: ; preds = %24, %20
store i32 0, i32* %13
br label %29
29: ; preds = %49, %28
%30 = load i32, i32* %13
%31 = load i32, i32* %12
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %52
33: ; preds = %29
%34 = load i64*, i64** %11
%35 = load i32, i32* %13
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i64, i64* %34, i64 %36
%38 = load i64, i64* %37
%39 = icmp sgt i64 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %33
%41 = load i64*, i64** %11
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i64, i64* %41, i64 %43
%45 = load i64, i64* %44
%46 = load i32, i32* @SIGKILL
%47 = call i32 @pthread_kill(i64 %45, i32 %46)
br label %48
48: ; preds = %40, %33
br label %49
49: ; preds = %48
%50 = load i32, i32* %13
%51 = add nsw i32 %50, 1
store i32 %51, i32* %13
br label %29
52: ; preds = %29
ret void
}

LLVM IR (-O2):
@SIGKILL = global i32 0
@.str = [17 x i8] c"./tmp/visual.sck\00"
define void @cleanup(i32 %0, i32 %1, i64 %2, i32 %3, i64* nocapture %4, i32 %5) {
%7 = icmp eq i32 %0, 0
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = load i32, i32* @SIGKILL
%10 = tail call i32 @kill(i32 %0, i32 %9)
br label %11
11: ; preds = %8, %6
%12 = tail call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %1, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @SIGKILL
%16 = tail call i32 @pthread_kill(i64 %2, i32 %15)
br label %17
17: ; preds = %14, %11
%18 = icmp sgt i32 %5, 0
br i1 %18, label %19, label %32
19: ; preds = %17
%20 = zext i32 %5 to i64
br label %21
21: ; preds = %19, %29
%22 = phi i64 [ 0, %19 ], [ %30, %29 ]
%23 = getelementptr inbounds i64, i64* %4, i64 %22
%24 = load i64, i64* %23
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* @SIGKILL
%28 = tail call i32 @pthread_kill(i64 %24, i32 %27)
br label %29
29: ; preds = %21, %26
%30 = add nuw nsw i64 %22, 1
%31 = icmp eq i64 %30, %20
br i1 %31, label %32, label %21
32: ; preds = %29, %17
ret void
}