#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*/ printf(char *, void *, ...);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
double sin(int);
double tan(int);
void *PrintHello(void *threadid) {
  int i;
  double myresult = 0.0;
  printf("thread=%ld: starting...\n", threadid);
  for (i = 0; i < 1000000; i++)
    myresult += sin(i) * tan(i);
  printf("thread=%ld result=%e. Done.\n", threadid, myresult);
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<PrintHello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jge    11b7 <PrintHello+0x77>
mov    -0x14(%rbp),%edi
call   1040 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <tan@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <PrintHello+0x2d>
mov    -0x10(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
lea    0xe52(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintHello>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xeb0(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
call   1060 <tan@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%ebp
cmp    $0xf4240,%ebp
jne    1160 <PrintHello+0x20>
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %edi,%edi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <pthread_exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"thread=%ld: starting...\0A\00"
@.str.1 = [29 x i8] c"thread=%ld result=%e. Done.\0A\00"
define i8* @PrintHello(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
store i8* %0, i8** %3
store double 0.000000e+00, double* %5
%6 = load i8*, i8** %3
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %6)
store i32 0, i32* %4
br label %8
8: ; preds = %18, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1000000
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %4
%13 = call double @sin(i32 %12)
%14 = load i32, i32* %4
%15 = call double @tan(i32 %14)
%16 = load double, double* %5
%17 = call double @llvm.fmuladd.f64(double %13, double %15, double %16)
store double %17, double* %5
br label %18
18: ; preds = %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %8
21: ; preds = %8
%22 = load i8*, i8** %3
%23 = load double, double* %5
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %22, double %23)
%25 = call i32 @pthread_exit(i32* null)
%26 = load i8*, i8** %2
ret i8* %26
}

LLVM IR (-O2):
@.str = [25 x i8] c"thread=%ld: starting...\0A\00"
@.str.1 = [29 x i8] c"thread=%ld result=%e. Done.\0A\00"
define noalias i8* @PrintHello(i8* %0) {
%2 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %3
3: ; preds = %1, %3
%4 = phi double [ 0.000000e+00, %1 ], [ %8, %3 ]
%5 = phi i32 [ 0, %1 ], [ %9, %3 ]
%6 = tail call double @sin(i32 %5)
%7 = tail call double @tan(i32 %5)
%8 = tail call double @llvm.fmuladd.f64(double %6, double %7, double %4)
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 1000000
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0, double %8)
%13 = tail call i32 @pthread_exit(i32* null)
ret i8* undef
}