#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 time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int my_timegm(struct tm *);
int /*<<< orphan*/ reftime(unsigned char **, int *, int *, int *, int *, int *,
                           int *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
scalar_t__ verftime(unsigned char **, int *, int *, int *, int *, int *, int *);
int f_unix_time(int mode, unsigned char **sec, float *data, unsigned int ndata,
                char *inv_out, void **local) {
  time_t rtx, vtx;
  struct tm timeinfo;
  int year, month, day, hour, minute, second;
  if (mode >= 0) {
    reftime(sec, &year, &month, &day, &hour, &minute, &second);
    timeinfo.tm_year = year - 1900;
    timeinfo.tm_mon = month - 1;
    timeinfo.tm_mday = day;
    timeinfo.tm_hour = hour;
    timeinfo.tm_min = minute;
    timeinfo.tm_sec = second;
    rtx = my_timegm(&timeinfo);
    if (verftime(sec, &(timeinfo.tm_year), &(timeinfo.tm_mon),
                 &(timeinfo.tm_mday), &(timeinfo.tm_hour), &(timeinfo.tm_min),
                 &(timeinfo.tm_sec)) == 0) {
      timeinfo.tm_year -= 1900;
      timeinfo.tm_mon -= 1;
      vtx = my_timegm(&timeinfo);
    } else
      vtx = -1;
    sprintf(inv_out, "unix_rt=%d:unix_vt=%d", (int)rtx, (int)vtx);
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_unix_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     124a <f_unix_time+0x10a>
mov    -0x10(%rbp),%rdi
lea    -0x54(%rbp),%rsi
lea    -0x58(%rbp),%rdx
lea    -0x5c(%rbp),%rcx
lea    -0x60(%rbp),%r8
lea    -0x64(%rbp),%r9
lea    -0x68(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <reftime@plt>
mov    -0x54(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x50(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <my_timegm@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x50(%rbp),%rdx
add    $0x4,%rdx
lea    -0x50(%rbp),%rcx
add    $0x8,%rcx
lea    -0x50(%rbp),%r8
add    $0xc,%r8
lea    -0x50(%rbp),%r9
add    $0x10,%r9
lea    -0x50(%rbp),%rax
add    $0x14,%rax
mov    %rax,(%rsp)
call   1040 <verftime@plt>
cmp    $0x0,%rax
jne    122d <f_unix_time+0xed>
mov    -0x50(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <my_timegm@plt>
mov    %eax,-0x38(%rbp)
jmp    1234 <f_unix_time+0xf4>
movl   $0xffffffff,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xdbb(%rip),%rsi
call   1060 <sprintf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_unix_time>:
test   %edi,%edi
js     123a <f_unix_time+0xfa>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r14
mov    %rsi,%rbx
lea    0x20(%rsp),%rax
mov    %rax,(%rsp)
lea    0x34(%rsp),%rsi
lea    0x30(%rsp),%rdx
lea    0x2c(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x24(%rsp),%r9
mov    %rbx,%rdi
call   1050 <reftime@plt>
mov    $0xfffff894,%eax
add    0x34(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x30(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
mov    0x2c(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x28(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0x24(%rsp),%eax
lea    0x18(%rsp),%r15
mov    %eax,0x18(%rsp)
mov    0x20(%rsp),%eax
lea    0x1c(%rsp),%r13
mov    %eax,0x1c(%rsp)
lea    0x8(%rsp),%r12
mov    %r12,%rdi
call   1030 <my_timegm@plt>
mov    %eax,%ebp
mov    %r13,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    %r15,%r9
call   1040 <verftime@plt>
mov    $0xffffffff,%ecx
test   %rax,%rax
jne    121b <f_unix_time+0xdb>
addl   $0xfffff894,0x8(%rsp)
ff
addl   $0xffffffff,0xc(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <my_timegm@plt>
mov    %eax,%ecx
lea    0xdde(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <sprintf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [22 x i8] c"unix_rt=%d:unix_vt=%d\00"
define i32 @f_unix_time(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.tm
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%22 = load i32, i32* %7
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %65
24: ; preds = %6
%25 = load i8**, i8*** %8
%26 = call i32 @reftime(i8** %25, i32* %16, i32* %17, i32* %18, i32* %19, i32* %20, i32* %21)
%27 = load i32, i32* %16
%28 = sub nsw i32 %27, 1900
%29 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
store i32 %28, i32* %29
%30 = load i32, i32* %17
%31 = sub nsw i32 %30, 1
%32 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
store i32 %31, i32* %32
%33 = load i32, i32* %18
%34 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
store i32 %33, i32* %34
%35 = load i32, i32* %19
%36 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 3
store i32 %35, i32* %36
%37 = load i32, i32* %20
%38 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 4
store i32 %37, i32* %38
%39 = load i32, i32* %21
%40 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 5
store i32 %39, i32* %40
%41 = call i32 @my_timegm(%struct.tm* %15)
store i32 %41, i32* %13
%42 = load i8**, i8*** %8
%43 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
%44 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
%45 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
%46 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 3
%47 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 4
%48 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 5
%49 = call i64 @verftime(i8** %42, i32* %43, i32* %44, i32* %45, i32* %46, i32* %47, i32* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %24
%52 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
%53 = load i32, i32* %52
%54 = sub nsw i32 %53, 1900
store i32 %54, i32* %52
%55 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
%56 = load i32, i32* %55
%57 = sub nsw i32 %56, 1
store i32 %57, i32* %55
%58 = call i32 @my_timegm(%struct.tm* %15)
store i32 %58, i32* %14
br label %60
59: ; preds = %24
store i32 -1, i32* %14
br label %60
60: ; preds = %59, %51
%61 = load i8*, i8** %11
%62 = load i32, i32* %13
%63 = load i32, i32* %14
%64 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %62, i32 %63)
br label %65
65: ; preds = %60, %6
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [22 x i8] c"unix_rt=%d:unix_vt=%d\00"
define i32 @f_unix_time(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* nocapture writeonly %4, i8** nocapture readnone %5) {
%7 = alloca %struct.tm
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = bitcast %struct.tm* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = bitcast i32* %9 to i8*
%17 = bitcast i32* %10 to i8*
%18 = bitcast i32* %11 to i8*
%19 = bitcast i32* %12 to i8*
%20 = bitcast i32* %13 to i8*
%21 = icmp sgt i32 %0, -1
br i1 %21, label %22, label %50
22: ; preds = %6
%23 = call i32 @reftime(i8** %1, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13)
%24 = load i32, i32* %8
%25 = add nsw i32 %24, -1900
%26 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* %9
%28 = add nsw i32 %27, -1
%29 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
store i32 %28, i32* %29
%30 = load i32, i32* %10
%31 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
store i32 %30, i32* %31
%32 = load i32, i32* %11
%33 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 3
store i32 %32, i32* %33
%34 = load i32, i32* %12
%35 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 4
store i32 %34, i32* %35
%36 = load i32, i32* %13
%37 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 5
store i32 %36, i32* %37
%38 = call i32 @my_timegm(%struct.tm* %7)
%39 = call i64 @verftime(i8** %1, i32* %26, i32* %29, i32* %31, i32* %33, i32* %35, i32* %37)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %22
%42 = load i32, i32* %26
%43 = add nsw i32 %42, -1900
store i32 %43, i32* %26
%44 = load i32, i32* %29
%45 = add nsw i32 %44, -1
store i32 %45, i32* %29
%46 = call i32 @my_timegm(%struct.tm* %7)
br label %47
47: ; preds = %22, %41
%48 = phi i32 [ %46, %41 ], [ -1, %22 ]
%49 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %48)
br label %50
50: ; preds = %47, %6
ret i32 0
}