#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*/ __NR_gettid;
scalar_t__ getpid();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ pthread_self();
int /*<<< orphan*/ syscall(int /*<<< orphan*/);
void *start_thread(void *arg) {
  do {
    printf("%s:%d -- ",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
           "linux/pthread/gettid.c",
           34);
    printf("pid : [%d], tid = [%ld], threadid = [%u]\n", (int)getpid(),
           syscall(__NR_gettid), (unsigned int)pthread_self());
    printf("\n");
  } while (0);
  return NULL;
}


x86 assembly (clang, -O0):
<start_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x22,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1050 <syscall@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <pthread_self@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %eax,%ecx
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_thread>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
lea    0xea9(%rip),%rsi
mov    $0x22,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1060 <syscall@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <pthread_self@plt>
lea    0xf0d(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s:%d -- \00"
@.str.1 = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/linux/pthread/gettid.c\00"
@.str.2 = [42 x i8] c"pid : [%d], tid = [%ld], threadid = [%u]\0A\00"
@__NR_gettid = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define i8* @start_thread(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0), i32 34)
%5 = call i64 (...) @getpid()
%6 = trunc i64 %5 to i32
%7 = load i32, i32* @__NR_gettid
%8 = call i32 @syscall(i32 %7)
%9 = call i64 (...) @pthread_self()
%10 = trunc i64 %9 to i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %8, i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %3
ret i8* null
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s:%d -- \00"
@.str.1 = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/linux/pthread/gettid.c\00"
@.str.2 = [42 x i8] c"pid : [%d], tid = [%ld], threadid = [%u]\0A\00"
@__NR_gettid = global i32 0
define noalias i8* @start_thread(i8* nocapture readnone %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0), i32 34)
%3 = tail call i64 (...) @getpid()
%4 = trunc i64 %3 to i32
%5 = load i32, i32* @__NR_gettid
%6 = tail call i32 @syscall(i32 %5)
%7 = tail call i64 (...) @pthread_self()
%8 = trunc i64 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %6, i32 %8)
%10 = tail call i32 @putchar(i32 10)
ret i8* null
}