#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(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strtok(char *, char *);
void printNextSecond(const char *timeStr) {
  int h, m, s;
  char *time = (char *)malloc(sizeof(char));
  strcpy(time, timeStr);
  h = atoi(strtok(time, ":"));
  m = atoi(strtok(NULL, ":"));
  s = atoi(strtok(NULL, ":"));
  if (s == 59) {
    s = 0;
    if (m == 59) {
      m = 0;
      if (h == 23)
        h = 0;
      else
        h++;
    } else
      m++;
  } else
    s++;
  free(time);
  printf("%02d:%02d:%02d", h, m, s);
}


x86 assembly (clang, -O0):
<printNextSecond>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe54(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe3a(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3b,-0x14(%rbp)
jne    1229 <printNextSecond+0xc9>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3b,-0x10(%rbp)
jne    121b <printNextSecond+0xbb>
movl   $0x0,-0x10(%rbp)
cmpl   $0x17,-0xc(%rbp)
jne    120d <printNextSecond+0xad>
movl   $0x0,-0xc(%rbp)
jmp    1216 <printNextSecond+0xb6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1224 <printNextSecond+0xc4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1232 <printNextSecond+0xd2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xdb7(%rip),%rdi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printNextSecond>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe77(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,%r14d
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
cmp    $0x3b,%eax
jne    11e0 <printNextSecond+0x80>
cmp    $0x3b,%ebp
jne    11e7 <printNextSecond+0x87>
xor    %ebp,%ebp
cmp    $0x17,%r14d
lea    0x1(%r14),%eax
cmove  %ebp,%eax
xor    %ebx,%ebx
mov    %eax,%r14d
jmp    11ec <printNextSecond+0x8c>
mov    %eax,%ebx
add    $0x1,%ebx
jmp    11ec <printNextSecond+0x8c>
add    $0x1,%ebp
xor    %ebx,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xe07(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [15 x i8] c"%02d:%02d:%02d\00"
define void @printNextSecond(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
%7 = call i64 @malloc(i32 1)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %6
%13 = call i32 @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @atoi(i32 %13)
store i32 %14, i32* %3
%15 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @atoi(i32 %15)
store i32 %16, i32* %4
%17 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @atoi(i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 59
br i1 %20, label %21, label %36
21: ; preds = %1
store i32 0, i32* %5
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 59
br i1 %23, label %24, label %32
24: ; preds = %21
store i32 0, i32* %4
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 23
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* %3
br label %31
28: ; preds = %24
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %31
31: ; preds = %28, %27
br label %35
32: ; preds = %21
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %35
35: ; preds = %32, %31
br label %39
36: ; preds = %1
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %39
39: ; preds = %36, %35
%40 = load i8*, i8** %6
%41 = call i32 @free(i8* %40)
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = load i32, i32* %5
%45 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [15 x i8] c"%02d:%02d:%02d\00"
define void @printNextSecond(i8* %0) {
%2 = tail call i64 @malloc(i32 1)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = tail call i32 @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @atoi(i32 %5)
%7 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @atoi(i32 %7)
%9 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @atoi(i32 %9)
%11 = icmp eq i32 %10, 59
br i1 %11, label %12, label %20
12: ; preds = %1
%13 = icmp eq i32 %8, 59
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = icmp eq i32 %6, 23
%16 = add nsw i32 %6, 1
%17 = select i1 %15, i32 0, i32 %16
br label %22
18: ; preds = %12
%19 = add nsw i32 %8, 1
br label %22
20: ; preds = %1
%21 = add nsw i32 %10, 1
br label %22
22: ; preds = %14, %18, %20
%23 = phi i32 [ %19, %18 ], [ %8, %20 ], [ 0, %14 ]
%24 = phi i32 [ 0, %18 ], [ %21, %20 ], [ 0, %14 ]
%25 = phi i32 [ %6, %18 ], [ %6, %20 ], [ %17, %14 ]
%26 = tail call i32 @free(i8* %3)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %23, i32 %24)
ret void
}