#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*/ G();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
void *ExecutaTarefa(void *threadid) {
  int i;
  int tid = (int)threadid;
  printf("Thread : %d esta executando...\n", (int)tid);
  for (i = 0; i < 10000000; i++) {
    G();
  }
  printf("Thread : %d terminou!\n", (int)tid);
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<ExecutaTarefa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x989680,-0x14(%rbp)
jge    117b <ExecutaTarefa+0x4b>
mov    $0x0,%al
call   1050 <G@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <ExecutaTarefa+0x29>
mov    -0x18(%rbp),%esi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExecutaTarefa>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0x989680,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <G@plt>
add    $0xffffffff,%ebp
jne    1150 <ExecutaTarefa+0x20>
lea    0xebd(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <pthread_exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Thread : %d esta executando...\0A\00"
@.str.1 = [23 x i8] c"Thread : %d terminou!\0A\00"
define i8* @ExecutaTarefa(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = ptrtoint i8* %6 to i32
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 0, i32* %4
br label %10
10: ; preds = %15, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 10000000
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = call i32 (...) @G()
br label %15
15: ; preds = %13
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %10
18: ; preds = %10
%19 = load i32, i32* %5
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 @pthread_exit(i32* null)
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@.str = [32 x i8] c"Thread : %d esta executando...\0A\00"
@.str.1 = [23 x i8] c"Thread : %d terminou!\0A\00"
define noalias i8* @ExecutaTarefa(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %5
5: ; preds = %1, %5
%6 = phi i32 [ 0, %1 ], [ %8, %5 ]
%7 = tail call i32 (...) @G()
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 10000000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%12 = tail call i32 @pthread_exit(i32* null)
ret i8* undef
}