#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*/ pthread_t;
typedef int /*<<< orphan*/ pthread_attr_t;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_CREATE_DETACHED;
int /*<<< orphan*/ logcat(char *, int);
int /*<<< orphan*/ pthread_attr_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_attr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_attr_setdetachstate(int /*<<< orphan*/ *,
                                               int /*<<< orphan*/);
int pthread_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   void *(*)(void *), int /*<<< orphan*/ *);
int start_timer_function_thr(void *(*func)(void *)) {
  int ret;
  pthread_t p;
  pthread_attr_t tattr;
  pthread_attr_init(&tattr);
  pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
  ret = pthread_create(&p, &tattr, func, NULL);
  if (ret) {
    logcat("RTC Timer function start error, ret = %d !\n", ret);
    return -1;
  }
  pthread_attr_destroy(&tattr);
  return 0;
}


x86 assembly (clang, -O0):
<start_timer_function_thr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <pthread_attr_init@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdi
call   1050 <pthread_attr_setdetachstate@plt>
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <pthread_create@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b4 <start_timer_function_thr+0x64>
mov    -0x14(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1030 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <start_timer_function_thr+0x74>
lea    -0x1c(%rbp),%rdi
call   1070 <pthread_attr_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_timer_function_thr>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1040 <pthread_attr_init@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1050 <pthread_attr_setdetachstate@plt>
xor    %ebx,%ebx
lea    0xc(%rsp),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1060 <pthread_create@plt>
test   %eax,%eax
je     11a7 <start_timer_function_thr+0x57>
lea    0xe67(%rip),%rdi
mov    %eax,%esi
call   1030 <logcat@plt>
mov    $0xffffffff,%ebx
jmp    11b1 <start_timer_function_thr+0x61>
lea    0x8(%rsp),%rdi
call   1070 <pthread_attr_destroy@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PTHREAD_CREATE_DETACHED = global i32 0
@.str = [44 x i8] c"RTC Timer function start error, ret = %d !\0A\00"
define i32 @start_timer_function_thr(i8* (i8*)* %0) {
%2 = alloca i32
%3 = alloca i8* (i8*)*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* (i8*)* %0, i8* (i8*)** %3
%7 = call i32 @pthread_attr_init(i32* %6)
%8 = load i32, i32* @PTHREAD_CREATE_DETACHED
%9 = call i32 @pthread_attr_setdetachstate(i32* %6, i32 %8)
%10 = load i8* (i8*)*, i8* (i8*)** %3
%11 = call i32 @pthread_create(i32* %5, i32* %6, i8* (i8*)* %10, i32* null)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i32, i32* %4
%16 = call i32 @logcat(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 -1, i32* %2
br label %19
17: ; preds = %1
%18 = call i32 @pthread_attr_destroy(i32* %6)
store i32 0, i32* %2
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@PTHREAD_CREATE_DETACHED = global i32 0
@.str = [44 x i8] c"RTC Timer function start error, ret = %d !\0A\00"
define i32 @start_timer_function_thr(i8* (i8*)* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @pthread_attr_init(i32* %3)
%7 = load i32, i32* @PTHREAD_CREATE_DETACHED
%8 = call i32 @pthread_attr_setdetachstate(i32* %3, i32 %7)
%9 = call i32 @pthread_create(i32* %2, i32* %3, i8* (i8*)* %0, i32* null)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %1
%12 = call i32 @logcat(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %15
13: ; preds = %1
%14 = call i32 @pthread_attr_destroy(i32* %3)
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ -1, %11 ], [ 0, %13 ]
ret i32 %16
}