#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 cpsr;

/* Variables and functions */
int /*<<< orphan*/ UART0_SendData32(unsigned int);
int /*<<< orphan*/ UART0_SendString(char *);
void print_cpsr(unsigned int cpsr, char *why) {
  UART0_SendString("\n\rInterrupt Reason:");
  UART0_SendString(why);
  UART0_SendString(",\tCPSR = ");
  UART0_SendData32(cpsr);
  UART0_SendString("\n\r");
  UART0_SendString("\t[31], N, Negative:");
  UART0_SendData32((cpsr >> 31) & 0x1);
  UART0_SendString("\t[30], Z, Zero:");
  UART0_SendData32((cpsr >> 30) & 0x1);
  UART0_SendString("\t[29], C, Carry:");
  UART0_SendData32((cpsr >> 29) & 0x1);
  UART0_SendString("\t[28], V, Overflow:");
  UART0_SendData32((cpsr >> 28) & 0x1);
  UART0_SendString("\n\r\t[7], I, IRQ:");
  UART0_SendData32((cpsr >> 7) & 0x1);
  UART0_SendString("\t[6], F, FIQ:");
  UART0_SendData32((cpsr >> 6) & 0x1);
  UART0_SendString("\t[5], T, Thumb:");
  UART0_SendData32((cpsr >> 5) & 0x1);
  UART0_SendString("\t[4:0], Mode:");
  UART0_SendData32((cpsr)&0x1f);
  UART0_SendString("\n\r");
}


x86 assembly (clang, -O0):
<print_cpsr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x10(%rbp),%rdi
call   1040 <UART0_SendString@plt>
lea    0xec9(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
call   1030 <UART0_SendData32@plt>
lea    0xebf(%rip),%rdi
call   1040 <UART0_SendString@plt>
lea    0xeb6(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x1f,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xeb0(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x1e,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xea6(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x1d,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe9d(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x1c,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe97(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x7,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe8d(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x6,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe81(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
shr    $0x5,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe77(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    -0x4(%rbp),%edi
and    $0x1f,%edi
call   1030 <UART0_SendData32@plt>
lea    0xde6(%rip),%rdi
call   1040 <UART0_SendString@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cpsr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xed0(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %r14,%rdi
call   1040 <UART0_SendString@plt>
lea    0xed0(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
call   1030 <UART0_SendData32@plt>
lea    0xec7(%rip),%r14
mov    %r14,%rdi
call   1040 <UART0_SendString@plt>
lea    0xebb(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x1f,%edi
call   1030 <UART0_SendData32@plt>
lea    0xeb9(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x1e,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xeb0(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x1d,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xea8(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x1c,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xea3(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x7,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe9a(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x6,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe8f(%rip),%rdi
call   1040 <UART0_SendString@plt>
mov    %ebx,%edi
shr    $0x5,%edi
and    $0x1,%edi
call   1030 <UART0_SendData32@plt>
lea    0xe86(%rip),%rdi
call   1040 <UART0_SendString@plt>
and    $0x1f,%ebx
mov    %ebx,%edi
call   1030 <UART0_SendData32@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <UART0_SendString@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\0A\0DInterrupt Reason:\00"
@.str.1 = [10 x i8] c",\09CPSR = \00"
@.str.2 = [3 x i8] c"\0A\0D\00"
@.str.3 = [20 x i8] c"\09[31], N, Negative:\00"
@.str.4 = [16 x i8] c"\09[30], Z, Zero:\00"
@.str.5 = [17 x i8] c"\09[29], C, Carry:\00"
@.str.6 = [20 x i8] c"\09[28], V, Overflow:\00"
@.str.7 = [16 x i8] c"\0A\0D\09[7], I, IRQ:\00"
@.str.8 = [14 x i8] c"\09[6], F, FIQ:\00"
@.str.9 = [16 x i8] c"\09[5], T, Thumb:\00"
@.str.10 = [14 x i8] c"\09[4:0], Mode:\00"
define void @print_cpsr(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = call i32 @UART0_SendString(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %4
%7 = call i32 @UART0_SendString(i8* %6)
%8 = call i32 @UART0_SendString(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* %3
%10 = call i32 @UART0_SendData32(i32 %9)
%11 = call i32 @UART0_SendString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @UART0_SendString(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* %3
%14 = lshr i32 %13, 31
%15 = and i32 %14, 1
%16 = call i32 @UART0_SendData32(i32 %15)
%17 = call i32 @UART0_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* %3
%19 = lshr i32 %18, 30
%20 = and i32 %19, 1
%21 = call i32 @UART0_SendData32(i32 %20)
%22 = call i32 @UART0_SendString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = lshr i32 %23, 29
%25 = and i32 %24, 1
%26 = call i32 @UART0_SendData32(i32 %25)
%27 = call i32 @UART0_SendString(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%28 = load i32, i32* %3
%29 = lshr i32 %28, 28
%30 = and i32 %29, 1
%31 = call i32 @UART0_SendData32(i32 %30)
%32 = call i32 @UART0_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%33 = load i32, i32* %3
%34 = lshr i32 %33, 7
%35 = and i32 %34, 1
%36 = call i32 @UART0_SendData32(i32 %35)
%37 = call i32 @UART0_SendString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = lshr i32 %38, 6
%40 = and i32 %39, 1
%41 = call i32 @UART0_SendData32(i32 %40)
%42 = call i32 @UART0_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%43 = load i32, i32* %3
%44 = lshr i32 %43, 5
%45 = and i32 %44, 1
%46 = call i32 @UART0_SendData32(i32 %45)
%47 = call i32 @UART0_SendString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%48 = load i32, i32* %3
%49 = and i32 %48, 31
%50 = call i32 @UART0_SendData32(i32 %49)
%51 = call i32 @UART0_SendString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0A\0DInterrupt Reason:\00"
@.str.1 = [10 x i8] c",\09CPSR = \00"
@.str.2 = [3 x i8] c"\0A\0D\00"
@.str.3 = [20 x i8] c"\09[31], N, Negative:\00"
@.str.4 = [16 x i8] c"\09[30], Z, Zero:\00"
@.str.5 = [17 x i8] c"\09[29], C, Carry:\00"
@.str.6 = [20 x i8] c"\09[28], V, Overflow:\00"
@.str.7 = [16 x i8] c"\0A\0D\09[7], I, IRQ:\00"
@.str.8 = [14 x i8] c"\09[6], F, FIQ:\00"
@.str.9 = [16 x i8] c"\09[5], T, Thumb:\00"
@.str.10 = [14 x i8] c"\09[4:0], Mode:\00"
define void @print_cpsr(i32 %0, i8* %1) {
%3 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @UART0_SendString(i8* %1)
%5 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @UART0_SendData32(i32 %0)
%7 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%9 = lshr i32 %0, 31
%10 = tail call i32 @UART0_SendData32(i32 %9)
%11 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%12 = lshr i32 %0, 30
%13 = and i32 %12, 1
%14 = tail call i32 @UART0_SendData32(i32 %13)
%15 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%16 = lshr i32 %0, 29
%17 = and i32 %16, 1
%18 = tail call i32 @UART0_SendData32(i32 %17)
%19 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%20 = lshr i32 %0, 28
%21 = and i32 %20, 1
%22 = tail call i32 @UART0_SendData32(i32 %21)
%23 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%24 = lshr i32 %0, 7
%25 = and i32 %24, 1
%26 = tail call i32 @UART0_SendData32(i32 %25)
%27 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%28 = lshr i32 %0, 6
%29 = and i32 %28, 1
%30 = tail call i32 @UART0_SendData32(i32 %29)
%31 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%32 = lshr i32 %0, 5
%33 = and i32 %32, 1
%34 = tail call i32 @UART0_SendData32(i32 %33)
%35 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%36 = and i32 %0, 31
%37 = tail call i32 @UART0_SendData32(i32 %36)
%38 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}