#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*/ sprintf(char *, char *, int, int, double);
int sscanf(char const *, char *, int *, int *, double *);
int /*<<< orphan*/ strcpy(char *, char *);
void time_to_isotime(const char *timestr, char *isotimestr) {
  int hour, min;
  double sec;
  if (sscanf(timestr, "%d:%d:%lf", &hour, &min, &sec) != 3) {
    strcpy("INVALID", isotimestr);
    return;
  }
  sprintf(isotimestr, "%02d:%02d:%06.3lf", hour, min, sec);
}


x86 assembly (clang, -O0):
<time_to_isotime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     117a <time_to_isotime+0x4a>
mov    -0x10(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <strcpy@plt>
jmp    1195 <time_to_isotime+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
movsd  -0x20(%rbp),%xmm0
lea    0xe82(%rip),%rsi
call   1050 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_to_isotime>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xec1(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
lea    0x8(%rsp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
jne    1174 <time_to_isotime+0x44>
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
movsd  0x8(%rsp),%xmm0
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
jmp    1183 <time_to_isotime+0x53>
lea    0xe8f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%d:%d:%lf\00"
@.str.1 = [8 x i8] c"INVALID\00"
@.str.2 = [18 x i8] c"%02d:%02d:%06.3lf\00"
define void @time_to_isotime(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, double* %7)
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @strcpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %20
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = load double, double* %7
%19 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17, double %18)
br label %20
20: ; preds = %14, %11
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d:%d:%lf\00"
@.str.1 = [8 x i8] c"INVALID\00"
@.str.2 = [18 x i8] c"%02d:%02d:%06.3lf\00"
define void @time_to_isotime(i8* nocapture %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, double* %5)
%10 = icmp eq i32 %9, 3
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @strcpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %18
13: ; preds = %2
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = load double, double* %5
%17 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15, double %16)
br label %18
18: ; preds = %13, %11
ret void
}