#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*/ Delay_ms(int);
int /*<<< orphan*/ MPU_I2C_Read(int, int, int, unsigned char *);
int /*<<< orphan*/ MPU_I2C_Write(int, int, int, unsigned char *);
int /*<<< orphan*/ UART2_write_text(char *);
int /*<<< orphan*/ delay_ms(int);
void Config_BNO55() {
  unsigned char dat;
  int i;
  dat = 0x00;
  MPU_I2C_Write(0x28, 0x3D, 1, &dat);
  delay_ms(50);
  dat = 0x01;
  MPU_I2C_Write(0x28, 0x07, 1, &dat);
  dat = 0b00001101;
  MPU_I2C_Write(0x28, 0x08, 1, &dat);
  dat = 0b00011000;
  MPU_I2C_Write(0x28, 0x0A, 1, &dat);
  dat = 0x00;
  MPU_I2C_Write(0x28, 0x0B, 1, &dat);
  dat = 0b000110;
  MPU_I2C_Write(0x28, 0x09, 1, &dat);
  dat = 0x00;
  MPU_I2C_Write(0x28, 0x07, 1, &dat);
  dat = 0x01;
  MPU_I2C_Write(0x28, 0x3B, 1, &dat);
  dat = 0x01;
  MPU_I2C_Write(0x28, 0x40, 1, &dat);
  dat = 0x00;
  MPU_I2C_Write(0x28, 0x3E, 1, &dat);
  for (i = 0; i <= 5; i++) {
    dat = 0b0000001100;
    MPU_I2C_Write(0x28, 0x3D, 1, &dat);
    Delay_ms(50);
    MPU_I2C_Read(0x28, 0x3D, 1, &dat);
    if (dat == 0b0000001100) {
      UART2_write_text("Configuration succes\x0D\x0D");
      return;
    }
  }
  UART2_write_text("Configuration ERROR\x0D");
}


x86 assembly (clang, -O0):
<Config_BNO55>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1060 <delay_ms@plt>
movb   $0x1,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x7,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0xd,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x8,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x18,-0x1(%rbp)
mov    $0x28,%edi
mov    $0xa,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x0,-0x1(%rbp)
mov    $0x28,%edi
mov    $0xb,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x6,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x9,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x0,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x7,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x1,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x3b,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x1,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x40,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x0,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x3e,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     12fa <Config_BNO55+0x1aa>
movb   $0xc,-0x1(%rbp)
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
lea    -0x1(%rbp),%rcx
call   1050 <MPU_I2C_Read@plt>
movzbl -0x1(%rbp),%eax
cmp    $0xc,%eax
jne    12e7 <Config_BNO55+0x197>
lea    0xd23(%rip),%rdi
call   1040 <UART2_write_text@plt>
jmp    1306 <Config_BNO55+0x1b6>
jmp    12ec <Config_BNO55+0x19c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1281 <Config_BNO55+0x131>
lea    0xd16(%rip),%rdi
call   1040 <UART2_write_text@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Config_BNO55>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xf(%rsp)
lea    0xf(%rsp),%rbx
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1060 <delay_ms@plt>
movb   $0x1,0xf(%rsp)
mov    $0x28,%edi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0xd,0xf(%rsp)
mov    $0x28,%edi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x18,0xf(%rsp)
mov    $0x28,%edi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x0,0xf(%rsp)
mov    $0x28,%edi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x6,0xf(%rsp)
mov    $0x28,%edi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x0,0xf(%rsp)
mov    $0x28,%edi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x1,0xf(%rsp)
mov    $0x28,%edi
mov    $0x3b,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x1,0xf(%rsp)
mov    $0x28,%edi
mov    $0x40,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0x0,0xf(%rsp)
mov    $0x28,%edi
mov    $0x3e,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
movb   $0xc,0xf(%rsp)
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <MPU_I2C_Read@plt>
cmpb   $0xc,0xf(%rsp)
je     143d <Config_BNO55+0x2ed>
movb   $0xc,0xf(%rsp)
lea    0xf(%rsp),%rbx
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <MPU_I2C_Read@plt>
cmpb   $0xc,0xf(%rsp)
je     143d <Config_BNO55+0x2ed>
movb   $0xc,0xf(%rsp)
lea    0xf(%rsp),%rbx
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <MPU_I2C_Read@plt>
cmpb   $0xc,0xf(%rsp)
je     143d <Config_BNO55+0x2ed>
movb   $0xc,0xf(%rsp)
lea    0xf(%rsp),%rbx
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <MPU_I2C_Read@plt>
cmpb   $0xc,0xf(%rsp)
je     143d <Config_BNO55+0x2ed>
movb   $0xc,0xf(%rsp)
lea    0xf(%rsp),%rbx
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <MPU_I2C_Read@plt>
cmpb   $0xc,0xf(%rsp)
je     143d <Config_BNO55+0x2ed>
movb   $0xc,0xf(%rsp)
lea    0xf(%rsp),%rbx
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MPU_I2C_Write@plt>
mov    $0x32,%edi
call   1070 <Delay_ms@plt>
mov    $0x28,%edi
mov    $0x3d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <MPU_I2C_Read@plt>
cmpb   $0xc,0xf(%rsp)
jne    144f <Config_BNO55+0x2ff>
lea    0xbbc(%rip),%rdi
call   1040 <UART2_write_text@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xbc1(%rip),%rdi
jmp    1444 <Config_BNO55+0x2f4>

LLVM IR (-O0):
@.str = [23 x i8] c"Configuration succes\0D\0D\00"
@.str.1 = [21 x i8] c"Configuration ERROR\0D\00"
define void @Config_BNO55() {
%1 = alloca i8
%2 = alloca i32
store i8 0, i8* %1
%3 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%4 = call i32 @delay_ms(i32 50)
store i8 1, i8* %1
%5 = call i32 @MPU_I2C_Write(i32 40, i32 7, i32 1, i8* %1)
store i8 13, i8* %1
%6 = call i32 @MPU_I2C_Write(i32 40, i32 8, i32 1, i8* %1)
store i8 24, i8* %1
%7 = call i32 @MPU_I2C_Write(i32 40, i32 10, i32 1, i8* %1)
store i8 0, i8* %1
%8 = call i32 @MPU_I2C_Write(i32 40, i32 11, i32 1, i8* %1)
store i8 6, i8* %1
%9 = call i32 @MPU_I2C_Write(i32 40, i32 9, i32 1, i8* %1)
store i8 0, i8* %1
%10 = call i32 @MPU_I2C_Write(i32 40, i32 7, i32 1, i8* %1)
store i8 1, i8* %1
%11 = call i32 @MPU_I2C_Write(i32 40, i32 59, i32 1, i8* %1)
store i8 1, i8* %1
%12 = call i32 @MPU_I2C_Write(i32 40, i32 64, i32 1, i8* %1)
store i8 0, i8* %1
%13 = call i32 @MPU_I2C_Write(i32 40, i32 62, i32 1, i8* %1)
store i32 0, i32* %2
br label %14
14: ; preds = %27, %0
%15 = load i32, i32* %2
%16 = icmp sle i32 %15, 5
br i1 %16, label %17, label %30
17: ; preds = %14
store i8 12, i8* %1
%18 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%19 = call i32 @Delay_ms(i32 50)
%20 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%21 = load i8, i8* %1
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 12
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 @UART2_write_text(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %32
26: ; preds = %17
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %14
30: ; preds = %14
%31 = call i32 @UART2_write_text(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Configuration succes\0D\0D\00"
@.str.1 = [21 x i8] c"Configuration ERROR\0D\00"
define void @Config_BNO55() {
%1 = alloca i8
store i8 0, i8* %1
%2 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%3 = call i32 @delay_ms(i32 50)
store i8 1, i8* %1
%4 = call i32 @MPU_I2C_Write(i32 40, i32 7, i32 1, i8* %1)
store i8 13, i8* %1
%5 = call i32 @MPU_I2C_Write(i32 40, i32 8, i32 1, i8* %1)
store i8 24, i8* %1
%6 = call i32 @MPU_I2C_Write(i32 40, i32 10, i32 1, i8* %1)
store i8 0, i8* %1
%7 = call i32 @MPU_I2C_Write(i32 40, i32 11, i32 1, i8* %1)
store i8 6, i8* %1
%8 = call i32 @MPU_I2C_Write(i32 40, i32 9, i32 1, i8* %1)
store i8 0, i8* %1
%9 = call i32 @MPU_I2C_Write(i32 40, i32 7, i32 1, i8* %1)
store i8 1, i8* %1
%10 = call i32 @MPU_I2C_Write(i32 40, i32 59, i32 1, i8* %1)
store i8 1, i8* %1
%11 = call i32 @MPU_I2C_Write(i32 40, i32 64, i32 1, i8* %1)
store i8 0, i8* %1
%12 = call i32 @MPU_I2C_Write(i32 40, i32 62, i32 1, i8* %1)
store i8 12, i8* %1
%13 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%14 = call i32 @Delay_ms(i32 50)
%15 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%16 = load i8, i8* %1
%17 = icmp eq i8 %16, 12
br i1 %17, label %48, label %18
18: ; preds = %0
store i8 12, i8* %1
%19 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%20 = call i32 @Delay_ms(i32 50)
%21 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%22 = load i8, i8* %1
%23 = icmp eq i8 %22, 12
br i1 %23, label %48, label %24
24: ; preds = %18
store i8 12, i8* %1
%25 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%26 = call i32 @Delay_ms(i32 50)
%27 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%28 = load i8, i8* %1
%29 = icmp eq i8 %28, 12
br i1 %29, label %48, label %30
30: ; preds = %24
store i8 12, i8* %1
%31 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%32 = call i32 @Delay_ms(i32 50)
%33 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%34 = load i8, i8* %1
%35 = icmp eq i8 %34, 12
br i1 %35, label %48, label %36
36: ; preds = %30
store i8 12, i8* %1
%37 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%38 = call i32 @Delay_ms(i32 50)
%39 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%40 = load i8, i8* %1
%41 = icmp eq i8 %40, 12
br i1 %41, label %48, label %42
42: ; preds = %36
store i8 12, i8* %1
%43 = call i32 @MPU_I2C_Write(i32 40, i32 61, i32 1, i8* %1)
%44 = call i32 @Delay_ms(i32 50)
%45 = call i32 @MPU_I2C_Read(i32 40, i32 61, i32 1, i8* %1)
%46 = load i8, i8* %1
%47 = icmp eq i8 %46, 12
br i1 %47, label %48, label %49
48: ; preds = %42, %36, %30, %24, %18, %0
br label %49
49: ; preds = %42, %48
%50 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %48 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %42 ]
%51 = call i32 @UART2_write_text(i8* %50)
ret void
}