#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_year;
  int tm_mon;
  int tm_hour;
  int tm_min;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_mday;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ serialCommand(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int hr20SetDateAndTime() {
  time_t rawtime;
  struct tm *ptm;
  char send_string[255];
  time(&rawtime);
  ptm = localtime(&rawtime);
  sprintf(send_string, "\rY%02x%02x%02x\r", ptm->tm_year - 100, ptm->tm_mon + 1,
          ptm->tm_mday);
  serialCommand(send_string, 0);
  sprintf(send_string, "\rH%02x%02x%02x\r", ptm->tm_hour, ptm->tm_min,
          ptm->tm_sec);
  serialCommand(send_string, 0);
  return 1;
}


x86 assembly (clang, -O0):
<hr20SetDateAndTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <time@plt>
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
sub    $0x64,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%r8d
lea    0xe76(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
call   1050 <serialCommand@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8d
lea    0xe4f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
call   1050 <serialCommand@plt>
mov    $0x1,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hr20SetDateAndTime>:
push   %r14
push   %rbx
sub    $0x118,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    (%rax),%edx
mov    0x4(%rax),%ecx
add    $0xffffff9c,%edx
add    $0x1,%ecx
mov    0x14(%rax),%r8d
lea    0xe88(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <serialCommand@plt>
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%ecx
mov    0x10(%rbx),%r8d
lea    0xe70(%rip),%rsi
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <serialCommand@plt>
mov    $0x1,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [16 x i8] c"\0DY%02x%02x%02x\0D\00"
@.str.1 = [16 x i8] c"\0DH%02x%02x%02x\0D\00"
define i32 @hr20SetDateAndTime() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca [255 x i8]
%4 = call i32 @time(i32* %1)
%5 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %5, %struct.tm** %2
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = load %struct.tm*, %struct.tm** %2
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = sub nsw i32 %9, 100
%11 = load %struct.tm*, %struct.tm** %2
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = load %struct.tm*, %struct.tm** %2
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 5
%17 = load i32, i32* %16
%18 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %14, i32 %17)
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%20 = call i32 @serialCommand(i8* %19, i32 0)
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%22 = load %struct.tm*, %struct.tm** %2
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 2
%24 = load i32, i32* %23
%25 = load %struct.tm*, %struct.tm** %2
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 3
%27 = load i32, i32* %26
%28 = load %struct.tm*, %struct.tm** %2
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 4
%30 = load i32, i32* %29
%31 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %27, i32 %30)
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%33 = call i32 @serialCommand(i8* %32, i32 0)
ret i32 1
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [16 x i8] c"\0DY%02x%02x%02x\0D\00"
@.str.1 = [16 x i8] c"\0DH%02x%02x%02x\0D\00"
define i32 @hr20SetDateAndTime() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = call i32 @time(i32* %1)
%6 = call %struct.tm* @localtime(i32* %1)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, -100
%10 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
%13 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 5
%14 = load i32, i32* %13
%15 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i32 %14)
%16 = call i32 @serialCommand(i8* %4, i32 0)
%17 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 3
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 4
%22 = load i32, i32* %21
%23 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %20, i32 %22)
%24 = call i32 @serialCommand(i8* %4, i32 0)
ret i32 1
}