#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 log10(float);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ printf(char *, float, char *);
int /*<<< orphan*/ scanf(char *, float *);
void ex7() {
  print("\n------------------------------\n");
  float ch, ph;
  print("Informe a concentracao de ions H+:");
  scanf("%f", &ch);
  while (!(ch > 0)) {
    print("Valor invalido, tente novamente:");
    scanf("%f", &ch);
  }
  ph = -1 * log10(ch);
  printf("O pH e: %.2f (%s).\n", ph,
         ph > 7 ? "basico" : (ph == 7 ? "neutro" : "acido"));
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb5(%rip),%rdi
call   1040 <print@plt>
lea    0xeca(%rip),%rdi
call   1040 <print@plt>
lea    0xee1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
seta   %al
xor    $0xff,%al
test   $0x1,%al
jne    118d <ex7+0x4d>
jmp    11ae <ex7+0x6e>
lea    0xeb7(%rip),%rdi
call   1040 <print@plt>
lea    0xea8(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1170 <ex7+0x30>
movss  -0x4(%rbp),%xmm0
call   1060 <log10@plt>
imul   $0xffffffff,%eax,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xe22(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11f7 <ex7+0xb7>
lea    0xe92(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1227 <ex7+0xe7>
movss  -0x8(%rbp),%xmm0
movss  0xdfc(%rip),%xmm1
lea    0xe83(%rip),%rax
lea    0xe75(%rip),%rcx
ucomiss %xmm1,%xmm0
setnp  %sil
sete   %dl
test   %sil,%dl
cmovne %rcx,%rax
mov    %rax,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%rsi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
lea    0xdc1(%rip),%rdi
call   1040 <print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex7>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
call   1040 <print@plt>
lea    0xec5(%rip),%rdi
call   1040 <print@plt>
lea    0xedc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
ja     11c1 <ex7+0x81>
lea    0xec0(%rip),%r14
lea    0xeb6(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <print@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
xorps  %xmm1,%xmm1
movss  0xc(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11a0 <ex7+0x60>
call   1060 <log10@plt>
cmp    $0xfffffff9,%eax
lea    0xeb3(%rip),%rcx
lea    0xeb3(%rip),%rdx
cmove  %rcx,%rdx
lea    0xe9a(%rip),%rsi
cmovge %rdx,%rsi
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
lea    0xdfe(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [35 x i8] c"Informe a concentracao de ions H+:\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [33 x i8] c"Valor invalido, tente novamente:\00"
@.str.4 = [20 x i8] c"O pH e: %.2f (%s).\0A\00"
@.str.5 = [7 x i8] c"basico\00"
@.str.6 = [7 x i8] c"neutro\00"
@.str.7 = [6 x i8] c"acido\00"
define void @ex7() {
%1 = alloca float
%2 = alloca float
%3 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @print(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
br label %6
6: ; preds = %10, %0
%7 = load float, float* %1
%8 = fcmp ogt float %7, 0.000000e+00
%9 = xor i1 %8, true
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
br label %6
13: ; preds = %6
%14 = load float, float* %1
%15 = call i32 @log10(float %14)
%16 = mul nsw i32 -1, %15
%17 = sitofp i32 %16 to float
store float %17, float* %2
%18 = load float, float* %2
%19 = load float, float* %2
%20 = fcmp ogt float %19, 7.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %13
br label %27
22: ; preds = %13
%23 = load float, float* %2
%24 = fcmp oeq float %23, 7.000000e+00
%25 = zext i1 %24 to i64
%26 = select i1 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0)
br label %27
27: ; preds = %22, %21
%28 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %21 ], [ %26, %22 ]
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), float %18, i8* %28)
%30 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [35 x i8] c"Informe a concentracao de ions H+:\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [33 x i8] c"Valor invalido, tente novamente:\00"
@.str.4 = [20 x i8] c"O pH e: %.2f (%s).\0A\00"
@.str.5 = [7 x i8] c"basico\00"
@.str.6 = [7 x i8] c"neutro\00"
@.str.7 = [6 x i8] c"acido\00"
define void @ex7() {
%1 = alloca float
%2 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%3 = bitcast float* %1 to i8*
%4 = tail call i32 @print(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%6 = load float, float* %1
%7 = fcmp ule float %6, 0.000000e+00
br i1 %7, label %8, label %13
8: ; preds = %0, %8
%9 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%11 = load float, float* %1
%12 = fcmp ule float %11, 0.000000e+00
br i1 %12, label %8, label %13
13: ; preds = %8, %0
%14 = phi float [ %6, %0 ], [ %11, %8 ]
%15 = call i32 @log10(float %14)
%16 = icmp slt i32 %15, -7
%17 = icmp eq i32 %15, -7
%18 = select i1 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0)
%19 = select i1 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %18
%20 = sub nsw i32 0, %15
%21 = sitofp i32 %20 to float
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), float %21, i8* %19)
%23 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}