#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*/ die(char *, int);
int pthread_join(int /*<<< orphan*/, int /*<<< orphan*/ *);
attendi_thread(pthread_t *th) {
  intptr_t i;
  int ret;
  for (i = 0; i < 100; i++)
    if (ret = pthread_join(th[i], NULL))
      die("errore join", ret);
}


x86 assembly (clang, -O0):
<attendi_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x64,-0x18(%rbp)
jge    1184 <attendi_thread+0x64>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <pthread_join@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     116e <attendi_thread+0x4e>
mov    -0x1c(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1030 <die@plt>
jmp    1173 <attendi_thread+0x53>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1134 <attendi_thread+0x14>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attendi_thread>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %ebx,%ebx
lea    0xecf(%rip),%r14
jmp    114a <attendi_thread+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x64,%rbx
je     1165 <attendi_thread+0x45>
mov    (%r15,%rbx,4),%edi
xor    %esi,%esi
call   1040 <pthread_join@plt>
test   %eax,%eax
je     1140 <attendi_thread+0x20>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <die@plt>
jmp    1140 <attendi_thread+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"errore join\00"
define i32 @attendi_thread(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
store i32* %0, i32** %3
store i64 0, i64* %4
br label %6
6: ; preds = %20, %1
%7 = load i64, i64* %4
%8 = icmp slt i64 %7, 100
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load i64, i64* %4
%12 = getelementptr inbounds i32, i32* %10, i64 %11
%13 = load i32, i32* %12
%14 = call i32 @pthread_join(i32 %13, i32* null)
store i32 %14, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %5
%18 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %9
br label %20
20: ; preds = %19
%21 = load i64, i64* %4
%22 = add nsw i64 %21, 1
store i64 %22, i64* %4
br label %6
23: ; preds = %6
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [12 x i8] c"errore join\00"
define i32 @attendi_thread(i32* nocapture %0) {
br label %2
2: ; preds = %1, %10
%3 = phi i64 [ 0, %1 ], [ %11, %10 ]
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
%6 = tail call i32 @pthread_join(i32 %5, i32* null)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %10
10: ; preds = %2, %8
%11 = add nuw nsw i64 %3, 1
%12 = icmp eq i64 %11, 100
br i1 %12, label %13, label %2
13: ; preds = %10
ret i32 undef
}