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

/* Variables and functions */
struct tm *localtime(unsigned int *);
unsigned int mktime(struct tm *);
unsigned int addclocktime(time_t start, int hours, int minutes, int seconds) {
  time_t alarmtime;
  struct tm *st, *end;
  st = localtime(&start);
  end = localtime(&start);
  if (hours < st->tm_hour) {
    end->tm_hour = hours + 24;
  } else if (hours == st->tm_hour && minutes < st->tm_min) {
    end->tm_hour = hours + 24;
  } else {
    end->tm_hour = hours;
  }
  end->tm_sec = seconds;
  end->tm_min = minutes;
  alarmtime = mktime(end);
  return (alarmtime - start);
}


x86 assembly (clang, -O0):
<addclocktime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    116e <addclocktime+0x4e>
mov    -0x8(%rbp),%ecx
add    $0x18,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ac <addclocktime+0x8c>
mov    -0x8(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jne    119e <addclocktime+0x7e>
mov    -0xc(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    119e <addclocktime+0x7e>
mov    -0x8(%rbp),%ecx
add    $0x18,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    11a7 <addclocktime+0x87>
mov    -0x8(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ac <addclocktime+0x8c>
mov    -0x10(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <mktime@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addclocktime>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%r12
mov    %r12,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <localtime@plt>
cmp    %ebp,(%rbx)
jle    1159 <addclocktime+0x39>
add    $0x18,%ebp
jmp    1167 <addclocktime+0x47>
jne    1167 <addclocktime+0x47>
lea    0x18(%rbp),%ecx
cmp    %r15d,0x4(%rbx)
cmovle %ebp,%ecx
mov    %ecx,%ebp
mov    %ebp,(%rax)
mov    %r14d,0x8(%rax)
mov    %r15d,0x4(%rax)
mov    %rax,%rdi
call   1040 <mktime@plt>
sub    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define i32 @addclocktime(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.tm*
%11 = alloca %struct.tm*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %12, %struct.tm** %10
%13 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %13, %struct.tm** %11
%14 = load i32, i32* %6
%15 = load %struct.tm*, %struct.tm** %10
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = icmp slt i32 %14, %17
br i1 %18, label %19, label %24
19: ; preds = %4
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 24
%22 = load %struct.tm*, %struct.tm** %11
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 0
store i32 %21, i32* %23
br label %46
24: ; preds = %4
%25 = load i32, i32* %6
%26 = load %struct.tm*, %struct.tm** %10
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = icmp eq i32 %25, %28
br i1 %29, label %30, label %41
30: ; preds = %24
%31 = load i32, i32* %7
%32 = load %struct.tm*, %struct.tm** %10
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 1
%34 = load i32, i32* %33
%35 = icmp slt i32 %31, %34
br i1 %35, label %36, label %41
36: ; preds = %30
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 24
%39 = load %struct.tm*, %struct.tm** %11
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 0
store i32 %38, i32* %40
br label %45
41: ; preds = %30, %24
%42 = load i32, i32* %6
%43 = load %struct.tm*, %struct.tm** %11
%44 = getelementptr inbounds %struct.tm, %struct.tm* %43, i32 0, i32 0
store i32 %42, i32* %44
br label %45
45: ; preds = %41, %36
br label %46
46: ; preds = %45, %19
%47 = load i32, i32* %8
%48 = load %struct.tm*, %struct.tm** %11
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i32 0, i32 2
store i32 %47, i32* %49
%50 = load i32, i32* %7
%51 = load %struct.tm*, %struct.tm** %11
%52 = getelementptr inbounds %struct.tm, %struct.tm* %51, i32 0, i32 1
store i32 %50, i32* %52
%53 = load %struct.tm*, %struct.tm** %11
%54 = call i32 @mktime(%struct.tm* %53)
store i32 %54, i32* %9
%55 = load i32, i32* %9
%56 = load i32, i32* %5
%57 = sub i32 %55, %56
ret i32 %57
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define i32 @addclocktime(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
store i32 %0, i32* %5
%6 = call %struct.tm* @localtime(i32* %5)
%7 = call %struct.tm* @localtime(i32* %5)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%9 = load i32, i32* %8
%10 = icmp sgt i32 %9, %1
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = add nsw i32 %1, 24
br label %21
13: ; preds = %4
%14 = icmp eq i32 %9, %1
br i1 %14, label %15, label %21
15: ; preds = %13
%16 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%17 = load i32, i32* %16
%18 = icmp sgt i32 %17, %2
%19 = add nsw i32 %1, 24
%20 = select i1 %18, i32 %19, i32 %1
br label %21
21: ; preds = %15, %13, %11
%22 = phi i32 [ %12, %11 ], [ %1, %13 ], [ %20, %15 ]
%23 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
store i32 %22, i32* %23
%24 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
store i32 %3, i32* %24
%25 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
store i32 %2, i32* %25
%26 = call i32 @mktime(%struct.tm* %7)
%27 = load i32, i32* %5
%28 = sub i32 %26, %27
ret i32 %28
}