#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 ADC_dato();
int /*<<< orphan*/ outNum(int, int, int);
int /*<<< orphan*/ output(char *);
void ADC_test(long int datoDAC) {
  int datoLeido = 0, errorAbs = 0, errorRelat = 0;
  datoLeido = ADC_dato();
  datoLeido *= 2;
  output(" ");
  outNum(10, (long)datoLeido, 1);
  output("\t ");
  outNum(10, (long)datoDAC, 1);
  output("\t  ");
  if (datoDAC > datoLeido)
    errorAbs = datoDAC - datoLeido;
  else
    errorAbs = datoLeido - datoDAC;
  outNum(10, errorAbs, 1);
  output("\t\t  ");
  if (datoDAC > 0)
    errorRelat = (100 * errorAbs) / datoDAC;
  else if (datoLeido > 0)
    errorRelat = (100 * errorAbs) / datoLeido;
  else
    errorRelat = 100;
  outNum(10, errorRelat, 1);
  output("%\n");
}


x86 assembly (clang, -O0):
<ADC_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <ADC_dato@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe96(%rip),%rdi
call   1040 <output@plt>
movslq -0xc(%rbp),%rax
mov    %eax,%esi
mov    $0xa,%edi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xe74(%rip),%rdi
call   1040 <output@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
mov    $0xa,%edi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xe57(%rip),%rdi
call   1040 <output@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jle    11d6 <ADC_test+0xa6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x10(%rbp)
jmp    11e1 <ADC_test+0xb1>
movslq -0xc(%rbp),%rax
sub    -0x8(%rbp),%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    $0xa,%edi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xe09(%rip),%rdi
call   1040 <output@plt>
cmpq   $0x0,-0x8(%rbp)
jle    121e <ADC_test+0xee>
imul   $0x64,-0x10(%rbp),%eax
cltq
cqto
idivq  -0x8(%rbp)
mov    %eax,-0x14(%rbp)
jmp    1244 <ADC_test+0x114>
cmpl   $0x0,-0xc(%rbp)
jle    1238 <ADC_test+0x108>
imul   $0x64,-0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x14(%rbp)
jmp    123f <ADC_test+0x10f>
movl   $0x64,-0x14(%rbp)
jmp    1244 <ADC_test+0x114>
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xdab(%rip),%rdi
call   1040 <output@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADC_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1050 <ADC_dato@plt>
mov    %eax,%r14d
lea    (%r14,%r14,1),%r12d
lea    0xeb1(%rip),%rdi
call   1040 <output@plt>
movslq %r12d,%rbx
mov    $0xa,%edi
mov    %ebx,%esi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xe90(%rip),%rdi
call   1040 <output@plt>
mov    $0xa,%edi
mov    %r15d,%esi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xe76(%rip),%rdi
call   1040 <output@plt>
mov    %r15d,%eax
sub    %ebx,%eax
mov    %ebx,%ebp
sub    %r15d,%ebp
cmp    %r15,%rbx
cmovl  %eax,%ebp
mov    $0xa,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xe48(%rip),%rdi
call   1040 <output@plt>
test   %r15,%r15
jle    11e4 <ADC_test+0xb4>
imul   $0x64,%ebp,%eax
movslq %eax,%rcx
mov    %rcx,%rdx
or     %r15,%rdx
shr    $0x20,%rdx
je     11f2 <ADC_test+0xc2>
mov    %rcx,%rax
cqto
idiv   %r15
mov    %rax,%rsi
jmp    1200 <ADC_test+0xd0>
test   %r14d,%r14d
jle    11fb <ADC_test+0xcb>
imul   $0x64,%ebp,%eax
cltd
idiv   %r12d
jmp    11f7 <ADC_test+0xc7>
xor    %edx,%edx
div    %r15d
mov    %eax,%esi
jmp    1200 <ADC_test+0xd0>
mov    $0x64,%esi
mov    $0xa,%edi
mov    $0x1,%edx
call   1030 <outNum@plt>
lea    0xdf2(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <output@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"\09 \00"
@.str.2 = [4 x i8] c"\09 \00"
@.str.3 = [5 x i8] c"\09\09 \00"
@.str.4 = [3 x i8] c"%\0A\00"
define void @ADC_test(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (...) @ADC_dato()
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = mul nsw i32 %7, 2
store i32 %8, i32* %3
%9 = call i32 @output(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = trunc i64 %11 to i32
%13 = call i32 @outNum(i32 10, i32 %12, i32 1)
%14 = call i32 @output(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = load i64, i64* %2
%16 = trunc i64 %15 to i32
%17 = call i32 @outNum(i32 10, i32 %16, i32 1)
%18 = call i32 @output(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = load i64, i64* %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = icmp sgt i64 %19, %21
br i1 %22, label %23, label %29
23: ; preds = %1
%24 = load i64, i64* %2
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = sub nsw i64 %24, %26
%28 = trunc i64 %27 to i32
store i32 %28, i32* %4
br label %35
29: ; preds = %1
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = load i64, i64* %2
%33 = sub nsw i64 %31, %32
%34 = trunc i64 %33 to i32
store i32 %34, i32* %4
br label %35
35: ; preds = %29, %23
%36 = load i32, i32* %4
%37 = call i32 @outNum(i32 10, i32 %36, i32 1)
%38 = call i32 @output(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = load i64, i64* %2
%40 = icmp sgt i64 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %35
%42 = load i32, i32* %4
%43 = mul nsw i32 100, %42
%44 = sext i32 %43 to i64
%45 = load i64, i64* %2
%46 = sdiv i64 %44, %45
%47 = trunc i64 %46 to i32
store i32 %47, i32* %5
br label %58
48: ; preds = %35
%49 = load i32, i32* %3
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %48
%52 = load i32, i32* %4
%53 = mul nsw i32 100, %52
%54 = load i32, i32* %3
%55 = sdiv i32 %53, %54
store i32 %55, i32* %5
br label %57
56: ; preds = %48
store i32 100, i32* %5
br label %57
57: ; preds = %56, %51
br label %58
58: ; preds = %57, %41
%59 = load i32, i32* %5
%60 = call i32 @outNum(i32 10, i32 %59, i32 1)
%61 = call i32 @output(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"\09 \00"
@.str.2 = [4 x i8] c"\09 \00"
@.str.3 = [5 x i8] c"\09\09 \00"
@.str.4 = [3 x i8] c"%\0A\00"
define void @ADC_test(i64 %0) {
%2 = tail call i32 (...) @ADC_dato()
%3 = shl nsw i32 %2, 1
%4 = tail call i32 @output(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %3 to i64
%6 = tail call i32 @outNum(i32 10, i32 %3, i32 1)
%7 = tail call i32 @output(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = trunc i64 %0 to i32
%9 = tail call i32 @outNum(i32 10, i32 %8, i32 1)
%10 = tail call i32 @output(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp slt i64 %5, %0
%12 = sub i32 %8, %3
%13 = sub i32 %3, %8
%14 = select i1 %11, i32 %12, i32 %13
%15 = tail call i32 @outNum(i32 10, i32 %14, i32 1)
%16 = tail call i32 @output(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp sgt i64 %0, 0
br i1 %17, label %18, label %23
18: ; preds = %1
%19 = mul nsw i32 %14, 100
%20 = sext i32 %19 to i64
%21 = sdiv i64 %20, %0
%22 = trunc i64 %21 to i32
br label %28
23: ; preds = %1
%24 = icmp sgt i32 %2, 0
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = mul nsw i32 %14, 100
%27 = sdiv i32 %26, %3
br label %28
28: ; preds = %23, %25, %18
%29 = phi i32 [ %22, %18 ], [ %27, %25 ], [ 100, %23 ]
%30 = tail call i32 @outNum(i32 10, i32 %29, i32 1)
%31 = tail call i32 @output(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret void
}