#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 tuner {
  int dummy;
};

/* Variables and functions */
int convert_time(char const *);
char *format_time(char *, char const *);
int /*<<< orphan*/ pause();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ tuner_sleep(struct tuner const *, int);
void maybe_sleep(const struct tuner *tuner, const char *wait_time) {
  char message[80 + 1];
  int int_wait_time;
  int_wait_time = convert_time(wait_time);
  if (int_wait_time > 0) {
    printf("Sleeping for %s\n", format_time(message, wait_time));
    tuner_sleep(tuner, int_wait_time);
  } else if (int_wait_time == 0) {
    printf("Sleeping forever...CTRL-C exits\n");
    for (;;)
      pause();
  }
}


x86 assembly (clang, -O0):
<maybe_sleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <convert_time@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jle    11a8 <maybe_sleep+0x58>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <format_time@plt>
mov    %rax,%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1030 <tuner_sleep@plt>
jmp    11d1 <maybe_sleep+0x81>
cmpl   $0x0,-0x74(%rbp)
jne    11cc <maybe_sleep+0x7c>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <pause@plt>
jmp    11c0 <maybe_sleep+0x70>
jmp    11d1 <maybe_sleep+0x81>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maybe_sleep>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <convert_time@plt>
test   %eax,%eax
jle    11a4 <maybe_sleep+0x44>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1080 <format_time@plt>
lea    0xe72(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <tuner_sleep@plt>
jmp    11a6 <maybe_sleep+0x46>
je     11af <maybe_sleep+0x4f>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <pause@plt>
jmp    11c0 <maybe_sleep+0x60>

LLVM IR (-O0):
%struct.tuner = type { i32 }
@.str = [17 x i8] c"Sleeping for %s\0A\00"
@.str.1 = [33 x i8] c"Sleeping forever...CTRL-C exits\0A\00"
define void @maybe_sleep(%struct.tuner* %0, i8* %1) {
%3 = alloca %struct.tuner*
%4 = alloca i8*
%5 = alloca [81 x i8]
%6 = alloca i32
store %struct.tuner* %0, %struct.tuner** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @convert_time(i8* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i8* @format_time(i8* %12, i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load %struct.tuner*, %struct.tuner** %3
%17 = load i32, i32* %6
%18 = call i32 @tuner_sleep(%struct.tuner* %16, i32 %17)
br label %27
19: ; preds = %2
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %24, %22
%25 = call i32 (...) @pause()
br label %24
26: ; preds = %19
br label %27
27: ; preds = %26, %11
ret void
}

LLVM IR (-O2):
%struct.tuner = type { i32 }
@.str = [17 x i8] c"Sleeping for %s\0A\00"
@str = [32 x i8] c"Sleeping forever...CTRL-C exits\00"
define void @maybe_sleep(%struct.tuner* %0, i8* %1) {
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @convert_time(i8* %1)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = call i8* @format_time(i8* %4, i8* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @tuner_sleep(%struct.tuner* %0, i32 %5)
br label %17
11: ; preds = %2
%12 = icmp eq i32 %5, 0
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %15, %13
%16 = tail call i32 (...) @pause()
br label %15
17: ; preds = %11, %7
ret void
}