#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct TYPE_3__ {
  int sival_int;
};
typedef TYPE_1__ sigval_t;
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int, int);
scalar_t__ pthread_self();
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void handle(sigval_t v) {
  time_t t;
  char p[32];
  time(&t);
  strftime(p, sizeof(p), "%T", localtime(&t));
  printf("%s thread %d, val = %d, signal captured.\n", p, (int)pthread_self(),
         v.sival_int);
  return;
}


x86 assembly (clang, -O0):
<handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <time@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%ecx
mov    $0x20,%esi
lea    0xe79(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1070 <pthread_self@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
mov    -0x8(%rbp),%ecx
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe8c(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
xor    %eax,%eax
call   1070 <pthread_self@plt>
lea    0xe6d(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
call   1040 <printf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@.str = [3 x i8] c"%T\00"
@.str.1 = [42 x i8] c"%s thread %d, val = %d, signal captured.\0A\00"
define void @handle(i32 %0) {
%2 = alloca %struct.TYPE_3__
%3 = alloca i32
%4 = alloca [32 x i8]
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i32 0, i32 0
store i32 %0, i32* %5
%6 = call i32 @time(i32* %3)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = call i32 @localtime(i32* %3)
%9 = call i32 @strftime(i8* %7, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%11 = call i64 (...) @pthread_self()
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %12, i32 %14)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%T\00"
@.str.1 = [42 x i8] c"%s thread %d, val = %d, signal captured.\0A\00"
define void @handle(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = call i32 @time(i32* %2)
%7 = call i32 @localtime(i32* %2)
%8 = call i32 @strftime(i8* %5, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i64 (...) @pthread_self()
%10 = trunc i64 %9 to i32
%11 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %10, i32 %0)
ret void
}