#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*/ print(char *);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ scanf(char *, int *);
float sqrt(float);
void ex1() {
  print("\n------------------------------\n");
  int a, b, x;
  print("Informe o valor de x: ");
  scanf("%d", &x);
  print("Informe o valor de a: ");
  scanf("%d", &a);
  print("Informe o valor de b: ");
  scanf("%d", &b);
  while (a + b == 0) {
    print("Informe outros valores para a e b, pois a + b = 0");
    print("Informe o novo valor de a: ");
    scanf("%d", &a);
    print("Informe o novo valor de b: ");
    scanf("%d", &b);
  }
  float resultado = sqrt((float)x / (a + b));
  printf("Resultado: %.2f\n", resultado);
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <print@plt>
lea    0xec6(%rip),%rdi
call   1040 <print@plt>
lea    0xed1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec4(%rip),%rdi
call   1040 <print@plt>
lea    0xeb5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xebf(%rip),%rdi
call   1040 <print@plt>
lea    0xe99(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    $0x0,%eax
jne    1200 <ex1+0xc0>
lea    0xeab(%rip),%rdi
call   1040 <print@plt>
lea    0xed1(%rip),%rdi
call   1040 <print@plt>
lea    0xe62(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed1(%rip),%rdi
call   1040 <print@plt>
lea    0xe46(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    11a8 <ex1+0x68>
cvtsi2ssl -0xc(%rbp),%xmm0
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
call   1060 <sqrt@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xdcb(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
call   1040 <print@plt>
lea    0xec0(%rip),%rdi
call   1040 <print@plt>
lea    0xecb(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeba(%rip),%rdi
call   1040 <print@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb8(%rip),%rdi
call   1040 <print@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    0x10(%rsp),%eax
jne    1218 <ex1+0xd8>
lea    0xeac(%rip),%r14
lea    0xed7(%rip),%r15
lea    0xe6d(%rip),%rbx
lea    0x10(%rsp),%r12
lea    0xee0(%rip),%r13
lea    0xc(%rsp),%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <print@plt>
mov    %r15,%rdi
call   1040 <print@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1040 <print@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    0x10(%rsp),%eax
je     11e0 <ex1+0xa0>
cvtsi2ssl 0x14(%rsp),%xmm0
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1234 <ex1+0xf4>
sqrtss %xmm0,%xmm0
jmp    1239 <ex1+0xf9>
call   1060 <sqrt@plt>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
lea    0xdb4(%rip),%rdi
call   1040 <print@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [23 x i8] c"Informe o valor de x: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Informe o valor de a: \00"
@.str.4 = [23 x i8] c"Informe o valor de b: \00"
@.str.5 = [50 x i8] c"Informe outros valores para a e b, pois a + b = 0\00"
@.str.6 = [28 x i8] c"Informe o novo valor de a: \00"
@.str.7 = [28 x i8] c"Informe o novo valor de b: \00"
@.str.8 = [17 x i8] c"Resultado: %.2f\0A\00"
define void @ex1() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = call i32 @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = call i32 @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %12
12: ; preds = %17, %0
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = add nsw i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = call i32 @print(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @print(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%21 = call i32 @print(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %12
23: ; preds = %12
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to float
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = add nsw i32 %26, %27
%29 = sitofp i32 %28 to float
%30 = fdiv float %25, %29
%31 = call float @sqrt(float %30)
store float %31, float* %4
%32 = load float, float* %4
%33 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), float %32)
%34 = 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 = [23 x i8] c"Informe o valor de x: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Informe o valor de a: \00"
@.str.4 = [23 x i8] c"Informe o valor de b: \00"
@.str.5 = [50 x i8] c"Informe outros valores para a e b, pois a + b = 0\00"
@.str.6 = [28 x i8] c"Informe o novo valor de a: \00"
@.str.7 = [28 x i8] c"Informe o novo valor de b: \00"
@.str.8 = [17 x i8] c"Resultado: %.2f\0A\00"
define void @ex1() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = tail call i32 @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%10 = call i32 @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%12 = call i32 @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = add nsw i32 %15, %14
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %0, %18
%19 = call i32 @print(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @print(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%22 = call i32 @print(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = add nsw i32 %25, %24
%27 = icmp eq i32 %26, 0
br i1 %27, label %18, label %28
28: ; preds = %18, %0
%29 = phi i32 [ %16, %0 ], [ %26, %18 ]
%30 = load i32, i32* %3
%31 = sitofp i32 %30 to float
%32 = sitofp i32 %29 to float
%33 = fdiv float %31, %32
%34 = call float @sqrt(float %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), float %34)
%36 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}