#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 {
  scalar_t__ tv_sec;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ output(int, int);
void pulseTS(int gpio, struct timespec *up, struct timespec *down) {
  if ((up->tv_sec > 0) || (up->tv_nsec > 0)) {
    output(gpio, 1);
    nanosleep(up, NULL);
  }
  if ((down->tv_sec > 0) || (down->tv_nsec > 0)) {
    output(gpio, 0);
    nanosleep(down, NULL);
  }
}


x86 assembly (clang, -O0):
<pulseTS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jg     1150 <pulseTS+0x30>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jle    116a <pulseTS+0x4a>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <output@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <nanosleep@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jg     1187 <pulseTS+0x67>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jle    119e <pulseTS+0x7e>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1030 <output@plt>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <nanosleep@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pulseTS>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r14d
cmpq   $0x0,(%rsi)
jg     113a <pulseTS+0x1a>
cmpq   $0x0,0x8(%rbp)
jle    1151 <pulseTS+0x31>
mov    %r14d,%edi
mov    $0x1,%esi
call   1030 <output@plt>
mov    %rbp,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
cmpq   $0x0,(%rbx)
jg     115e <pulseTS+0x3e>
cmpq   $0x0,0x8(%rbx)
jle    1176 <pulseTS+0x56>
mov    %r14d,%edi
xor    %esi,%esi
call   1030 <output@plt>
mov    %rbx,%rdi
xor    %esi,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <nanosleep@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
define void @pulseTS(i32 %0, %struct.timespec* %1, %struct.timespec* %2) {
%4 = alloca i32
%5 = alloca %struct.timespec*
%6 = alloca %struct.timespec*
store i32 %0, i32* %4
store %struct.timespec* %1, %struct.timespec** %5
store %struct.timespec* %2, %struct.timespec** %6
%7 = load %struct.timespec*, %struct.timespec** %5
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = icmp sgt i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %3
%12 = load %struct.timespec*, %struct.timespec** %5
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%14 = load i64, i64* %13
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11, %3
%17 = load i32, i32* %4
%18 = call i32 @output(i32 %17, i32 1)
%19 = load %struct.timespec*, %struct.timespec** %5
%20 = call i32 @nanosleep(%struct.timespec* %19, i32* null)
br label %21
21: ; preds = %16, %11
%22 = load %struct.timespec*, %struct.timespec** %6
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 0
%24 = load i64, i64* %23
%25 = icmp sgt i64 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = load %struct.timespec*, %struct.timespec** %6
%28 = getelementptr inbounds %struct.timespec, %struct.timespec* %27, i32 0, i32 1
%29 = load i64, i64* %28
%30 = icmp sgt i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26, %21
%32 = load i32, i32* %4
%33 = call i32 @output(i32 %32, i32 0)
%34 = load %struct.timespec*, %struct.timespec** %6
%35 = call i32 @nanosleep(%struct.timespec* %34, i32* null)
br label %36
36: ; preds = %31, %26
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define void @pulseTS(i32 %0, %struct.timespec* %1, %struct.timespec* %2) {
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = icmp sgt i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7, %3
%12 = tail call i32 @output(i32 %0, i32 1)
%13 = tail call i32 @nanosleep(%struct.timespec* %1, i32* null)
br label %14
14: ; preds = %11, %7
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%16 = load i64, i64* %15
%17 = icmp sgt i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%20 = load i64, i64* %19
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18, %14
%23 = tail call i32 @output(i32 %0, i32 0)
%24 = tail call i32 @nanosleep(%struct.timespec* %2, i32* null)
br label %25
25: ; preds = %22, %18
ret void
}