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

/* Variables and functions */
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
void stop_all_readers(int cpus, int *pid_array) {
  int cpu;
  for (cpu = 0; cpu < cpus; cpu++) {
    if (pid_array[cpu] > 0)
      kill(pid_array[cpu], SIGUSR1);
  }
}


x86 assembly (clang, -O0):
<stop_all_readers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1170 <stop_all_readers+0x60>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    115d <stop_all_readers+0x4d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
jmp    1162 <stop_all_readers+0x52>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <stop_all_readers+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stop_all_readers>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    114c <stop_all_readers+0x3c>
mov    %rsi,%r14
mov    %edi,%r15d
xor    %ebx,%ebx
mov    0x2ebd(%rip),%r12
jmp    1139 <stop_all_readers+0x29>
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     114c <stop_all_readers+0x3c>
mov    (%r14,%rbx,4),%edi
test   %edi,%edi
jle    1130 <stop_all_readers+0x20>
mov    (%r12),%esi
call   1030 <kill@plt>
jmp    1130 <stop_all_readers+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@SIGUSR1 = global i32 0
define void @stop_all_readers(i32 %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %14
%7 = phi i64 [ 0, %4 ], [ %15, %14 ]
%8 = getelementptr inbounds i32, i32* %1, i64 %7
%9 = load i32, i32* %8
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* @SIGUSR1
%13 = tail call i32 @kill(i32 %9, i32 %12)
br label %14
14: ; preds = %6, %11
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %17, label %6
17: ; preds = %14, %2
ret void
}