#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 */
struct rtc_wkalrm {
  int dummy;
};
struct rtc_time {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ RTC_SET_TIME;
void *atoi(char *);
int ioctl(int, int /*<<< orphan*/, struct rtc_time *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
void setup_time(int fd) {
  int i, retval;
  unsigned long tmp, data;
  struct rtc_time rtc_tm;
  int scale_type = 1;
  struct rtc_wkalrm rtc_alarmtm;
  int ret;
  static char year[4], month[4], day[4], hour[4], min[4], sec[4];
  printf("Input the adjust time:\n");
  printf("You should input 6 words,and must be 'enter' per word!\n");
  printf("->year->month->day->hour->min->sec\n");
  scanf("%s", year);
  rtc_tm.tm_year = atoi(year) - 1900;
  scanf("%s", month);
  scanf("%s", day);
  scanf("%s", hour);
  scanf("%s", min);
  scanf("%s", sec);
  rtc_tm.tm_mon = atoi(month) - 1;
  rtc_tm.tm_mday = atoi(day);
  rtc_tm.tm_hour = atoi(hour);
  rtc_tm.tm_min = atoi(min);
  rtc_tm.tm_sec = atoi(sec);
  retval = ioctl(fd, RTC_SET_TIME, &rtc_tm);
  if (retval < 0) {
    printf("ioctl RTC_SET_TIME  faild!!!\n");
    return;
  }
  printf("Adjust current RTC time as: %04d-%02d-%02d %02d:%02d:%02d\n\n",
         rtc_tm.tm_year + 1900, rtc_tm.tm_mon + 1, rtc_tm.tm_mday,
         rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
  printf("Adjust current RTC time test OK!\n");
}


x86 assembly (clang, -O0):
<setup_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    0x2eba(%rip),%rsi
call   1050 <scanf@plt>
lea    0x2eae(%rip),%rdi
call   1060 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %eax,-0x38(%rbp)
lea    0xec9(%rip),%rdi
lea    0x2e96(%rip),%rsi
call   1050 <scanf@plt>
lea    0xeb6(%rip),%rdi
lea    0x2e87(%rip),%rsi
call   1050 <scanf@plt>
lea    0xea3(%rip),%rdi
lea    0x2e78(%rip),%rsi
call   1050 <scanf@plt>
lea    0xe90(%rip),%rdi
lea    0x2e69(%rip),%rsi
call   1050 <scanf@plt>
lea    0xe7d(%rip),%rdi
lea    0x2e5a(%rip),%rsi
call   1050 <scanf@plt>
lea    0x2e3e(%rip),%rdi
call   1060 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %eax,-0x34(%rbp)
lea    0x2e2f(%rip),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x30(%rbp)
lea    0x2e24(%rip),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x2c(%rbp)
lea    0x2e19(%rip),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x28(%rbp)
lea    0x2e0e(%rip),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1287 <setup_time+0x147>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c3 <setup_time+0x183>
mov    -0x38(%rbp),%esi
add    $0x76c,%esi
mov    -0x34(%rbp),%edx
add    $0x1,%edx
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x24(%rbp),%eax
lea    0xdea(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,0x24(%rsp)
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%rbx
lea    0x2eb8(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    %rbp,%rdi
call   1070 <atoi@plt>
add    $0xfffff894,%eax
mov    %eax,0x8(%rsp)
lea    0x2e99(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0x2e8b(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
lea    0x2e7d(%rip),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
lea    0x2e6f(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
lea    0x2e61(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1070 <atoi@plt>
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
call   1070 <atoi@plt>
mov    %eax,0x10(%rsp)
mov    %r13,%rdi
call   1070 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    %r12,%rdi
call   1070 <atoi@plt>
mov    %eax,0x18(%rsp)
mov    %r15,%rdi
call   1070 <atoi@plt>
mov    %eax,0x1c(%rsp)
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    0x24(%rsp),%edi
call   1050 <ioctl@plt>
test   %eax,%eax
js     12a0 <setup_time+0x150>
mov    $0x76c,%esi
add    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
add    $0x1,%edx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
mov    0x1c(%rsp),%eax
mov    %eax,(%rsp)
lea    0xd73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe12(%rip),%rdi
jmp    12a7 <setup_time+0x157>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rtc_time = type { i32, i32, i32, i32, i32, i32 }
%struct.rtc_wkalrm = type { i32 }
@setup_time.year = internal global [4 x i8] zeroinitializer
@setup_time.month = internal global [4 x i8] zeroinitializer
@setup_time.day = internal global [4 x i8] zeroinitializer
@setup_time.hour = internal global [4 x i8] zeroinitializer
@setup_time.min = internal global [4 x i8] zeroinitializer
@setup_time.sec = internal global [4 x i8] zeroinitializer
@.str = [24 x i8] c"Input the adjust time:\0A\00"
@.str.1 = [56 x i8] c"You should input 6 words,and must be 'enter' per word!\0A\00"
@.str.2 = [36 x i8] c"->year->month->day->hour->min->sec\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@RTC_SET_TIME = global i32 0
@.str.4 = [30 x i8] c"ioctl RTC_SET_TIME faild!!!\0A\00"
@.str.5 = [60 x i8] c"Adjust current RTC time as: %04d-%02d-%02d %02d:%02d:%02d\0A\0A\00"
@.str.6 = [34 x i8] c"Adjust current RTC time test OK!\0A\00"
define void @setup_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca %struct.rtc_time
%8 = alloca i32
%9 = alloca %struct.rtc_wkalrm
%10 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.year, i64 0, i64 0))
%15 = call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.year, i64 0, i64 0))
%16 = getelementptr i8, i8* %15, i64 -1900
%17 = ptrtoint i8* %16 to i32
%18 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 0
store i32 %17, i32* %18
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.month, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.day, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.hour, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.min, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.sec, i64 0, i64 0))
%24 = call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.month, i64 0, i64 0))
%25 = getelementptr i8, i8* %24, i64 -1
%26 = ptrtoint i8* %25 to i32
%27 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 1
store i32 %26, i32* %27
%28 = call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.day, i64 0, i64 0))
%29 = ptrtoint i8* %28 to i32
%30 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 2
store i32 %29, i32* %30
%31 = call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.hour, i64 0, i64 0))
%32 = ptrtoint i8* %31 to i32
%33 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 3
store i32 %32, i32* %33
%34 = call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.min, i64 0, i64 0))
%35 = ptrtoint i8* %34 to i32
%36 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 4
store i32 %35, i32* %36
%37 = call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.sec, i64 0, i64 0))
%38 = ptrtoint i8* %37 to i32
%39 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 5
store i32 %38, i32* %39
%40 = load i32, i32* %2
%41 = load i32, i32* @RTC_SET_TIME
%42 = call i32 @ioctl(i32 %40, i32 %41, %struct.rtc_time* %7)
store i32 %42, i32* %4
%43 = load i32, i32* %4
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %1
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %64
47: ; preds = %1
%48 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 0
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1900
%51 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 1
%52 = load i32, i32* %51
%53 = add nsw i32 %52, 1
%54 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 2
%55 = load i32, i32* %54
%56 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 3
%57 = load i32, i32* %56
%58 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 4
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %7, i32 0, i32 5
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), i32 %50, i32 %53, i32 %55, i32 %57, i32 %59, i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %64
64: ; preds = %47, %45
ret void
}

LLVM IR (-O2):
%struct.rtc_time = type { i32, i32, i32, i32, i32, i32 }
@setup_time.year = internal global [4 x i8] zeroinitializer
@setup_time.month = internal global [4 x i8] zeroinitializer
@setup_time.day = internal global [4 x i8] zeroinitializer
@setup_time.hour = internal global [4 x i8] zeroinitializer
@setup_time.min = internal global [4 x i8] zeroinitializer
@setup_time.sec = internal global [4 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%s\00"
@RTC_SET_TIME = global i32 0
@.str.5 = [60 x i8] c"Adjust current RTC time as: %04d-%02d-%02d %02d:%02d:%02d\0A\0A\00"
@str = [23 x i8] c"Input the adjust time:\00"
@str.7 = [55 x i8] c"You should input 6 words,and must be 'enter' per word!\00"
@str.8 = [35 x i8] c"->year->month->day->hour->min->sec\00"
@str.9 = [33 x i8] c"Adjust current RTC time test OK!\00"
@str.10 = [29 x i8] c"ioctl RTC_SET_TIME faild!!!\00"
define void @setup_time(i32 %0) {
%2 = alloca %struct.rtc_time
%3 = bitcast %struct.rtc_time* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.year, i64 0, i64 0))
%8 = tail call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.year, i64 0, i64 0))
%9 = getelementptr i8, i8* %8, i64 -1900
%10 = ptrtoint i8* %9 to i64
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 0
store i32 %11, i32* %12
%13 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.month, i64 0, i64 0))
%14 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.day, i64 0, i64 0))
%15 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.hour, i64 0, i64 0))
%16 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.min, i64 0, i64 0))
%17 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.sec, i64 0, i64 0))
%18 = tail call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.month, i64 0, i64 0))
%19 = getelementptr i8, i8* %18, i64 -1
%20 = ptrtoint i8* %19 to i64
%21 = trunc i64 %20 to i32
%22 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 1
store i32 %21, i32* %22
%23 = tail call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.day, i64 0, i64 0))
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 2
store i32 %25, i32* %26
%27 = tail call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.hour, i64 0, i64 0))
%28 = ptrtoint i8* %27 to i64
%29 = trunc i64 %28 to i32
%30 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 3
store i32 %29, i32* %30
%31 = tail call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.min, i64 0, i64 0))
%32 = ptrtoint i8* %31 to i64
%33 = trunc i64 %32 to i32
%34 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 4
store i32 %33, i32* %34
%35 = tail call i8* @atoi(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @setup_time.sec, i64 0, i64 0))
%36 = ptrtoint i8* %35 to i64
%37 = trunc i64 %36 to i32
%38 = getelementptr inbounds %struct.rtc_time, %struct.rtc_time* %2, i64 0, i32 5
store i32 %37, i32* %38
%39 = load i32, i32* @RTC_SET_TIME
%40 = call i32 @ioctl(i32 %0, i32 %39, %struct.rtc_time* %2)
%41 = icmp slt i32 %40, 0
br i1 %41, label %52, label %42
42: ; preds = %1
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1900
%45 = load i32, i32* %22
%46 = add nsw i32 %45, 1
%47 = load i32, i32* %26
%48 = load i32, i32* %30
%49 = load i32, i32* %34
%50 = load i32, i32* %38
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), i32 %44, i32 %46, i32 %47, i32 %48, i32 %49, i32 %50)
br label %52
52: ; preds = %1, %42
%53 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0), %42 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.10, i64 0, i64 0), %1 ]
%54 = call i32 @puts(i8* dereferenceable(1) %53)
ret void
}