#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*/ free(unsigned long *);
int /*<<< orphan*/ printf(char *, unsigned long, ...);
void *helloGoodbye(void *buf) {
  unsigned long *argBuf = (unsigned long *)buf;
  unsigned long id = argBuf[0];
  unsigned long numThreads = argBuf[1];
  printf("Hello from thread #%lu of %lu.\n", id, numThreads);
  printf("Goodbye from thread #%lu\n", id);
  free(argBuf);
  return NULL;
}


x86 assembly (clang, -O0):
<helloGoodbye>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<helloGoodbye>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%r14
mov    0x8(%rdi),%rdx
lea    0xecb(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Hello from thread #%lu of %lu.\0A\00"
@.str.1 = [26 x i8] c"Goodbye from thread #%lu\0A\00"
define i8* @helloGoodbye(i8* %0) {
%2 = alloca i8*
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i64*
store i64* %7, i64** %3
%8 = load i64*, i64** %3
%9 = getelementptr inbounds i64, i64* %8, i64 0
%10 = load i64, i64* %9
store i64 %10, i64* %4
%11 = load i64*, i64** %3
%12 = getelementptr inbounds i64, i64* %11, i64 1
%13 = load i64, i64* %12
store i64 %13, i64* %5
%14 = load i64, i64* %4
%15 = load i64, i64* %5
%16 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %15)
%17 = load i64, i64* %4
%18 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%19 = load i64*, i64** %3
%20 = call i32 @free(i64* %19)
ret i8* null
}

LLVM IR (-O2):
@.str = [32 x i8] c"Hello from thread #%lu of %lu.\0A\00"
@.str.1 = [26 x i8] c"Goodbye from thread #%lu\0A\00"
define noalias i8* @helloGoodbye(i8* nocapture %0) {
%2 = bitcast i8* %0 to i64*
%3 = load i64, i64* %2
%4 = getelementptr inbounds i8, i8* %0, i64 8
%5 = bitcast i8* %4 to i64*
%6 = load i64, i64* %5
%7 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %3, i64 %6)
%8 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%9 = tail call i32 @free(i64* %2)
ret i8* null
}