#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 int8_t;

/* Variables and functions */
int abs(int);
int /*<<< orphan*/ display_fpga_7seg(int, int, int);
int /*<<< orphan*/ printf(char *, int);
extern void display_val(int8_t value) {
  if (value < -99 || value > 99) {
    printf(
        "ERROR: The current temperature %d can't be displayed on the display",
        value);
  } else {
    display_fpga_7seg(abs(value) % 10, 0, 1);
    if (value < 0) {
      display_fpga_7seg(abs(value) / 10, 0x004, 2);
    } else {
      display_fpga_7seg(abs(value) / 10, 0, 2);
    }
  }
}


x86 assembly (clang, -O0):
<display_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xffffff9d,-0x4(%rbp)
jl     114f <display_val+0x1f>
cmpl   $0x63,-0x4(%rbp)
jle    1163 <display_val+0x33>
mov    -0x4(%rbp),%esi
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
jmp    11d4 <display_val+0xa4>
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <display_fpga_7seg@plt>
cmpl   $0x0,-0x4(%rbp)
jge    11b1 <display_val+0x81>
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0x4,%esi
mov    $0x2,%edx
call   1050 <display_fpga_7seg@plt>
jmp    11cf <display_val+0x9f>
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <display_fpga_7seg@plt>
jmp    11d4 <display_val+0xa4>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_val>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    -0x64(%rbx),%eax
cmp    $0xffffff38,%eax
ja     1145 <display_val+0x25>
lea    0xec9(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
mov    %ebx,%eax
neg    %eax
cmovs  %ebx,%eax
movzbl %al,%eax
imul   $0xcd,%eax,%r14d
shr    $0xb,%r14d
lea    (%r14,%r14,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movzbl %al,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <display_fpga_7seg@plt>
mov    %r14d,%edi
test   %ebx,%ebx
js     117d <display_val+0x5d>
xor    %esi,%esi
jmp    1182 <display_val+0x62>
mov    $0x4,%esi
mov    $0x2,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <display_fpga_7seg@plt>

LLVM IR (-O0):
@.str = [69 x i8] c"ERROR:\C2\A0The current temperature %d can't be displayed on the display\00"
define void @display_val(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, -99
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 99
br i1 %7, label %8, label %11
8: ; preds = %5, %1
%9 = load i32, i32* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %29
11: ; preds = %5
%12 = load i32, i32* %2
%13 = call i32 @abs(i32 %12)
%14 = srem i32 %13, 10
%15 = call i32 @display_fpga_7seg(i32 %14, i32 0, i32 1)
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i32, i32* %2
%20 = call i32 @abs(i32 %19)
%21 = sdiv i32 %20, 10
%22 = call i32 @display_fpga_7seg(i32 %21, i32 4, i32 2)
br label %28
23: ; preds = %11
%24 = load i32, i32* %2
%25 = call i32 @abs(i32 %24)
%26 = sdiv i32 %25, 10
%27 = call i32 @display_fpga_7seg(i32 %26, i32 0, i32 2)
br label %28
28: ; preds = %23, %18
br label %29
29: ; preds = %28, %8
ret void
}

LLVM IR (-O2):
@.str = [69 x i8] c"ERROR:\C2\A0The current temperature %d can't be displayed on the display\00"
define void @display_val(i32 %0) {
%2 = add i32 %0, -100
%3 = icmp ult i32 %2, -199
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %19
6: ; preds = %1
%7 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%8 = trunc i32 %7 to i8
%9 = urem i8 %8, 10
%10 = zext i8 %9 to i32
%11 = tail call i32 @display_fpga_7seg(i32 %10, i32 0, i32 1)
%12 = icmp slt i32 %0, 0
%13 = udiv i8 %8, 10
%14 = zext i8 %13 to i32
br i1 %12, label %15, label %17
15: ; preds = %6
%16 = tail call i32 @display_fpga_7seg(i32 %14, i32 4, i32 2)
br label %19
17: ; preds = %6
%18 = tail call i32 @display_fpga_7seg(i32 %14, i32 0, i32 2)
br label %19
19: ; preds = %15, %17, %4
ret void
}