#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*/ pthread_t;

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int pthread_kill(int /*<<< orphan*/, int /*<<< orphan*/);
int kill_work_threads(pthread_t *tids, const int count) {
  int result;
  pthread_t *ptid;
  pthread_t *ptid_end;
  ptid_end = tids + count;
  for (ptid = tids; ptid < ptid_end; ptid++) {
    if ((result = pthread_kill(*ptid, SIGINT)) != 0) {
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<kill_work_threads>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1183 <kill_work_threads+0x73>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
call   1030 <pthread_kill@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     116d <kill_work_threads+0x5d>
jmp    116d <kill_work_threads+0x5d>
jmp    1172 <kill_work_threads+0x62>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    113a <kill_work_threads+0x2a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kill_work_threads>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1143 <kill_work_threads+0x33>
mov    %rdi,%rbx
movslq %esi,%rax
lea    (%rdi,%rax,4),%r14
mov    0x2ebe(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%edi
mov    (%r15),%esi
call   1030 <pthread_kill@plt>
add    $0x4,%rbx
cmp    %r14,%rbx
jb     1130 <kill_work_threads+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIGINT = global i32 0
define i32 @kill_work_threads(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32*, i32** %3
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
store i32* %11, i32** %7
%12 = load i32*, i32** %3
store i32* %12, i32** %6
br label %13
13: ; preds = %25, %2
%14 = load i32*, i32** %6
%15 = load i32*, i32** %7
%16 = icmp ult i32* %14, %15
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
%20 = load i32, i32* @SIGINT
%21 = call i32 @pthread_kill(i32 %19, i32 %20)
store i32 %21, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
br label %24
24: ; preds = %23, %17
br label %25
25: ; preds = %24
%26 = load i32*, i32** %6
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %6
br label %13
28: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@SIGINT = global i32 0
define i32 @kill_work_threads(i32* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %13
6: ; preds = %2, %6
%7 = phi i32* [ %11, %6 ], [ %0, %2 ]
%8 = load i32, i32* %7
%9 = load i32, i32* @SIGINT
%10 = tail call i32 @pthread_kill(i32 %8, i32 %9)
%11 = getelementptr inbounds i32, i32* %7, i64 1
%12 = icmp ult i32* %11, %4
br i1 %12, label %6, label %13
13: ; preds = %6, %2
ret i32 0
}