#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 chk_sum(char *);
int chk_val(char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int uct_to_bjt(char *);
int main() {
  char sen[255] = {'\0'};
  char uct[8] = {'\0'};
  scanf("%s", sen);
  while (strcmp(sen, "END") != 0) {
    if (strncmp(sen, "$GPRMC,", 7) == 0) {
      int chksum = chk_sum(sen);
      int chkval = chk_val(sen);
      char *loc = strchr(strchr(sen, ',') + 1, ',') + 1;
      if (chksum == chkval && *loc == 'A') {
        strncpy(uct, (strchr(sen, ',') + 1), 6);
      }
    }
    scanf("%s", sen);
  }
  int bjt = uct_to_bjt(uct);
  printf("%02d:%02d:%02d", bjt / 10000, bjt / 100 % 100, bjt % 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1080 <memset@plt>
lea    -0x118(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1080 <memset@plt>
lea    -0x110(%rbp),%rsi
lea    0xe1a(%rip),%rdi
call   10b0 <scanf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     12f4 <main+0x154>
lea    -0x110(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12dc <main+0x13c>
lea    -0x110(%rbp),%rdi
call   10c0 <chk_sum@plt>
mov    %eax,-0x11c(%rbp)
lea    -0x110(%rbp),%rdi
call   10a0 <chk_val@plt>
mov    %eax,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x120(%rbp),%eax
jne    12d7 <main+0x137>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jne    12d7 <main+0x137>
lea    -0x118(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    -0x138(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
jmp    12dc <main+0x13c>
lea    -0x110(%rbp),%rsi
lea    0xd16(%rip),%rdi
call   10b0 <scanf@plt>
jmp    11eb <main+0x4b>
lea    -0x118(%rbp),%rdi
call   1050 <uct_to_bjt@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x12c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x13c(%rbp)
mov    -0x12c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x13c(%rbp),%edx
lea    0xcc0(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xff(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xde1(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   10a0 <scanf@plt>
lea    0xdd0(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12f0 <main+0x160>
lea    0xdbc(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xda9(%rip),%rbx
lea    0xda5(%rip),%r15
jmp    127b <main+0xeb>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12f0 <main+0x160>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1260 <main+0xd0>
mov    %r13,%rdi
call   10b0 <chk_sum@plt>
mov    %eax,%r15d
mov    %r13,%rdi
call   1090 <chk_val@plt>
mov    %eax,%r14d
mov    %r13,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
cmp    %r14d,%r15d
lea    0xd46(%rip),%r15
jne    1260 <main+0xd0>
mov    %rax,%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
cmpb   $0x41,0x1(%rax)
jne    1260 <main+0xd0>
lea    0x8(%rsp),%rdi
mov    %rbp,%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
jmp    1260 <main+0xd0>
lea    0x8(%rsp),%rdi
call   1050 <uct_to_bjt@plt>
movslq %eax,%rcx
imul   $0x68db8bad,%rcx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x2c,%rsi
add    %eax,%esi
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x25,%rax
add    %edi,%eax
imul   $0x64,%eax,%eax
imul   $0x64,%edx,%edi
sub    %eax,%edx
sub    %edi,%ecx
lea    0xcc2(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"END\00"
@.str.2 = [8 x i8] c"$GPRMC,\00"
@.str.3 = [15 x i8] c"%02d:%02d:%02d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = alloca [8 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [255 x i8]* %2 to i8*
%9 = bitcast [8 x i8]* %3 to i8*
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %45, %0
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %48
16: ; preds = %12
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %45
20: ; preds = %16
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%22 = call i32 @chk_sum(i8* %21)
store i32 %22, i32* %4
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%24 = call i32 @chk_val(i8* %23)
store i32 %24, i32* %5
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%26 = call i8* @strchr(i8* %25, i8 signext 44)
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i8* @strchr(i8* %27, i8 signext 44)
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %6
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %20
%34 = load i8*, i8** %6
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 65
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%41 = call i8* @strchr(i8* %40, i8 signext 44)
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = call i32 @strncpy(i8* %39, i8* %42, i32 6)
br label %44
44: ; preds = %38, %33, %20
br label %45
45: ; preds = %44, %16
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %46)
br label %12
48: ; preds = %12
%49 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%50 = call i32 @uct_to_bjt(i8* %49)
store i32 %50, i32* %7
%51 = load i32, i32* %7
%52 = sdiv i32 %51, 10000
%53 = load i32, i32* %7
%54 = sdiv i32 %53, 100
%55 = srem i32 %54, 100
%56 = load i32, i32* %7
%57 = srem i32 %56, 100
%58 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %52, i32 %55, i32 %57)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"END\00"
@.str.2 = [8 x i8] c"$GPRMC,\00"
@.str.3 = [15 x i8] c"%02d:%02d:%02d\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %28, label %8
8: ; preds = %0, %24
%9 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = call i32 @chk_sum(i8* %3)
%13 = call i32 @chk_val(i8* %3)
%14 = call i8* @strchr(i8* %3, i8 signext 44)
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = icmp eq i32 %12, %13
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = call i8* @strchr(i8* %15, i8 signext 44)
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 65
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @strncpy(i8* %4, i8* %15, i32 6)
br label %24
24: ; preds = %11, %17, %22, %8
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%26 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %8
28: ; preds = %24, %0
%29 = call i32 @uct_to_bjt(i8* %4)
%30 = sdiv i32 %29, 10000
%31 = sdiv i32 %29, 100
%32 = srem i32 %31, 100
%33 = srem i32 %29, 100
%34 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %32, i32 %33)
ret i32 0
}