#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 clock_t;

/* Variables and functions */
int CLOCKS_PER_SEC;
unsigned int atoi(char *);
int clock();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int);
unsigned int sleep(unsigned int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "USAGE:\t%s seconds\n", argv[0]);
    fprintf(stderr, "\tSleeps for the specified number of seconds\n");
    return 1;
  };
  clock_t start = clock();
  unsigned secs = atoi(argv[1]);
  while (secs > 0) {
    secs = sleep(secs);
  };
  clock_t end = clock();
  clock_t seconds = (end - start) / CLOCKS_PER_SEC;
  printf("I waited for %lu seconds\n", seconds);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b1 <main+0x61>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1218 <main+0xc8>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jbe    11e5 <main+0x95>
mov    -0x18(%rbp),%edi
call   1070 <sleep@plt>
mov    %eax,-0x18(%rbp)
jmp    11cb <main+0x7b>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    0x2dec(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    11af <main+0x5f>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%r14d
mov    0x8(%rbp),%rdi
call   1060 <atoi@plt>
test   %eax,%eax
je     118b <main+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%edi
call   1070 <sleep@plt>
test   %eax,%eax
jne    1180 <main+0x30>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14d,%eax
mov    0x2e4c(%rip),%rcx
cltd
idivl  (%rcx)
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    11df <main+0x8f>
mov    0x2e22(%rip),%rbx
mov    (%rbx),%edi
mov    0x0(%rbp),%rdx
lea    0xe3d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe40(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"USAGE:\09%s seconds\0A\00"
@.str.1 = [45 x i8] c"\09Sleeps for the specified number of seconds\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [26 x i8] c"I waited for %lu seconds\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %41
20: ; preds = %2
%21 = call i32 (...) @clock()
store i32 %21, i32* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
br label %26
26: ; preds = %29, %20
%27 = load i32, i32* %7
%28 = icmp ugt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %7
%31 = call i32 @sleep(i32 %30)
store i32 %31, i32* %7
br label %26
32: ; preds = %26
%33 = call i32 (...) @clock()
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = load i32, i32* %6
%36 = sub nsw i32 %34, %35
%37 = load i32, i32* @CLOCKS_PER_SEC
%38 = sdiv i32 %36, %37
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %32, %12
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"USAGE:\09%s seconds\0A\00"
@.str.1 = [45 x i8] c"\09Sleeps for the specified number of seconds\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [26 x i8] c"I waited for %lu seconds\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %26
10: ; preds = %2
%11 = tail call i32 (...) @clock()
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %10, %16
%17 = phi i32 [ %18, %16 ], [ %14, %10 ]
%18 = tail call i32 @sleep(i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %16, %10
%21 = tail call i32 (...) @clock()
%22 = sub nsw i32 %21, %11
%23 = load i32, i32* @CLOCKS_PER_SEC
%24 = sdiv i32 %22, %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %20, %4
%27 = phi i32 [ 1, %4 ], [ 0, %20 ]
ret i32 %27
}