#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*/ timer_t;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_PROCESS_CPUTIME_ID;
int /*<<< orphan*/ perror(char *);
int timer_create(int /*<<< orphan*/, int /*<<< orphan*/ *,
                 int /*<<< orphan*/ *);
int timer_delete(int /*<<< orphan*/);
void create_cpu_timer(void) {
  timer_t timer;
  int ret;
  ret = timer_create(CLOCK_PROCESS_CPUTIME_ID, NULL, &timer);
  if (ret) {
    perror("timer_create");
  }
  ret = timer_delete(timer);
  if (ret) {
    perror("timer_delete");
  }
}


x86 assembly (clang, -O0):
<create_cpu_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x4(%rbp),%rdx
call   1030 <timer_create@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1167 <create_cpu_timer+0x37>
lea    0xe9e(%rip),%rdi
call   1050 <perror@plt>
mov    -0x4(%rbp),%edi
call   1040 <timer_delete@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1188 <create_cpu_timer+0x58>
lea    0xe8a(%rip),%rdi
call   1050 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_cpu_timer>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rdx
xor    %esi,%esi
call   1030 <timer_create@plt>
test   %eax,%eax
jne    1159 <create_cpu_timer+0x29>
mov    0x4(%rsp),%edi
call   1040 <timer_delete@plt>
test   %eax,%eax
jne    1167 <create_cpu_timer+0x37>
pop    %rax
ret
lea    0xea0(%rip),%rdi
call   1050 <perror@plt>
jmp    114a <create_cpu_timer+0x1a>
lea    0xe9f(%rip),%rdi
call   1050 <perror@plt>
pop    %rax
ret

LLVM IR (-O0):
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@.str = [13 x i8] c"timer_create\00"
@.str.1 = [13 x i8] c"timer_delete\00"
define void @create_cpu_timer() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%4 = call i32 @timer_create(i32 %3, i32* null, i32* %1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* %1
%11 = call i32 @timer_delete(i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@.str = [13 x i8] c"timer_create\00"
@.str.1 = [13 x i8] c"timer_delete\00"
define void @create_cpu_timer() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%4 = call i32 @timer_create(i32 %3, i32* null, i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = load i32, i32* %1
%10 = call i32 @timer_delete(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
ret void
}