#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 */
scalar_t__ EINVAL;
scalar_t__ errno;
struct timespec *flu_parse_ts(char const *);
int /*<<< orphan*/ free(struct timespec *);
long long flu_parse_t(const char *s) {
  errno = 0;
  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    0x2ead(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <flu_parse_ts@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1173 <flu_parse_t+0x53>
mov    0x2e7f(%rip),%rax
mov    (%rax),%rcx
mov    0x2e7d(%rip),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    118f <flu_parse_t+0x6f>
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
mov    0x2eb8(%rip),%rbx
movq   $0x0,(%rbx)
call   1040 <flu_parse_ts@plt>
test   %rax,%rax
je     1146 <flu_parse_t+0x26>
mov    (%rax),%rbx
mov    %rax,%rdi
call   1030 <free@plt>
jmp    1155 <flu_parse_t+0x35>
mov    0x2e8b(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rbx)
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64 }
@errno = global i64 0
@EINVAL = global i64 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
store i64 0, i64* @errno
%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 i64, i64* @EINVAL
store i64 %11, i64* @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 }
@errno = global i64 0
@EINVAL = global i64 0
define i64 @flu_parse_t(i8* %0) {
store i64 0, i64* @errno
%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 i64, i64* @EINVAL
store i64 %5, i64* @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
}