#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 int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ SYS_gettid;
scalar_t__ getpid();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int, int, char const *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
scalar_t__ syscall(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void message(const char *msg) {
  time_t ts;
  time(&ts);
  struct tm *tm = localtime(&ts);
  char buf[32] = {};
  strftime(buf, sizeof(buf), "%H:%M:%S", tm);
  printf("%s pid=%d tid=%d %s\n", buf, (int)getpid(), (int)syscall(SYS_gettid),
         msg);
}


x86 assembly (clang, -O0):
<message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1080 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x20,%esi
lea    0xe4a(%rip),%rdx
call   1090 <strftime@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x44(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1070 <syscall@plt>
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
mov    -0x8(%rbp),%r8
lea    0xe1a(%rip),%rdi
call   1050 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<message>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe6b(%rip),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x20,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1060 <syscall@plt>
lea    0xe40(%rip),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
mov    %r14,%r8
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [21 x i8] c"%s pid=%d tid=%d %s\0A\00"
@SYS_gettid = global i32 0
define void @message(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca [32 x i8]
store i8* %0, i8** %2
%6 = call i32 @time(i32* %3)
%7 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %7, %struct.tm** %4
%8 = bitcast [32 x i8]* %5 to i8*
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%10 = load %struct.tm*, %struct.tm** %4
%11 = call i32 @strftime(i8* %9, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %10)
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = call i64 (...) @getpid()
%14 = trunc i64 %13 to i32
%15 = load i32, i32* @SYS_gettid
%16 = call i64 @syscall(i32 %15)
%17 = trunc i64 %16 to i32
%18 = load i8*, i8** %2
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %14, i32 %17, i8* %18)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [21 x i8] c"%s pid=%d tid=%d %s\0A\00"
@SYS_gettid = global i32 0
define void @message(i8* %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = bitcast i32* %2 to i8*
%5 = call i32 @time(i32* %2)
%6 = call %struct.tm* @localtime(i32* %2)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%8 = call i32 @strftime(i8* %7, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%9 = call i64 (...) @getpid()
%10 = trunc i64 %9 to i32
%11 = load i32, i32* @SYS_gettid
%12 = call i64 @syscall(i32 %11)
%13 = trunc i64 %12 to i32
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %10, i32 %13, i8* %0)
ret void
}