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

/* Variables and functions */
int atoi(char *);
scalar_t__ digitstring(char *);
int /*<<< orphan*/ kbhit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int run_sleep(int argc, char **argv) {
  int t;
  int ac = argc;
  int i;
  t = 0;
  if (argc == 2) {
    if (digitstring(argv[1])) {
      t = atoi(argv[1]);
      ac = 2;
    } else
      ac = 1;
  } else if (argc > 2) {
    ac = 1;
    if (digitstring(argv[1])) {
      t = atoi(argv[1]);
      ac = 2;
    }
  }
  if (argc != 1) {
    for (i = ac; i < argc; i++)
      printf("%s ", argv[i]);
    printf("\n");
  }
  if (t == 0) {
    if (argc == 1)
      printf("Press any key to continue\n");
    kbhit(0);
  } else
    sleep(t);
  return 1;
}


x86 assembly (clang, -O0):
<run_sleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    11b5 <run_sleep+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <digitstring@plt>
cmp    $0x0,%rax
je     11a9 <run_sleep+0x59>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
jmp    11b0 <run_sleep+0x60>
movl   $0x1,-0x18(%rbp)
jmp    11fe <run_sleep+0xae>
cmpl   $0x2,-0x4(%rbp)
jle    11f9 <run_sleep+0xa9>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <digitstring@plt>
cmp    $0x0,%rax
je     11f4 <run_sleep+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
jmp    11f9 <run_sleep+0xa9>
jmp    11fe <run_sleep+0xae>
cmpl   $0x1,-0x4(%rbp)
je     1250 <run_sleep+0x100>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1242 <run_sleep+0xf2>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120e <run_sleep+0xbe>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    127e <run_sleep+0x12e>
cmpl   $0x1,-0x4(%rbp)
jne    1272 <run_sleep+0x122>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <kbhit@plt>
jmp    1286 <run_sleep+0x136>
mov    -0x14(%rbp),%edi
call   1070 <sleep@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_sleep>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebp
cmp    $0x2,%edi
je     1184 <run_sleep+0x14>
jle    11ff <run_sleep+0x8f>
mov    0x8(%r15),%rdi
call   1070 <digitstring@plt>
test   %rax,%rax
je     11ac <run_sleep+0x3c>
lea    0x8(%r15),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    $0x2,%eax
cmp    %ebp,%eax
jb     11b8 <run_sleep+0x48>
jmp    11e6 <run_sleep+0x76>
mov    $0x1,%eax
xor    %r14d,%r14d
cmp    %ebp,%eax
jae    11e6 <run_sleep+0x76>
mov    %eax,%ebx
mov    %ebp,%ebp
lea    0xe3d(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbx,8),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    11d0 <run_sleep+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
je     121c <run_sleep+0xac>
mov    %r14d,%edi
call   1090 <sleep@plt>
jmp    1223 <run_sleep+0xb3>
cmp    $0x1,%ebp
jne    1212 <run_sleep+0xa2>
lea    0xdf9(%rip),%rdi
call   1040 <puts@plt>
jmp    121c <run_sleep+0xac>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1060 <kbhit@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [27 x i8] c"Press any key to continue\0A\00"
define i32 @run_sleep(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
store i32 %8, i32* %6
store i32 0, i32* %5
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @digitstring(i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %5
store i32 2, i32* %6
br label %23
22: ; preds = %11
store i32 1, i32* %6
br label %23
23: ; preds = %22, %17
br label %40
24: ; preds = %2
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 2
br i1 %26, label %27, label %39
27: ; preds = %24
store i32 1, i32* %6
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @digitstring(i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %5
store i32 2, i32* %6
br label %38
38: ; preds = %33, %27
br label %39
39: ; preds = %38, %24
br label %40
40: ; preds = %39, %23
%41 = load i32, i32* %3
%42 = icmp ne i32 %41, 1
br i1 %42, label %43, label %61
43: ; preds = %40
%44 = load i32, i32* %6
store i32 %44, i32* %7
br label %45
45: ; preds = %56, %43
%46 = load i32, i32* %7
%47 = load i32, i32* %3
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i8**, i8*** %4
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %49
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %45
59: ; preds = %45
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %61
61: ; preds = %59, %40
%62 = load i32, i32* %5
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %61
%65 = load i32, i32* %3
%66 = icmp eq i32 %65, 1
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %69
69: ; preds = %67, %64
%70 = call i32 @kbhit(i32 0)
br label %74
71: ; preds = %61
%72 = load i32, i32* %5
%73 = call i32 @sleep(i32 %72)
br label %74
74: ; preds = %71, %69
ret i32 1
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@str = [26 x i8] c"Press any key to continue\00"
define i32 @run_sleep(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @digitstring(i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %24, label %20
9: ; preds = %2
%10 = icmp sgt i32 %0, 2
br i1 %10, label %11, label %16
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @digitstring(i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %20
16: ; preds = %9
%17 = icmp eq i32 %0, 1
br i1 %17, label %41, label %18
18: ; preds = %16
%19 = tail call i32 @putchar(i32 10)
br label %43
20: ; preds = %11, %4
%21 = phi i8** [ %5, %4 ], [ %12, %11 ]
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
br label %24
24: ; preds = %20, %4, %11
%25 = phi i32 [ 0, %4 ], [ 0, %11 ], [ %23, %20 ]
%26 = phi i32 [ 1, %4 ], [ 1, %11 ], [ 2, %20 ]
%27 = icmp ult i32 %26, %0
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = zext i32 %26 to i64
br label %30
30: ; preds = %28, %30
%31 = phi i64 [ %29, %28 ], [ %35, %30 ]
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = add nuw nsw i64 %31, 1
%36 = trunc i64 %35 to i32
%37 = icmp eq i32 %36, %0
br i1 %37, label %38, label %30
38: ; preds = %30, %24
%39 = tail call i32 @putchar(i32 10)
%40 = icmp eq i32 %25, 0
br i1 %40, label %43, label %45
41: ; preds = %16
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %38, %18, %41
%44 = tail call i32 @kbhit(i32 0)
br label %47
45: ; preds = %38
%46 = tail call i32 @sleep(i32 %25)
br label %47
47: ; preds = %45, %43
ret i32 1
}