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

/* Variables and functions */
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
void kill_processes(pid_t *process_ids, size_t n_processes) {
  int n_child;
  for (n_child = 0; n_child < n_processes; n_child++)
    if (process_ids[n_child] != -1)
      kill(process_ids[n_child], SIGTERM);
}


x86 assembly (clang, -O0):
<kill_processes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1173 <kill_processes+0x63>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     1160 <kill_processes+0x50>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
jmp    1165 <kill_processes+0x55>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <kill_processes+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kill_processes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     114d <kill_processes+0x3d>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2ebc(%rip),%r12
jmp    1139 <kill_processes+0x29>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r15
je     114d <kill_processes+0x3d>
mov    (%r14,%rbx,4),%edi
cmp    $0xffffffff,%edi
je     1130 <kill_processes+0x20>
mov    (%r12),%esi
call   1030 <kill@plt>
jmp    1130 <kill_processes+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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