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

/* Variables and functions */
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int delaySleep(int minutes, pid_t pid) {
  int mins;
  for (mins = 0; mins < (minutes * 60); mins += 600) {
    if (kill(pid, SIGUSR2) != 0) {
      fprintf(stderr, "Failed to signal for sleep delay\n");
      return -1;
    }
    usleep(20000);
  }
  printf("delayed sleep by %d minutes\n", mins / 60);
  return 0;
}


x86 assembly (clang, -O0):
<delaySleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
imul   $0x3c,-0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    11ba <delaySleep+0x7a>
mov    -0xc(%rbp),%edi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
cmp    $0x0,%rax
je     11a0 <delaySleep+0x60>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <delaySleep+0x9a>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%eax
add    $0x258,%eax
mov    %eax,-0x10(%rbp)
jmp    1155 <delaySleep+0x15>
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delaySleep>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
mov    $0x0,%ebx
test   %edi,%edi
jle    1199 <delaySleep+0x59>
mov    %esi,%r15d
imul   $0x3c,%edi,%r13d
xor    %ebx,%ebx
mov    0x2e71(%rip),%r12
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r12),%esi
mov    %r15d,%edi
call   1050 <kill@plt>
test   %rax,%rax
jne    11a9 <delaySleep+0x69>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
add    $0x258,%ebp
add    $0xa,%ebx
cmp    %r13d,%ebp
jl     1170 <delaySleep+0x30>
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    11c4 <delaySleep+0x84>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SIGUSR2 = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"Failed to signal for sleep delay\0A\00"
@.str.1 = [29 x i8] c"delayed sleep by %d minutes\0A\00"
define i32 @delaySleep(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %22, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = mul nsw i32 %9, 60
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %25
12: ; preds = %7
%13 = load i32, i32* %5
%14 = load i32, i32* @SIGUSR2
%15 = call i64 @kill(i32 %13, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %29
20: ; preds = %12
%21 = call i32 @usleep(i32 20000)
br label %22
22: ; preds = %20
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 600
store i32 %24, i32* %6
br label %7
25: ; preds = %7
%26 = load i32, i32* %6
%27 = sdiv i32 %26, 60
%28 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %27)
store i32 0, i32* %3
br label %29
29: ; preds = %25, %17
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@SIGUSR2 = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"Failed to signal for sleep delay\0A\00"
@.str.1 = [29 x i8] c"delayed sleep by %d minutes\0A\00"
define i32 @delaySleep(i32 %0, i32 %1) {
%3 = mul nsw i32 %0, 60
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %19
5: ; preds = %2, %13
%6 = phi i32 [ %15, %13 ], [ 0, %2 ]
%7 = load i32, i32* @SIGUSR2
%8 = tail call i64 @kill(i32 %1, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %22
13: ; preds = %5
%14 = tail call i32 @usleep(i32 20000)
%15 = add nuw nsw i32 %6, 600
%16 = icmp slt i32 %15, %3
br i1 %16, label %5, label %17
17: ; preds = %13
%18 = udiv i32 %15, 60
br label %19
19: ; preds = %17, %2
%20 = phi i32 [ 0, %2 ], [ %18, %17 ]
%21 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %10
%23 = phi i32 [ -1, %10 ], [ 0, %19 ]
ret i32 %23
}