#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 */
struct timespec {
  long long tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ errno;
struct timespec *flu_parse_ts(char const *);
int /*<<< orphan*/ free(struct timespec *);
long long flu_parse_t(const char *s) {
  struct timespec *ts = flu_parse_ts(s);
  if (ts == NULL) {
    errno = EINVAL;
    return 0;
  }
  long long r = ts->tv_sec;
  free(ts);
  return r;
}


x86 assembly (clang, -O0):
<flu_parse_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <flu_parse_ts@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <flu_parse_t+0x43>
mov    0x2e8d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e8c(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    117f <flu_parse_t+0x5f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flu_parse_t>:
push   %rbx
call   1040 <flu_parse_ts@plt>
test   %rax,%rax
je     1138 <flu_parse_t+0x18>
mov    (%rax),%rbx
mov    %rax,%rdi
call   1030 <free@plt>
jmp    114c <flu_parse_t+0x2c>
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    0x2e98(%rip),%rcx
mov    %eax,(%rcx)
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64 }
@EINVAL = global i32 0
@errno = global i32 0
define i64 @flu_parse_t(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca %struct.timespec*
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call %struct.timespec* @flu_parse_ts(i8* %6)
store %struct.timespec* %7, %struct.timespec** %4
%8 = load %struct.timespec*, %struct.timespec** %4
%9 = icmp eq %struct.timespec* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i32, i32* @EINVAL
store i32 %11, i32* @errno
store i64 0, i64* %2
br label %19
12: ; preds = %1
%13 = load %struct.timespec*, %struct.timespec** %4
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
%15 = load i64, i64* %14
store i64 %15, i64* %5
%16 = load %struct.timespec*, %struct.timespec** %4
%17 = call i32 @free(%struct.timespec* %16)
%18 = load i64, i64* %5
store i64 %18, i64* %2
br label %19
19: ; preds = %12, %10
%20 = load i64, i64* %2
ret i64 %20
}

LLVM IR (-O2):
%struct.timespec = type { i64 }
@EINVAL = global i32 0
@errno = global i32 0
define i64 @flu_parse_t(i8* %0) {
%2 = tail call %struct.timespec* @flu_parse_ts(i8* %0)
%3 = icmp eq %struct.timespec* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load i32, i32* @EINVAL
store i32 %5, i32* @errno
br label %10
6: ; preds = %1
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%8 = load i64, i64* %7
%9 = tail call i32 @free(%struct.timespec* %2)
br label %10
10: ; preds = %6, %4
%11 = phi i64 [ 0, %4 ], [ %8, %6 ]
ret i64 %11
}