#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int pthread_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   void *(*)(void *), void *);
int /*<<< orphan*/ pthread_join(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
main() {
  pthread_t hilos[3];
  int status, i, v[3];
  extern double contador;
  void *sumador(void *);
  for (i = 0; i < 3; i++) {
    v[i] = i;
    if (status = pthread_create(&hilos[i], NULL, sumador, (void *)&v[i]))
      exit(status);
  }
  for (i = 0; i < 3; i++)
    pthread_join(hilos[i], NULL);
  fprintf(stdout, "%f\n", contador);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11c0 <main+0x80>
mov    -0x18(%rbp),%ecx
movslq -0x18(%rbp),%rax
mov    %ecx,-0x24(%rbp,%rax,4)
movslq -0x18(%rbp),%rax
lea    -0x10(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
movslq -0x18(%rbp),%rax
lea    -0x24(%rbp),%rcx
shl    $0x2,%rax
add    %rax,%rcx
xor    %eax,%eax
mov    %eax,%esi
mov    0x2e4c(%rip),%rdx
call   1040 <pthread_create@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11ad <main+0x6d>
mov    -0x14(%rbp),%edi
call   1050 <exit@plt>
jmp    11b2 <main+0x72>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <main+0x16>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11f0 <main+0xb0>
movslq -0x18(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <pthread_join@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <main+0x87>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    0x2dd0(%rip),%rax
movsd  (%rax),%xmm0
lea    0xdf5(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x0,(%rsp)
mov    0x2e8e(%rip),%rdx
lea    0xc(%rsp),%rdi
mov    %rsp,%rcx
xor    %esi,%esi
call   1040 <pthread_create@plt>
test   %eax,%eax
jne    11f9 <main+0xb9>
lea    0x4(%rsp),%rcx
movl   $0x1,0x4(%rsp)
lea    0x10(%rsp),%rdi
mov    0x2e5e(%rip),%rdx
xor    %esi,%esi
call   1040 <pthread_create@plt>
test   %eax,%eax
jne    11f9 <main+0xb9>
lea    0x8(%rsp),%rcx
movl   $0x2,0x8(%rsp)
lea    0x14(%rsp),%rdi
mov    0x2e3a(%rip),%rdx
xor    %esi,%esi
call   1040 <pthread_create@plt>
test   %eax,%eax
jne    11f9 <main+0xb9>
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1060 <pthread_join@plt>
mov    0x10(%rsp),%edi
xor    %esi,%esi
call   1060 <pthread_join@plt>
mov    0x14(%rsp),%edi
xor    %esi,%esi
call   1060 <pthread_join@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    0x2dee(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe13(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    %eax,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [4 x i8] c"%f\0A\00"
@contador = external global double
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [3 x i32]
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %27, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %30
9: ; preds = %6
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 %12
store i32 %10, i32* %13
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 %18
%20 = bitcast i32* %19 to i8*
%21 = call i32 @pthread_create(i32* %16, i32* null, i8* (i8*)* @sumador, i8* %20)
store i32 %21, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %9
%24 = load i32, i32* %3
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %9
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %6
30: ; preds = %6
store i32 0, i32* %4
br label %31
31: ; preds = %40, %30
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 3
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 @pthread_join(i32 %38, i32* null)
br label %40
40: ; preds = %34
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %31
43: ; preds = %31
%44 = load i32, i32* @stdout
%45 = load double, double* @contador
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %45)
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [4 x i8] c"%f\0A\00"
@contador = external global double
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 0, i32* %5
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%7 = bitcast [3 x i32]* %2 to i8*
%8 = call i32 @pthread_create(i32* %6, i32* null, i8* (i8*)* @sumador, i8* %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %0
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32 1, i32* %11
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%13 = bitcast i32* %11 to i8*
%14 = call i32 @pthread_create(i32* %12, i32* null, i8* (i8*)* @sumador, i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %10
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 2, i32* %17
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%19 = bitcast i32* %17 to i8*
%20 = call i32 @pthread_create(i32* %18, i32* null, i8* (i8*)* @sumador, i8* %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = load i32, i32* %6
%24 = call i32 @pthread_join(i32 %23, i32* null)
%25 = load i32, i32* %12
%26 = call i32 @pthread_join(i32 %25, i32* null)
%27 = load i32, i32* %18
%28 = call i32 @pthread_join(i32 %27, i32* null)
%29 = load i32, i32* @stdout
%30 = load double, double* @contador
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %30)
ret i32 0
32: ; preds = %16, %10, %0
%33 = phi i32 [ %8, %0 ], [ %14, %10 ], [ %20, %16 ]
%34 = call i32 @exit(i32 %33)
unreachable
}