#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(char *);
int /*<<< orphan*/ getchar();
char *malloc(int);
int /*<<< orphan*/ nextTime(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  char *current = malloc(20);
  strcpy(current, "2004-11-30-23-59-59");
  char *token = strtok(current, "-");
  int i = 0;
  int time[6];
  do {
    time[i] = atoi(token);
    printf("%d\t", time[i]);
    token = strtok(NULL, "-");
    i++;
  } while (token);
  printf("\n");
  nextTime(time, 5, 1);
  for (i = 0; i < 6; i++) {
    printf("%d\t", time[i]);
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
movslq -0x24(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe21(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bf <main+0x4f>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
call   1090 <nextTime@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    1266 <main+0xf6>
movslq -0x24(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1238 <main+0xc8>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe63(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe68(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strtok@plt>
mov    %rsp,%rbx
lea    0xe55(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,(%rbx)
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1080 <strtok@plt>
add    $0x4,%rbx
test   %rax,%rax
jne    11d0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x1,%edx
call   10a0 <nextTime@plt>
mov    (%rsp),%esi
lea    0xdf7(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"2004-11-30-23-59-59\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [4 x i8] c"%d\09\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%5 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = bitcast [6 x i32]* %3 to i8*
br label %8
8: ; preds = %8, %2
%9 = phi i64 [ %15, %8 ], [ 0, %2 ]
%10 = phi i8* [ %14, %8 ], [ %6, %2 ]
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %9
store i32 %11, i32* %12
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = add nuw i64 %9, 1
%16 = icmp eq i8* %14, null
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = tail call i32 @putchar(i32 10)
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%20 = call i32 @nextTime(i32* %19, i32 5, i32 1)
%21 = load i32, i32* %19
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = call i32 (...) @getchar()
ret i32 0
}