#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 /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ refresh();
int time(int /*<<< orphan*/);
void goodnight(int initime) {
  int runtime = time(0) - initime;
  move(22, 0);
  printw("*** Program ended successfully               ");
  move(22, 58);
  printw("runtime: %3dh %2dm %2ds", runtime / 3600, runtime / 60 % 60,
         runtime % 60);
  move(23, 0);
  printw("*** [Press any key to quit]");
  refresh();
  getch();
  endwin();
}


x86 assembly (clang, -O0):
<goodnight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
sub    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x16,%edi
xor    %esi,%esi
call   1080 <move@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    $0x16,%edi
mov    $0x3a,%esi
call   1080 <move@plt>
mov    -0x8(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0xc(%rbp),%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1080 <move@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    $0x0,%al
call   1070 <endwin@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<goodnight>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%ebp
sub    %ebx,%ebp
mov    $0x16,%edi
xor    %esi,%esi
call   1080 <move@plt>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    $0x16,%edi
mov    $0x3a,%esi
call   1080 <move@plt>
movslq %ebp,%rcx
imul   $0xffffffff91a2b3c5,%rcx,%rsi
shr    $0x20,%rsi
add    %ecx,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0xb,%esi
add    %eax,%esi
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
movslq %eax,%rdx
imul   $0xffffffff88888889,%rdx,%rax
shr    $0x20,%rax
add    %edx,%eax
mov    %eax,%edi
shr    $0x1f,%edi
sar    $0x5,%eax
add    %edi,%eax
imul   $0x3c,%eax,%eax
imul   $0x3c,%edx,%edi
sub    %eax,%edx
sub    %edi,%ecx
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1080 <move@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <endwin@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"*** Program ended successfully \00"
@.str.1 = [24 x i8] c"runtime: %3dh %2dm %2ds\00"
@.str.2 = [28 x i8] c"*** [Press any key to quit]\00"
define void @goodnight(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @time(i32 0)
%5 = load i32, i32* %2
%6 = sub nsw i32 %4, %5
store i32 %6, i32* %3
%7 = call i32 @move(i32 22, i32 0)
%8 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @move(i32 22, i32 58)
%10 = load i32, i32* %3
%11 = sdiv i32 %10, 3600
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 60
%14 = srem i32 %13, 60
%15 = load i32, i32* %3
%16 = srem i32 %15, 60
%17 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14, i32 %16)
%18 = call i32 @move(i32 23, i32 0)
%19 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (...) @refresh()
%21 = call i32 (...) @getch()
%22 = call i32 (...) @endwin()
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"*** Program ended successfully \00"
@.str.1 = [24 x i8] c"runtime: %3dh %2dm %2ds\00"
@.str.2 = [28 x i8] c"*** [Press any key to quit]\00"
define void @goodnight(i32 %0) {
%2 = tail call i32 @time(i32 0)
%3 = sub nsw i32 %2, %0
%4 = tail call i32 @move(i32 22, i32 0)
%5 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @move(i32 22, i32 58)
%7 = sdiv i32 %3, 3600
%8 = sdiv i32 %3, 60
%9 = srem i32 %8, 60
%10 = srem i32 %3, 60
%11 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %9, i32 %10)
%12 = tail call i32 @move(i32 23, i32 0)
%13 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 (...) @refresh()
%15 = tail call i32 (...) @getch()
%16 = tail call i32 (...) @endwin()
ret void
}