#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;

/* Variables and functions */
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void print_time(int TID, char *comment) {
  time_t tp;
  char buffer[26], mytime[9];
  (void)time(&tp);
  strcpy(&buffer[0], ctime(&tp));
  strncpy(&mytime[0], &buffer[11], 8);
  mytime[8] = '\0';
  printf("Thread %d %s barrier at %s\n", TID, comment, &mytime[0]);
  return;
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1070 <time@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <ctime@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x39(%rbp),%rdi
lea    -0x30(%rbp),%rsi
add    $0xb,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x31(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    -0x39(%rbp),%rcx
lea    0xe50(%rip),%rdi
call   1060 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1050 <ctime@plt>
lea    0x10(%rsp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0x1b(%rsp),%rsi
lea    0x7(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
lea    0xe61(%rip),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <printf@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Thread %d %s barrier at %s\0A\00"
define void @print_time(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [26 x i8]
%7 = alloca [9 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = call i32 @time(i32* %5)
%9 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%10 = call i32 @ctime(i32* %5)
%11 = call i32 @strcpy(i8* %9, i32 %10)
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 11
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 8)
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 8
store i8 0, i8* %15
%16 = load i32, i32* %3
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %17, i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Thread %d %s barrier at %s\0A\00"
define void @print_time(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca [26 x i8]
%5 = alloca [9 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%9 = call i32 @time(i32* %3)
%10 = call i32 @ctime(i32* %3)
%11 = call i32 @strcpy(i8* %7, i32 %10)
%12 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 11
%13 = call i32 @strncpy(i8* %8, i8* %12, i32 8)
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 8
store i8 0, i8* %14
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %1, i8* %8)
ret void
}