int safemode_memfuses(int save, unsigned char *lfuse, unsigned char *hfuse,
                      unsigned char *efuse, unsigned char *fuse) {
  static unsigned char safemode_lfuse = 0xff;
  static unsigned char safemode_hfuse = 0xff;
  static unsigned char safemode_efuse = 0xff;
  static unsigned char safemode_fuse = 0xff;
  switch (save) {
  case 1:
    safemode_lfuse = *lfuse;
    safemode_hfuse = *hfuse;
    safemode_efuse = *efuse;
    safemode_fuse = *fuse;
    break;
  default:
    *lfuse = safemode_lfuse;
    *hfuse = safemode_hfuse;
    *efuse = safemode_efuse;
    *fuse = safemode_fuse;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<safemode_memfuses>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
jne    115d <safemode_memfuses+0x5d>
jmp    1128 <safemode_memfuses+0x28>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2eec(%rip)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ee1(%rip)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ed6(%rip)
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ecb(%rip)
jmp    118d <safemode_memfuses+0x8d>
mov    0x2ebd(%rip),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x2eb2(%rip),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    0x2ea7(%rip),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    0x2e9c(%rip),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<safemode_memfuses>:
push   %rbx
cmp    $0x1,%edi
lea    0x2f15(%rip),%rax
mov    %rax,%r10
cmove  %rsi,%r10
cmove  %rax,%rsi
lea    0x2f04(%rip),%r9
mov    %r9,%r11
cmove  %rdx,%r11
cmove  %r9,%rdx
lea    0x2ef3(%rip),%r9
mov    %r9,%rdi
cmove  %rcx,%rdi
cmove  %r9,%rcx
lea    0x2ee2(%rip),%r9
mov    %r9,%rbx
cmove  %r8,%rbx
cmove  %r9,%r8
mov    (%r10),%al
mov    %al,(%rsi)
mov    (%r11),%al
mov    %al,(%rdx)
mov    (%rdi),%al
mov    %al,(%rcx)
mov    (%rbx),%al
mov    %al,(%r8)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@safemode_memfuses.safemode_lfuse = internal global i8 -1
@safemode_memfuses.safemode_hfuse = internal global i8 -1
@safemode_memfuses.safemode_efuse = internal global i8 -1
@safemode_memfuses.safemode_fuse = internal global i8 -1
define i32 @safemode_memfuses(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load i32, i32* %6
switch i32 %11, label %21 [
i32 1, label %12
]
12: ; preds = %5
%13 = load i8*, i8** %7
%14 = load i8, i8* %13
store i8 %14, i8* @safemode_memfuses.safemode_lfuse
%15 = load i8*, i8** %8
%16 = load i8, i8* %15
store i8 %16, i8* @safemode_memfuses.safemode_hfuse
%17 = load i8*, i8** %9
%18 = load i8, i8* %17
store i8 %18, i8* @safemode_memfuses.safemode_efuse
%19 = load i8*, i8** %10
%20 = load i8, i8* %19
store i8 %20, i8* @safemode_memfuses.safemode_fuse
br label %30
21: ; preds = %5
%22 = load i8, i8* @safemode_memfuses.safemode_lfuse
%23 = load i8*, i8** %7
store i8 %22, i8* %23
%24 = load i8, i8* @safemode_memfuses.safemode_hfuse
%25 = load i8*, i8** %8
store i8 %24, i8* %25
%26 = load i8, i8* @safemode_memfuses.safemode_efuse
%27 = load i8*, i8** %9
store i8 %26, i8* %27
%28 = load i8, i8* @safemode_memfuses.safemode_fuse
%29 = load i8*, i8** %10
store i8 %28, i8* %29
br label %30
30: ; preds = %21, %12
ret i32 0
}

LLVM IR (-O2):
@safemode_memfuses.safemode_lfuse = internal unnamed_addr global i8 -1
@safemode_memfuses.safemode_hfuse = internal unnamed_addr global i8 -1
@safemode_memfuses.safemode_efuse = internal unnamed_addr global i8 -1
@safemode_memfuses.safemode_fuse = internal unnamed_addr global i8 -1
define i32 @safemode_memfuses(i32 %0, i8* nocapture %1, i8* nocapture %2, i8* nocapture %3, i8* nocapture %4) {
%6 = icmp eq i32 %0, 1
%7 = select i1 %6, i8* %1, i8* @safemode_memfuses.safemode_lfuse
%8 = select i1 %6, i8* @safemode_memfuses.safemode_lfuse, i8* %1
%9 = select i1 %6, i8* %2, i8* @safemode_memfuses.safemode_hfuse
%10 = select i1 %6, i8* @safemode_memfuses.safemode_hfuse, i8* %2
%11 = select i1 %6, i8* %3, i8* @safemode_memfuses.safemode_efuse
%12 = select i1 %6, i8* @safemode_memfuses.safemode_efuse, i8* %3
%13 = select i1 %6, i8* %4, i8* @safemode_memfuses.safemode_fuse
%14 = select i1 %6, i8* @safemode_memfuses.safemode_fuse, i8* %4
%15 = load i8, i8* %7
store i8 %15, i8* %8
%16 = load i8, i8* %9
store i8 %16, i8* %10
%17 = load i8, i8* %11
store i8 %17, i8* %12
%18 = load i8, i8* %13
store i8 %18, i8* %14
ret i32 0
}