#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 scalar_t__ pthread_t;
typedef scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ getpid();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ pthread_self();
int /*<<< orphan*/ sleep(int);
void *print_abc(void *arg) {
  pid_t pid;
  pthread_t tid;
  printf("start\n");
  pid = getpid();
  tid = pthread_self();
  printf("pid %u talk [%s] to tid %u\n", (unsigned int)pid, (char *)arg,
         (unsigned int)tid);
  sleep(2);
  printf("end\n");
  return NULL;
}


x86 assembly (clang, -O0):
<print_abc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_abc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <pthread_self@plt>
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%edi
call   1070 <sleep@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"start\0A\00"
@.str.1 = [28 x i8] c"pid %u talk [%s] to tid %u\0A\00"
@.str.2 = [5 x i8] c"end\0A\00"
define i8* @print_abc(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i8* %0, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = call i64 (...) @getpid()
store i64 %6, i64* %3
%7 = call i64 (...) @pthread_self()
store i64 %7, i64* %4
%8 = load i64, i64* %3
%9 = trunc i64 %8 to i32
%10 = load i8*, i8** %2
%11 = load i64, i64* %4
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %9, i8* %10, i32 %12)
%14 = call i32 @sleep(i32 2)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i8* null
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"pid %u talk [%s] to tid %u\0A\00"
@str = [6 x i8] c"start\00"
@str.3 = [4 x i8] c"end\00"
define noalias i8* @print_abc(i8* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%3 = tail call i64 (...) @getpid()
%4 = tail call i64 (...) @pthread_self()
%5 = trunc i64 %3 to i32
%6 = trunc i64 %4 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %5, i8* %0, i32 %6)
%8 = tail call i32 @sleep(i32 2)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0))
ret i8* null
}