#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 */

/* Variables and functions */
int add_dt(int *, int *, int *, int *, int *, int *, int, int);
int sub_dt(int *, int *, int *, int *, int *, int *, int, int);
int add_time(int *year, int *month, int *day, int *hour, int *minute,
             int *second, int dtime, int unit) {
  if (dtime == 0)
    return 0;
  if (dtime > 0)
    return add_dt(year, month, day, hour, minute, second, dtime, unit);
  return sub_dt(year, month, day, hour, minute, second, -dtime, unit);
}


x86 assembly (clang, -O0):
<add_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpl   $0x0,0x10(%rbp)
jne    115c <add_time+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11cc <add_time+0xac>
cmpl   $0x0,0x10(%rbp)
jle    119a <add_time+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <add_dt@plt>
mov    %eax,-0x4(%rbp)
jmp    11cc <add_time+0xac>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
xor    %r10d,%r10d
sub    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <sub_dt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_time>:
push   %rax
mov    0x10(%rsp),%eax
test   %eax,%eax
je     1131 <add_time+0x11>
jle    1135 <add_time+0x15>
pop    %rax
jmp    1040 <add_dt@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x18(%rsp),%r10d
neg    %eax
push   %r10
push   %rax
call   1030 <sub_dt@plt>
add    $0x10,%rsp
pop    %rcx
ret

LLVM IR (-O0):
define i32 @add_time(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i32* %0, i32** %10
store i32* %1, i32** %11
store i32* %2, i32** %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32 %6, i32* %16
store i32 %7, i32* %17
%18 = load i32, i32* %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %8
store i32 0, i32* %9
br label %45
21: ; preds = %8
%22 = load i32, i32* %16
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32*, i32** %10
%26 = load i32*, i32** %11
%27 = load i32*, i32** %12
%28 = load i32*, i32** %13
%29 = load i32*, i32** %14
%30 = load i32*, i32** %15
%31 = load i32, i32* %16
%32 = load i32, i32* %17
%33 = call i32 @add_dt(i32* %25, i32* %26, i32* %27, i32* %28, i32* %29, i32* %30, i32 %31, i32 %32)
store i32 %33, i32* %9
br label %45
34: ; preds = %21
%35 = load i32*, i32** %10
%36 = load i32*, i32** %11
%37 = load i32*, i32** %12
%38 = load i32*, i32** %13
%39 = load i32*, i32** %14
%40 = load i32*, i32** %15
%41 = load i32, i32* %16
%42 = sub nsw i32 0, %41
%43 = load i32, i32* %17
%44 = call i32 @sub_dt(i32* %35, i32* %36, i32* %37, i32* %38, i32* %39, i32* %40, i32 %42, i32 %43)
store i32 %44, i32* %9
br label %45
45: ; preds = %34, %24, %20
%46 = load i32, i32* %9
ret i32 %46
}

LLVM IR (-O2):
define i32 @add_time(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6, i32 %7) {
%9 = icmp eq i32 %6, 0
br i1 %9, label %17, label %10
10: ; preds = %8
%11 = icmp sgt i32 %6, 0
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @add_dt(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6, i32 %7)
br label %17
14: ; preds = %10
%15 = sub nsw i32 0, %6
%16 = tail call i32 @sub_dt(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %15, i32 %7)
br label %17
17: ; preds = %8, %14, %12
%18 = phi i32 [ %13, %12 ], [ %16, %14 ], [ 0, %8 ]
ret i32 %18
}