#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 clock();
char getch();
scalar_t__ kbhit();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  printf("*#This is a stopwatch#*\n\n\n");
  printf("**Press 'p' to pause.\n");
  printf("**Press any key to start & to stop.");
  getch();
  system("cls");
  printf("\t\t*#This is a stopwatch#*\n\n\n");
  clock_t s, n;
  s = clock();
  while (1) {
    while (1) {
      n = clock();
      printf("\r");
      printf("Time-\t %d : %d : %d ", ((n - s) / 1000) / 60,
             ((n - s) / 1000) % 60, (n - s) % 1000);
      if (kbhit())
        break;
    }
    if (getch() == 'p') {
      printf("\rTime-\t %d : %d : %d ", ((n - s) / 1000) / 60,
             ((n - s) / 1000) % 60, (n - s) % 1000);
      getch();
    } else
      break;
    s = s + (clock() - n);
  }
  printf("\rTime-\t %d : %d : %d ", ((n - s) / 1000) / 60,
         ((n - s) / 1000) % 60, (n - s) % 1000);
  getch();
  getch();
  printf("\n\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
lea    0xea4(%rip),%rdi
call   1040 <system@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x8(%rbp)
jmp    11b9 <main+0x69>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x10(%rbp),%edx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <kbhit@plt>
cmp    $0x0,%rax
je     1239 <main+0xe9>
jmp    123e <main+0xee>
jmp    11b9 <main+0x69>
mov    $0x0,%al
call   1070 <getch@plt>
movsbl %al,%eax
cmp    $0x70,%eax
jne    12af <main+0x15f>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x14(%rbp),%edx
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
jmp    12b4 <main+0x164>
jmp    12d3 <main+0x183>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x64>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x1c(%rbp),%edx
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    $0x0,%al
call   1070 <getch@plt>
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed4(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1090 <getch@plt>
lea    0xe75(%rip),%rdi
call   1060 <system@plt>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%r12d
lea    0xe58(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <clock@plt>
mov    %eax,%r13d
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    %r13d,%eax
sub    %r12d,%eax
movslq %eax,%rbx
imul   $0x45e7b273,%rbx,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
shr    $0x20,%rbp
sar    $0xe,%ebp
add    %eax,%ebp
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
movslq %eax,%r15
imul   $0xffffffff88888889,%r15,%rax
shr    $0x20,%rax
add    %r15d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
imul   $0x3e8,%r15d,%ecx
sub    %eax,%r15d
sub    %ecx,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1080 <kbhit@plt>
test   %rax,%rax
je     11e0 <main+0x70>
xor    %eax,%eax
call   1090 <getch@plt>
mov    %al,0x7(%rsp)
lea    0xda3(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1090 <getch@plt>
cmpb   $0x70,0x7(%rsp)
jne    12b3 <main+0x143>
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r13d,%r12d
add    %eax,%r12d
jmp    11e0 <main+0x70>
xor    %eax,%eax
call   1090 <getch@plt>
lea    0xdac(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"*#This is a stopwatch#*\0A\0A\0A\00"
@.str.1 = [23 x i8] c"**Press 'p' to pause.\0A\00"
@.str.2 = [36 x i8] c"**Press any key to start & to stop.\00"
@.str.3 = [4 x i8] c"cls\00"
@.str.4 = [29 x i8] c"\09\09*#This is a stopwatch#*\0A\0A\0A\00"
@.str.5 = [2 x i8] c"\0D\00"
@.str.6 = [21 x i8] c"Time-\09 %d : %d : %d \00"
@.str.7 = [22 x i8] c"\0DTime-\09 %d : %d : %d \00"
@.str.8 = [4 x i8] c"\0A\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%7 = call signext i8 (...) @getch()
%8 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (...) @clock()
store i32 %10, i32* %2
br label %11
11: ; preds = %0, %56
br label %12
12: ; preds = %11, %33
%13 = call i32 (...) @clock()
store i32 %13, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = sub nsw i32 %15, %16
%18 = sdiv i32 %17, 1000
%19 = sdiv i32 %18, 60
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = sub nsw i32 %20, %21
%23 = sdiv i32 %22, 1000
%24 = srem i32 %23, 60
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = sub nsw i32 %25, %26
%28 = srem i32 %27, 1000
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %19, i32 %24, i32 %28)
%30 = call i64 (...) @kbhit()
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %12
br label %34
33: ; preds = %12
br label %12
34: ; preds = %32
%35 = call signext i8 (...) @getch()
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 112
br i1 %37, label %38, label %55
38: ; preds = %34
%39 = load i32, i32* %3
%40 = load i32, i32* %2
%41 = sub nsw i32 %39, %40
%42 = sdiv i32 %41, 1000
%43 = sdiv i32 %42, 60
%44 = load i32, i32* %3
%45 = load i32, i32* %2
%46 = sub nsw i32 %44, %45
%47 = sdiv i32 %46, 1000
%48 = srem i32 %47, 60
%49 = load i32, i32* %3
%50 = load i32, i32* %2
%51 = sub nsw i32 %49, %50
%52 = srem i32 %51, 1000
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %43, i32 %48, i32 %52)
%54 = call signext i8 (...) @getch()
br label %56
55: ; preds = %34
br label %62
56: ; preds = %38
%57 = load i32, i32* %2
%58 = call i32 (...) @clock()
%59 = load i32, i32* %3
%60 = sub nsw i32 %58, %59
%61 = add nsw i32 %57, %60
store i32 %61, i32* %2
br label %11
62: ; preds = %55
%63 = load i32, i32* %3
%64 = load i32, i32* %2
%65 = sub nsw i32 %63, %64
%66 = sdiv i32 %65, 1000
%67 = sdiv i32 %66, 60
%68 = load i32, i32* %3
%69 = load i32, i32* %2
%70 = sub nsw i32 %68, %69
%71 = sdiv i32 %70, 1000
%72 = srem i32 %71, 60
%73 = load i32, i32* %3
%74 = load i32, i32* %2
%75 = sub nsw i32 %73, %74
%76 = srem i32 %75, 1000
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %67, i32 %72, i32 %76)
%78 = call signext i8 (...) @getch()
%79 = call signext i8 (...) @getch()
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [36 x i8] c"**Press any key to start & to stop.\00"
@.str.3 = [4 x i8] c"cls\00"
@.str.6 = [21 x i8] c"Time-\09 %d : %d : %d \00"
@.str.7 = [22 x i8] c"\0DTime-\09 %d : %d : %d \00"
@str = [26 x i8] c"*#This is a stopwatch#*\0A\0A\00"
@str.9 = [22 x i8] c"**Press 'p' to pause.\00"
@str.10 = [28 x i8] c"\09\09*#This is a stopwatch#*\0A\0A\00"
@str.11 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call signext i8 (...) @getch()
%5 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 (...) @clock()
br label %8
8: ; preds = %26, %0
%9 = phi i32 [ %7, %0 ], [ %29, %26 ]
br label %10
10: ; preds = %10, %8
%11 = tail call i32 (...) @clock()
%12 = tail call i32 @putchar(i32 13)
%13 = sub nsw i32 %11, %9
%14 = sdiv i32 %13, 1000
%15 = sdiv i32 %13, 60000
%16 = srem i32 %14, 60
%17 = srem i32 %13, 1000
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
%19 = tail call i64 (...) @kbhit()
%20 = icmp eq i64 %19, 0
br i1 %20, label %10, label %21
21: ; preds = %10
%22 = tail call signext i8 (...) @getch()
%23 = icmp eq i8 %22, 112
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
%25 = tail call signext i8 (...) @getch()
br i1 %23, label %26, label %30
26: ; preds = %21
%27 = tail call i32 (...) @clock()
%28 = sub i32 %9, %11
%29 = add i32 %28, %27
br label %8
30: ; preds = %21
%31 = tail call signext i8 (...) @getch()
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.11, i64 0, i64 0))
ret i32 0
}