#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 tm_sec;
  int tm_min;
  int tm_hour;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int attime(time_t *timer) {
  time_t reftime = time(timer);
  struct tm *tm;
  tm = gmtime(&reftime);
  return (tm->tm_sec + (tm->tm_min * 60) + (tm->tm_hour * 3600)) / 86.4;
}


x86 assembly (clang, -O0):
<attime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
imul   $0x3c,0x4(%rcx),%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%rcx
imul   $0xe10,0x8(%rcx),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe92(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attime>:
push   %rax
call   1030 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <gmtime@plt>
imul   $0x3c,0x4(%rax),%ecx
add    (%rax),%ecx
imul   $0xe10,0x8(%rax),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
divsd  0xeb1(%rip),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define i32 @attime(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca %struct.tm*
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @time(i32* %5)
store i32 %6, i32* %3
%7 = call %struct.tm* @gmtime(i32* %3)
store %struct.tm* %7, %struct.tm** %4
%8 = load %struct.tm*, %struct.tm** %4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = load %struct.tm*, %struct.tm** %4
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 60
%15 = add nsw i32 %10, %14
%16 = load %struct.tm*, %struct.tm** %4
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 3600
%20 = add nsw i32 %15, %19
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 8.640000e+01
%23 = fptosi double %22 to i32
ret i32 %23
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define i32 @attime(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @time(i32* %0)
store i32 %4, i32* %2
%5 = call %struct.tm* @gmtime(i32* %2)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%9 = load i32, i32* %8
%10 = mul nsw i32 %9, 60
%11 = add nsw i32 %10, %7
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 3600
%15 = add nsw i32 %11, %14
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 8.640000e+01
%18 = fptosi double %17 to i32
ret i32 %18
}