#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 int uint8_t;

/* Variables and functions */
int decode_voltage_ncp5392p(int);
int encode_voltage_ncp5392p(int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main() {
  int v = 0;
  uint8_t encode_val;
  v = 5000;
  while (v <= 16000) {
    encode_val = encode_voltage_ncp5392p(v);
    printf("%d --> %02x | %d --> %d\n", v, encode_val, encode_val,
           decode_voltage_ncp5392p(encode_val));
    v += 125;
  }
  encode_val = encode_voltage_ncp5392p(0);
  printf("%d --> %02x | %d --> %d\n", 0, encode_val, encode_val,
         decode_voltage_ncp5392p(encode_val));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1388,-0x8(%rbp)
cmpl   $0x3e80,-0x8(%rbp)
jg     11a5 <main+0x75>
mov    -0x8(%rbp),%edi
call   1050 <encode_voltage_ncp5392p@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <decode_voltage_ncp5392p@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    %eax,%r8d
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x7d,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
xor    %edi,%edi
call   1050 <encode_voltage_ncp5392p@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <decode_voltage_ncp5392p@plt>
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    %eax,%r8d
lea    0xe2d(%rip),%rdi
xor    %esi,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x130b,%ebx
lea    0xec0(%rip),%r14
add    $0x7d,%ebx
mov    %ebx,%edi
call   1050 <encode_voltage_ncp5392p@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <decode_voltage_ncp5392p@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
call   1040 <printf@plt>
cmp    $0x3e04,%ebx
jb     1140 <main+0x10>
xor    %edi,%edi
call   1050 <encode_voltage_ncp5392p@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <decode_voltage_ncp5392p@plt>
lea    0xe7d(%rip),%rdi
xor    %esi,%esi
mov    %ebx,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%d --> %02x | %d --> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 5000, i32* %2
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 16000
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 @encode_voltage_ncp5392p(i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @decode_voltage_ncp5392p(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12, i32 %14)
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 125
store i32 %17, i32* %2
br label %4
18: ; preds = %4
%19 = call i32 @encode_voltage_ncp5392p(i32 0)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = load i32, i32* %3
%22 = load i32, i32* %3
%23 = call i32 @decode_voltage_ncp5392p(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 0, i32 %20, i32 %21, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"%d --> %02x | %d --> %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 5000, %0 ], [ %6, %1 ]
%3 = tail call i32 @encode_voltage_ncp5392p(i32 %2)
%4 = tail call i32 @decode_voltage_ncp5392p(i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 %3, i32 %4)
%6 = add nuw nsw i32 %2, 125
%7 = icmp ult i32 %2, 15876
br i1 %7, label %1, label %8
8: ; preds = %1
%9 = tail call i32 @encode_voltage_ncp5392p(i32 0)
%10 = tail call i32 @decode_voltage_ncp5392p(i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 0, i32 %9, i32 %9, i32 %10)
ret i32 0
}