#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 /*<<< orphan*/ uart_puts(char *);
void change_rtc_day(int value) {
  if (!(value >= 1 && value <= 7)) {
    uart_puts("\nError: Day must between 1 to 31!");
    return;
  }
  (*(volatile unsigned int *)(0x7E005040)) |= (1 << 3);
  (*(volatile unsigned int *)(0x7E005040)) = 1;
  (*(volatile unsigned int *)(0x7E005080)) = value;
  (*(volatile unsigned int *)(0x7E005040)) = 0;
  return;
}


x86 assembly (clang, -O0):
<change_rtc_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     112f <change_rtc_day+0x1f>
cmpl   $0x7,-0x4(%rbp)
jle    1140 <change_rtc_day+0x30>
lea    0xeca(%rip),%rdi
call   1030 <uart_puts@plt>
jmp    1171 <change_rtc_day+0x61>
mov    $0x7e005040,%eax
mov    (%rax),%ecx
or     $0x8,%ecx
mov    $0x7e005040,%eax
mov    %ecx,(%rax)
mov    $0x7e005040,%eax
movl   $0x1,(%rax)
mov    -0x4(%rbp),%ecx
mov    $0x7e005080,%eax
mov    %ecx,(%rax)
mov    $0x7e005040,%eax
movl   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_rtc_day>:
lea    -0x1(%rdi),%eax
cmp    $0x7,%eax
jae    113e <change_rtc_day+0x2e>
orl    $0x8,0x7e005040
08
movl   $0x1,0x7e005040
mov    %edi,0x7e005080
movl   $0x0,0x7e005040
ret
lea    0xebb(%rip),%rdi
jmp    1030 <uart_puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"\0AError: Day must between 1 to 31!\00"
define void @change_rtc_day(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 1
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 7
br i1 %7, label %10, label %8
8: ; preds = %5, %1
%9 = call i32 @uart_puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %14
10: ; preds = %5
%11 = load volatile i32, i32* inttoptr (i64 2113949760 to i32*)
%12 = or i32 %11, 8
store volatile i32 %12, i32* inttoptr (i64 2113949760 to i32*)
store volatile i32 1, i32* inttoptr (i64 2113949760 to i32*)
%13 = load i32, i32* %2
store volatile i32 %13, i32* inttoptr (i64 2113949824 to i32*)
store volatile i32 0, i32* inttoptr (i64 2113949760 to i32*)
br label %14
14: ; preds = %10, %8
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0AError: Day must between 1 to 31!\00"
define void @change_rtc_day(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 7
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @uart_puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %9
6: ; preds = %1
%7 = load volatile i32, i32* inttoptr (i64 2113949760 to i32*)
%8 = or i32 %7, 8
store volatile i32 %8, i32* inttoptr (i64 2113949760 to i32*)
store volatile i32 1, i32* inttoptr (i64 2113949760 to i32*)
store volatile i32 %0, i32* inttoptr (i64 2113949824 to i32*)
store volatile i32 0, i32* inttoptr (i64 2113949760 to i32*)
br label %9
9: ; preds = %6, %4
ret void
}