#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 mpu_write_mem(int, int, unsigned char *);
int dmp_set_interrupt_mode(unsigned char mode) {
  const unsigned char regs_continuous[11] = {0xd8, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3,
                                             0x91, 0xb6, 0x09, 0xb4, 0xd9};
  const unsigned char regs_gesture[11] = {0xda, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3,
                                          0x91, 0xb6, 0xda, 0xb4, 0xda};
  switch (mode) {
  case (0x02):
    return mpu_write_mem((2690), 11, (unsigned char *)regs_continuous);
  case (0x01):
    return mpu_write_mem((2690), 11, (unsigned char *)regs_gesture);
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<dmp_set_interrupt_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movabs $0xb691a38bf3b9b1d8,%rax
a3 91 b6
mov    %rax,-0x10(%rbp)
movl   $0xd9b409b6,-0x9(%rbp)
movabs $0xb691a38bf3b9b1da,%rax
a3 91 b6
mov    %rax,-0x20(%rbp)
movl   $0xdab4dab6,-0x19(%rbp)
movzbl -0x5(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     1189 <dmp_set_interrupt_mode+0x79>
jmp    115d <dmp_set_interrupt_mode+0x4d>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
jne    11a4 <dmp_set_interrupt_mode+0x94>
jmp    116e <dmp_set_interrupt_mode+0x5e>
lea    -0x10(%rbp),%rdx
mov    $0xa82,%edi
mov    $0xb,%esi
call   1030 <mpu_write_mem@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <dmp_set_interrupt_mode+0x9b>
lea    -0x20(%rbp),%rdx
mov    $0xa82,%edi
mov    $0xb,%esi
call   1030 <mpu_write_mem@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <dmp_set_interrupt_mode+0x9b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmp_set_interrupt_mode>:
sub    $0x28,%rsp
movabs $0xb691a38bf3b9b1d8,%rax
a3 91 b6
mov    %rax,0x18(%rsp)
movl   $0xd9b409b6,0x1f(%rsp)
d9
movabs $0xb691a38bf3b9b1da,%rax
a3 91 b6
mov    %rax,0x8(%rsp)
movl   $0xdab4dab6,0xf(%rsp)
da
cmp    $0x2,%dil
je     115a <dmp_set_interrupt_mode+0x4a>
mov    $0xffffffff,%eax
cmp    $0x1,%dil
jne    116e <dmp_set_interrupt_mode+0x5e>
lea    0x8(%rsp),%rdx
jmp    115f <dmp_set_interrupt_mode+0x4f>
lea    0x18(%rsp),%rdx
mov    $0xa82,%edi
mov    $0xb,%esi
call   1030 <mpu_write_mem@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.dmp_set_interrupt_mode.regs_continuous = [11 x i8] c"\D8\B1\B9\F3\8B\A3\91\B6\09\B4\D9"
@__const.dmp_set_interrupt_mode.regs_gesture = [11 x i8] c"\DA\B1\B9\F3\8B\A3\91\B6\DA\B4\DA"
define i32 @dmp_set_interrupt_mode(i8 zeroext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca [11 x i8]
%5 = alloca [11 x i8]
store i8 %0, i8* %3
%6 = bitcast [11 x i8]* %4 to i8*
%7 = bitcast [11 x i8]* %5 to i8*
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
switch i32 %9, label %16 [
i32 2, label %10
i32 1, label %13
]
10: ; preds = %1
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%12 = call i32 @mpu_write_mem(i32 2690, i32 11, i8* %11)
store i32 %12, i32* %2
br label %17
13: ; preds = %1
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%15 = call i32 @mpu_write_mem(i32 2690, i32 11, i8* %14)
store i32 %15, i32* %2
br label %17
16: ; preds = %1
store i32 -1, i32* %2
br label %17
17: ; preds = %16, %13, %10
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@__const.dmp_set_interrupt_mode.regs_continuous = [11 x i8] c"\D8\B1\B9\F3\8B\A3\91\B6\09\B4\D9"
@__const.dmp_set_interrupt_mode.regs_gesture = [11 x i8] c"\DA\B1\B9\F3\8B\A3\91\B6\DA\B4\DA"
define i32 @dmp_set_interrupt_mode(i8 zeroext %0) {
%2 = alloca [11 x i8]
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
switch i8 %0, label %10 [
i8 2, label %7
i8 1, label %6
]
6: ; preds = %1
br label %7
7: ; preds = %1, %6
%8 = phi i8* [ %5, %6 ], [ %4, %1 ]
%9 = call i32 @mpu_write_mem(i32 2690, i32 11, i8* %8)
br label %10
10: ; preds = %7, %1
%11 = phi i32 [ -1, %1 ], [ %9, %7 ]
ret i32 %11
}