#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 /*<<< orphan*/ time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
unsigned int getMinutesToWait(unsigned int, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void printSchedulerAction(FILE *fd, char *label, time_t *lastOccurancep,
                          unsigned int count, unsigned int frequency) {
  unsigned int remaining;
  char *timeStr;
  time_t currentTime = time(NULL);
  remaining = getMinutesToWait(frequency, currentTime, *lastOccurancep);
  timeStr = asctime(localtime(lastOccurancep));
  if (strlen(timeStr) != 0)
    timeStr[strlen(timeStr) - 1] = 0;
  fprintf(fd, "%14s  %s   %4d       ", label, timeStr, count);
  if (frequency != 0)
    fprintf(fd, "%02d:%02d     ", frequency / 60, frequency % 60);
  else
    fprintf(fd, "--:--     ");
  if (frequency != 0)
    fprintf(fd, "%02d:%02d\n", remaining / 60, remaining % 60);
  else
    fprintf(fd, "--:--\n");
}


x86 assembly (clang, -O0):
<printSchedulerAction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1040 <getMinutesToWait@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
je     11e2 <printSchedulerAction+0x82>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x20(%rbp)
je     1241 <printSchedulerAction+0xe1>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%ecx
mov    -0x44(%rbp),%edx
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1253 <printSchedulerAction+0xf3>
mov    -0x8(%rbp),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x20(%rbp)
je     1294 <printSchedulerAction+0x134>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%ecx
mov    -0x48(%rbp),%edx
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12a6 <printSchedulerAction+0x146>
mov    -0x8(%rbp),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSchedulerAction>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r14
xor    %edi,%edi
call   1080 <time@plt>
mov    (%rbx),%edx
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <getMinutesToWait@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1060 <asctime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     11cc <printSchedulerAction+0x5c>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe2d(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %r15d,%r8d
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %ebp,%ebp
je     1244 <printSchedulerAction+0xd4>
mov    %ebp,%edx
mov    $0x88888889,%ebx
imul   %rbx,%rdx
shr    $0x25,%rdx
imul   $0x3c,%edx,%eax
sub    %eax,%ebp
lea    0xe11(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r13d,%edx
imul   %rbx,%rdx
shr    $0x25,%rdx
imul   $0x3c,%edx,%eax
sub    %eax,%r13d
lea    0xe07(%rip),%rsi
mov    %r14,%rdi
mov    %r13d,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fprintf@plt>
lea    0xdda(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1090 <fwrite@plt>
lea    0xdd7(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <fwrite@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"%14s %s %4d \00"
@.str.1 = [15 x i8] c"%02d:%02d \00"
@.str.2 = [11 x i8] c"--:-- \00"
@.str.3 = [11 x i8] c"%02d:%02d\0A\00"
@.str.4 = [7 x i8] c"--:--\0A\00"
define void @printSchedulerAction(i32* %0, i8* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = call i32 @time(i32* null)
store i32 %14, i32* %13
%15 = load i32, i32* %10
%16 = load i32, i32* %13
%17 = load i32*, i32** %8
%18 = load i32, i32* %17
%19 = call i32 @getMinutesToWait(i32 %15, i32 %16, i32 %18)
store i32 %19, i32* %11
%20 = load i32*, i32** %8
%21 = call i32 @localtime(i32* %20)
%22 = call i8* @asctime(i32 %21)
store i8* %22, i8** %12
%23 = load i8*, i8** %12
%24 = call i32 @strlen(i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %5
%27 = load i8*, i8** %12
%28 = load i8*, i8** %12
%29 = call i32 @strlen(i8* %28)
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %27, i64 %31
store i8 0, i8* %32
br label %33
33: ; preds = %26, %5
%34 = load i32*, i32** %6
%35 = load i8*, i8** %7
%36 = load i8*, i8** %12
%37 = load i32, i32* %9
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %35, i8* %36, i32 %37)
%39 = load i32, i32* %10
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %33
%42 = load i32*, i32** %6
%43 = load i32, i32* %10
%44 = udiv i32 %43, 60
%45 = load i32, i32* %10
%46 = urem i32 %45, 60
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %44, i32 %46)
br label %51
48: ; preds = %33
%49 = load i32*, i32** %6
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %48, %41
%52 = load i32, i32* %10
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = load i32*, i32** %6
%56 = load i32, i32* %11
%57 = udiv i32 %56, 60
%58 = load i32, i32* %11
%59 = urem i32 %58, 60
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %57, i32 %59)
br label %64
61: ; preds = %51
%62 = load i32*, i32** %6
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %61, %54
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"%14s %s %4d \00"
@.str.1 = [15 x i8] c"%02d:%02d \00"
@.str.2 = [11 x i8] c"--:-- \00"
@.str.3 = [11 x i8] c"%02d:%02d\0A\00"
@.str.4 = [7 x i8] c"--:--\0A\00"
define void @printSchedulerAction(i32* nocapture %0, i8* %1, i32* %2, i32 %3, i32 %4) {
%6 = tail call i32 @time(i32* null)
%7 = load i32, i32* %2
%8 = tail call i32 @getMinutesToWait(i32 %4, i32 %6, i32 %7)
%9 = tail call i32 @localtime(i32* %2)
%10 = tail call i8* @asctime(i32 %9)
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %5
%14 = tail call i32 @strlen(i8* %10)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %10, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %13, %5
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %10, i32 %3)
%20 = icmp eq i32 %4, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = udiv i32 %4, 60
%23 = urem i32 %4, 60
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
%25 = udiv i32 %8, 60
%26 = urem i32 %8, 60
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %26)
br label %31
28: ; preds = %18
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 10, i64 1, i32* %0)
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %31
31: ; preds = %28, %21
ret void
}