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

/* Variables and functions */
scalar_t__ nanosleep(struct timespec *, struct timespec *);
void slepp(int secs) {
  struct timespec req;
  struct timespec rem;
  req.tv_sec = secs;
  req.tv_nsec = 0;
  while (nanosleep(&req, &rem)) {
    req.tv_sec = rem.tv_sec;
    req.tv_nsec = rem.tv_nsec;
  }
}


x86 assembly (clang, -O0):
<slepp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <nanosleep@plt>
cmp    $0x0,%rax
je     1153 <slepp+0x43>
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1129 <slepp+0x19>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slepp>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <nanosleep@plt>
test   %rax,%rax
je     1172 <slepp+0x62>
lea    0x8(%rsp),%r14
lea    0x18(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x18(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x20(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <nanosleep@plt>
test   %rax,%rax
jne    1150 <slepp+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
define void @slepp(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
store i64 0, i64* %7
br label %8
8: ; preds = %11, %1
%9 = call i64 @nanosleep(%struct.timespec* %3, %struct.timespec* %4)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%16 = load i64, i64* %15
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
store i64 %16, i64* %17
br label %8
18: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
define void @slepp(i32 %0) {
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %2 to i8*
%5 = bitcast %struct.timespec* %3 to i8*
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 %0, i32* %6
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i64 0, i64* %7
%8 = call i64 @nanosleep(%struct.timespec* %2, %struct.timespec* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %1
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
br label %13
13: ; preds = %10, %13
%14 = load i32, i32* %11
store i32 %14, i32* %6
%15 = load i64, i64* %12
store i64 %15, i64* %7
%16 = call i64 @nanosleep(%struct.timespec* %2, %struct.timespec* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %13
18: ; preds = %13, %1
ret void
}