#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 int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int difftime(int /*<<< orphan*/, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ logErrorMessages(char *, char *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ strptime(char *, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int getSeconds(char *time_str) {
  time_t now = time(NULL);
  struct tm newyear;
  newyear = *localtime(&now);
  if (!strptime(time_str, "%H:%M:%S", &newyear)) {
    logErrorMessages("parsing time error", time_str);
  }
  int time_diff = difftime(mktime(&newyear), now);
  return time_diff;
}


x86 assembly (clang, -O0):
<getSeconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1080 <strptime@plt>
cmp    $0x0,%eax
jne    11b3 <getSeconds+0x53>
mov    -0x8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1070 <logErrorMessages@plt>
lea    -0x10(%rbp),%rdi
call   1060 <mktime@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1040 <difftime@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSeconds>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0xe76(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1080 <strptime@plt>
test   %eax,%eax
jne    11aa <getSeconds+0x4a>
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
call   1070 <logErrorMessages@plt>
lea    0x8(%rsp),%rdi
call   1060 <mktime@plt>
mov    0xc(%rsp),%esi
mov    %eax,%edi
call   1040 <difftime@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [19 x i8] c"parsing time error\00"
define i32 @getSeconds(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @time(i32* null)
store i32 %6, i32* %3
%7 = call %struct.tm* @localtime(i32* %3)
%8 = bitcast %struct.tm* %4 to i8*
%9 = bitcast %struct.tm* %7 to i8*
%10 = load i8*, i8** %2
%11 = call i32 @strptime(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = call i32 @logErrorMessages(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %1
%17 = call i32 @mktime(%struct.tm* %4)
%18 = load i32, i32* %3
%19 = call i32 @difftime(i32 %17, i32 %18)
store i32 %19, i32* %5
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [19 x i8] c"parsing time error\00"
define i32 @getSeconds(i8* %0) {
%2 = alloca i32
%3 = alloca %struct.tm
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = bitcast %struct.tm* %3 to i8*
%7 = call %struct.tm* @localtime(i32* %2)
%8 = getelementptr %struct.tm, %struct.tm* %7, i64 0, i32 0
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%10 = load i32, i32* %8
store i32 %10, i32* %9
%11 = call i32 @strptime(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @logErrorMessages(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %13, %1
%16 = call i32 @mktime(%struct.tm* %3)
%17 = load i32, i32* %2
%18 = call i32 @difftime(i32 %16, i32 %17)
ret i32 %18
}