#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 long uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fd_log_at(char *, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int, unsigned int);
void fdFaultGetRegistersFromStack(uint32_t *pulFaultStackAddress) {
  volatile uint32_t __attribute__((unused)) r0;
  volatile uint32_t __attribute__((unused)) r1;
  volatile uint32_t __attribute__((unused)) r2;
  volatile uint32_t __attribute__((unused)) r3;
  volatile uint32_t __attribute__((unused)) r12;
  volatile uint32_t lr;
  volatile uint32_t pc;
  volatile uint32_t __attribute__((unused)) psr;
  r0 = pulFaultStackAddress[0];
  r1 = pulFaultStackAddress[1];
  r2 = pulFaultStackAddress[2];
  r3 = pulFaultStackAddress[3];
  r12 = pulFaultStackAddress[4];
  lr = pulFaultStackAddress[5];
  pc = pulFaultStackAddress[6];
  psr = pulFaultStackAddress[7];
  uint32_t __attribute__((unused)) CFSR =
      (*((volatile unsigned long *)(0xE000ED28)));
  uint32_t __attribute__((unused)) HFSR =
      (*((volatile unsigned long *)(0xE000ED2C)));
  uint32_t __attribute__((unused)) DFSR =
      (*((volatile unsigned long *)(0xE000ED30)));
  uint32_t __attribute__((unused)) AFSR =
      (*((volatile unsigned long *)(0xE000ED3C)));
  uint32_t __attribute__((unused)) MMAR =
      (*((volatile unsigned long *)(0xE000ED34)));
  uint32_t __attribute__((unused)) BFAR =
      (*((volatile unsigned long *)(0xE000ED38)));
  char buffer[80];
  sprintf(buffer, "pc=%x lr=%x", (unsigned int)pc, (unsigned int)lr);
  fd_log_at("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/denisbohm/firefly-ice-firmware/refs/"
            "heads/master/src/fd_fault.c",
            77, buffer);
  while (true)
    ;
}


x86 assembly (clang, -O0):
<fdFaultGetRegistersFromStack>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    0x38(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    $0xe000ed28,%eax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    $0xe000ed2c,%eax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    $0xe000ed30,%eax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    $0xe000ed3c,%eax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    $0xe000ed34,%eax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    $0xe000ed38,%eax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
lea    0xe10(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0xd0(%rbp),%rdx
lea    0xe09(%rip),%rdi
mov    $0x4d,%esi
call   1030 <fd_log_at@plt>
jmp    120d <fdFaultGetRegistersFromStack+0xed>

x86 assembly (clang, -O2):
<fdFaultGetRegistersFromStack>:
push   %rbx
sub    $0x90,%rsp
mov    (%rdi),%rax
mov    %rax,0x38(%rsp)
mov    0x8(%rdi),%rax
mov    %rax,0x30(%rsp)
mov    0x10(%rdi),%rax
mov    %rax,0x28(%rsp)
mov    0x18(%rdi),%rax
mov    %rax,0x20(%rsp)
mov    0x20(%rdi),%rax
mov    %rax,0x18(%rsp)
mov    0x28(%rdi),%rax
mov    %rax,0x8(%rsp)
mov    0x30(%rdi),%rax
mov    %rax,(%rsp)
mov    0x38(%rdi),%rax
mov    %rax,0x10(%rsp)
mov    $0xe000ed28,%eax
mov    (%rax),%rcx
mov    0x4(%rax),%rcx
mov    0x8(%rax),%rcx
mov    0x14(%rax),%rcx
mov    0xc(%rax),%rcx
mov    0x10(%rax),%rax
mov    (%rsp),%rdx
mov    0x8(%rsp),%rcx
lea    0xe66(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
lea    0xe5e(%rip),%rdi
mov    $0x4d,%esi
mov    %rbx,%rdx
call   1030 <fd_log_at@plt>
nopl   0x0(%rax,%rax,1)
jmp    11c0 <fdFaultGetRegistersFromStack+0xa0>

LLVM IR (-O0):
@.str = [12 x i8] c"pc=%x lr=%x\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/denisbohm/firefly-ice-firmware/refs/heads/master/src/fd_fault.c\00"
define void @fdFaultGetRegistersFromStack(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca [80 x i8]
store i64* %0, i64** %2
%18 = load i64*, i64** %2
%19 = getelementptr inbounds i64, i64* %18, i64 0
%20 = load i64, i64* %19
store volatile i64 %20, i64* %3
%21 = load i64*, i64** %2
%22 = getelementptr inbounds i64, i64* %21, i64 1
%23 = load i64, i64* %22
store volatile i64 %23, i64* %4
%24 = load i64*, i64** %2
%25 = getelementptr inbounds i64, i64* %24, i64 2
%26 = load i64, i64* %25
store volatile i64 %26, i64* %5
%27 = load i64*, i64** %2
%28 = getelementptr inbounds i64, i64* %27, i64 3
%29 = load i64, i64* %28
store volatile i64 %29, i64* %6
%30 = load i64*, i64** %2
%31 = getelementptr inbounds i64, i64* %30, i64 4
%32 = load i64, i64* %31
store volatile i64 %32, i64* %7
%33 = load i64*, i64** %2
%34 = getelementptr inbounds i64, i64* %33, i64 5
%35 = load i64, i64* %34
store volatile i64 %35, i64* %8
%36 = load i64*, i64** %2
%37 = getelementptr inbounds i64, i64* %36, i64 6
%38 = load i64, i64* %37
store volatile i64 %38, i64* %9
%39 = load i64*, i64** %2
%40 = getelementptr inbounds i64, i64* %39, i64 7
%41 = load i64, i64* %40
store volatile i64 %41, i64* %10
%42 = load volatile i64, i64* inttoptr (i64 3758157096 to i64*)
store i64 %42, i64* %11
%43 = load volatile i64, i64* inttoptr (i64 3758157100 to i64*)
store i64 %43, i64* %12
%44 = load volatile i64, i64* inttoptr (i64 3758157104 to i64*)
store i64 %44, i64* %13
%45 = load volatile i64, i64* inttoptr (i64 3758157116 to i64*)
store i64 %45, i64* %14
%46 = load volatile i64, i64* inttoptr (i64 3758157108 to i64*)
store i64 %46, i64* %15
%47 = load volatile i64, i64* inttoptr (i64 3758157112 to i64*)
store i64 %47, i64* %16
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%49 = load volatile i64, i64* %9
%50 = trunc i64 %49 to i32
%51 = load volatile i64, i64* %8
%52 = trunc i64 %51 to i32
%53 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %50, i32 %52)
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%55 = call i32 @fd_log_at(i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 77, i8* %54)
br label %56
56: ; preds = %1, %56
br label %56
}

LLVM IR (-O2):
@.str = [12 x i8] c"pc=%x lr=%x\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/denisbohm/firefly-ice-firmware/refs/heads/master/src/fd_fault.c\00"
define void @fdFaultGetRegistersFromStack(i64* nocapture %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca [80 x i8]
%11 = bitcast i64* %2 to i8*
%12 = bitcast i64* %3 to i8*
%13 = bitcast i64* %4 to i8*
%14 = bitcast i64* %5 to i8*
%15 = bitcast i64* %6 to i8*
%16 = bitcast i64* %7 to i8*
%17 = bitcast i64* %8 to i8*
%18 = bitcast i64* %9 to i8*
%19 = load i64, i64* %0
store volatile i64 %19, i64* %2
%20 = getelementptr inbounds i64, i64* %0, i64 1
%21 = load i64, i64* %20
store volatile i64 %21, i64* %3
%22 = getelementptr inbounds i64, i64* %0, i64 2
%23 = load i64, i64* %22
store volatile i64 %23, i64* %4
%24 = getelementptr inbounds i64, i64* %0, i64 3
%25 = load i64, i64* %24
store volatile i64 %25, i64* %5
%26 = getelementptr inbounds i64, i64* %0, i64 4
%27 = load i64, i64* %26
store volatile i64 %27, i64* %6
%28 = getelementptr inbounds i64, i64* %0, i64 5
%29 = load i64, i64* %28
store volatile i64 %29, i64* %7
%30 = getelementptr inbounds i64, i64* %0, i64 6
%31 = load i64, i64* %30
store volatile i64 %31, i64* %8
%32 = getelementptr inbounds i64, i64* %0, i64 7
%33 = load i64, i64* %32
store volatile i64 %33, i64* %9
%34 = load volatile i64, i64* inttoptr (i64 3758157096 to i64*)
%35 = load volatile i64, i64* inttoptr (i64 3758157100 to i64*)
%36 = load volatile i64, i64* inttoptr (i64 3758157104 to i64*)
%37 = load volatile i64, i64* inttoptr (i64 3758157116 to i64*)
%38 = load volatile i64, i64* inttoptr (i64 3758157108 to i64*)
%39 = load volatile i64, i64* inttoptr (i64 3758157112 to i64*)
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%41 = load volatile i64, i64* %8
%42 = trunc i64 %41 to i32
%43 = load volatile i64, i64* %7
%44 = trunc i64 %43 to i32
%45 = call i32 @sprintf(i8* %40, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %42, i32 %44)
%46 = call i32 @fd_log_at(i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 77, i8* %40)
br label %47
47: ; preds = %47, %1
br label %47
}