#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ pthread_cancel(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void cancelaHilos(pthread_t *hilos, int maxHilos) {
  int i;
  for (i = 0; i < maxHilos; i++) {
    if (hilos[i] != 0) {
      fprintf(stderr, "cancelando hilo #%d... ", i);
      fflush(stdout);
      pthread_cancel(hilos[i]);
      fprintf(stderr, "OK\n");
    }
  }
}


x86 assembly (clang, -O0):
<cancelaHilos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <cancelaHilos+0x98>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11b5 <cancelaHilos+0x85>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <pthread_cancel@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ba <cancelaHilos+0x8a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <cancelaHilos+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cancelaHilos>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11a3 <cancelaHilos+0x73>
mov    %rdi,%r12
mov    %esi,%r13d
mov    0x2e94(%rip),%rbp
mov    0x2e85(%rip),%r14
lea    0xebe(%rip),%r15
xor    %ebx,%ebx
jmp    1169 <cancelaHilos+0x39>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     11a3 <cancelaHilos+0x73>
cmpq   $0x0,(%r12,%rbx,8)
je     1160 <cancelaHilos+0x30>
mov    0x0(%rbp),%edi
lea    0xe86(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    (%r12,%rbx,8),%rdi
call   1050 <pthread_cancel@plt>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1160 <cancelaHilos+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"cancelando hilo #%d... \00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"OK\0A\00"
define void @cancelaHilos(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i32
store i64* %0, i64** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %32, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %35
10: ; preds = %6
%11 = load i64*, i64** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i64, i64* %11, i64 %13
%15 = load i64, i64* %14
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = load i32, i32* %5
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @stdout
%22 = call i32 @fflush(i32 %21)
%23 = load i64*, i64** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i64, i64* %23, i64 %25
%27 = load i64, i64* %26
%28 = call i32 @pthread_cancel(i64 %27)
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %17, %10
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %6
35: ; preds = %6
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"cancelando hilo #%d... \00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"OK\0A\00"
define void @cancelaHilos(i64* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %21
%7 = phi i64 [ 0, %4 ], [ %22, %21 ]
%8 = getelementptr inbounds i64, i64* %0, i64 %7
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = trunc i64 %7 to i32
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @stdout
%16 = tail call i32 @fflush(i32 %15)
%17 = load i64, i64* %8
%18 = tail call i32 @pthread_cancel(i64 %17)
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %6, %11
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %24, label %6
24: ; preds = %21, %2
ret void
}