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

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int timer_hour_judge(int /*<<< orphan*/);
int timer_next_hour_get(time_t time, int *second) {
  int ret;
  struct tm *p;
  ret = timer_hour_judge(time);
  if (0 == ret) {
    *second = 0;
    return 0;
  }
  p = gmtime(&time);
  *second = (60 - p->tm_min - 1) * 60 + (60 - p->tm_sec);
  return 0;
}


x86 assembly (clang, -O0):
<timer_next_hour_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <timer_hour_judge@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    115b <timer_next_hour_get+0x3b>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1194 <timer_next_hour_get+0x74>
lea    -0x8(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    $0x3c,%eax
sub    (%rcx),%eax
sub    $0x1,%eax
imul   $0x3c,%eax,%ecx
mov    -0x20(%rbp),%rdx
mov    $0x3c,%eax
sub    0x4(%rdx),%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timer_next_hour_get>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
call   1030 <timer_hour_judge@plt>
test   %eax,%eax
je     1151 <timer_next_hour_get+0x31>
lea    0xc(%rsp),%rdi
call   1040 <gmtime@plt>
mov    $0x3b,%ecx
sub    (%rax),%ecx
imul   $0x3c,%ecx,%ecx
sub    0x4(%rax),%ecx
add    $0x3c,%ecx
jmp    1153 <timer_next_hour_get+0x33>
xor    %ecx,%ecx
mov    %ecx,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
define i32 @timer_next_hour_get(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.tm*
store i32 %0, i32* %4
store i32* %1, i32** %5
%8 = load i32, i32* %4
%9 = call i32 @timer_hour_judge(i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 0, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32*, i32** %5
store i32 0, i32* %13
store i32 0, i32* %3
br label %28
14: ; preds = %2
%15 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %15, %struct.tm** %7
%16 = load %struct.tm*, %struct.tm** %7
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = sub nsw i32 60, %18
%20 = sub nsw i32 %19, 1
%21 = mul nsw i32 %20, 60
%22 = load %struct.tm*, %struct.tm** %7
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = sub nsw i32 60, %24
%26 = add nsw i32 %21, %25
%27 = load i32*, i32** %5
store i32 %26, i32* %27
store i32 0, i32* %3
br label %28
28: ; preds = %14, %12
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
define i32 @timer_next_hour_get(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = tail call i32 @timer_hour_judge(i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = call %struct.tm* @gmtime(i32* %3)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = sub i32 59, %9
%11 = mul nsw i32 %10, 60
%12 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%13 = load i32, i32* %12
%14 = sub i32 60, %13
%15 = add nsw i32 %14, %11
br label %16
16: ; preds = %2, %6
%17 = phi i32 [ %15, %6 ], [ 0, %2 ]
store i32 %17, i32* %1
ret i32 0
}