#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 scalar_t__ time_t;
struct tm {
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
};

/* Variables and functions */
struct tm *gmtime(scalar_t__ *);
scalar_t__ mkgmtime(struct tm *);
int /*<<< orphan*/ sscanf(char *, char *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
time_t sync_time(time_t arg_gpstime, char *arg_videotime) {
  static time_t videotime_t;
  static struct tm *ptm_video;
  static time_t result;
  videotime_t = 0;
  ptm_video = gmtime(&videotime_t);
  if (arg_videotime) {
    sscanf(arg_videotime, "%2d%2d%2d", &ptm_video->tm_hour, &ptm_video->tm_min,
           &ptm_video->tm_sec);
  }
  videotime_t = mkgmtime(ptm_video);
  result = (arg_gpstime - videotime_t);
  return result;
}


x86 assembly (clang, -O0):
<sync_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,0x2ef5(%rip)
lea    0x2eee(%rip),%rdi
call   1050 <gmtime@plt>
mov    %rax,0x2eea(%rip)
cmpq   $0x0,-0x10(%rbp)
je     1196 <sync_time+0x66>
mov    -0x10(%rbp),%rdi
mov    0x2ed4(%rip),%rdx
add    $0x8,%rdx
mov    0x2ec9(%rip),%rcx
add    $0x4,%rcx
mov    0x2ebe(%rip),%r8
lea    0xe6f(%rip),%rsi
call   1040 <sscanf@plt>
mov    0x2eab(%rip),%rdi
call   1030 <mkgmtime@plt>
mov    %rax,0x2e97(%rip)
mov    -0x8(%rbp),%rax
sub    0x2e8c(%rip),%rax
mov    %rax,0x2e95(%rip)
mov    0x2e8e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sync_time>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x2efb(%rip)
lea    0x2ef4(%rip),%rdi
call   1050 <gmtime@plt>
mov    %rax,0x2ef0(%rip)
test   %r14,%r14
je     1181 <sync_time+0x51>
lea    0x8(%rax),%rdx
mov    %rax,%rcx
add    $0x4,%rcx
lea    0xe91(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%r8
call   1040 <sscanf@plt>
mov    0x2ec7(%rip),%rax
mov    %rax,%rdi
call   1030 <mkgmtime@plt>
mov    %rax,0x2eb0(%rip)
sub    %rax,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@sync_time.videotime_t = internal global i64 0
@sync_time.ptm_video = internal global %struct.tm* null
@sync_time.result = internal global i64 0
@.str = [10 x i8] c"%2d%2d%2d\00"
define i64 @sync_time(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
store i64 %0, i64* %3
store i8* %1, i8** %4
store i64 0, i64* @sync_time.videotime_t
%5 = call %struct.tm* @gmtime(i64* @sync_time.videotime_t)
store %struct.tm* %5, %struct.tm** @sync_time.ptm_video
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load %struct.tm*, %struct.tm** @sync_time.ptm_video
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
%12 = load %struct.tm*, %struct.tm** @sync_time.ptm_video
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load %struct.tm*, %struct.tm** @sync_time.ptm_video
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
%16 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %11, i32* %13, i32* %15)
br label %17
17: ; preds = %8, %2
%18 = load %struct.tm*, %struct.tm** @sync_time.ptm_video
%19 = call i64 @mkgmtime(%struct.tm* %18)
store i64 %19, i64* @sync_time.videotime_t
%20 = load i64, i64* %3
%21 = load i64, i64* @sync_time.videotime_t
%22 = sub nsw i64 %20, %21
store i64 %22, i64* @sync_time.result
%23 = load i64, i64* @sync_time.result
ret i64 %23
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@sync_time.videotime_t = internal global i64 0
@sync_time.ptm_video = internal unnamed_addr global %struct.tm* null
@.str = [10 x i8] c"%2d%2d%2d\00"
define i64 @sync_time(i64 %0, i8* %1) {
store i64 0, i64* @sync_time.videotime_t
%3 = tail call %struct.tm* @gmtime(i64* @sync_time.videotime_t)
store %struct.tm* %3, %struct.tm** @sync_time.ptm_video
%4 = icmp eq i8* %1, null
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%7 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%9 = tail call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %7, i32* %8)
%10 = load %struct.tm*, %struct.tm** @sync_time.ptm_video
br label %11
11: ; preds = %5, %2
%12 = phi %struct.tm* [ %10, %5 ], [ %3, %2 ]
%13 = tail call i64 @mkgmtime(%struct.tm* %12)
store i64 %13, i64* @sync_time.videotime_t
%14 = sub nsw i64 %0, %13
ret i64 %14
}