#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void ex7() {
  int num, x = 1, y = 2, z = 3;
  printf("Digite um numero para verificar se ele e um numero triangular: ");
  scanf("%d", &num);
  while (x * y * z <= num) {
    if (x * y * z == num)
      printf("E triangular.");
    x++;
    y++;
    z++;
  }
  if (x * y * z < num)
    printf("Nao e triangular.");
}


x86 assembly (clang, -O0):
<ex7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x3,-0x10(%rbp)
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11ad <ex7+0x8d>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    118d <ex7+0x6d>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <ex7+0x39>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cd <ex7+0xad>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex7>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x6,%eax
jge    1152 <ex7+0x32>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x6,%ecx
mov    $0x4,%ebx
lea    0xee0(%rip),%r14
jmp    1183 <ex7+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rbx),%edx
lea    -0x1(%rbx),%ecx
imul   %edx,%ecx
imul   %ebx,%ecx
add    $0x1,%ebx
cmp    %eax,%ecx
jg     114a <ex7+0x2a>
cmp    %eax,%ecx
jne    1170 <ex7+0x50>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
jmp    1170 <ex7+0x50>

LLVM IR (-O0):
@.str = [64 x i8] c"Digite um numero para verificar se ele e um numero triangular: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"E triangular.\00"
@.str.3 = [18 x i8] c"Nao e triangular.\00"
define void @ex7() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %2
store i32 2, i32* %3
store i32 3, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %7
7: ; preds = %25, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = mul nsw i32 %8, %9
%11 = load i32, i32* %4
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %1
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %32
15: ; preds = %7
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = mul nsw i32 %16, %17
%19 = load i32, i32* %4
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %1
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %15
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %7
32: ; preds = %7
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %4
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %1
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %32
ret void
}

LLVM IR (-O2):
@.str = [64 x i8] c"Digite um numero para verificar se ele e um numero triangular: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"E triangular.\00"
define void @ex7() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 6
br i1 %6, label %25, label %7
7: ; preds = %0, %17
%8 = phi i32 [ %18, %17 ], [ %5, %0 ]
%9 = phi i32 [ %23, %17 ], [ 6, %0 ]
%10 = phi i32 [ %21, %17 ], [ 3, %0 ]
%11 = phi i32 [ %20, %17 ], [ 2, %0 ]
%12 = phi i32 [ %19, %17 ], [ 1, %0 ]
%13 = icmp eq i32 %9, %8
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %1
br label %17
17: ; preds = %14, %7
%18 = phi i32 [ %16, %14 ], [ %8, %7 ]
%19 = add nuw nsw i32 %12, 1
%20 = add nuw nsw i32 %11, 1
%21 = add nuw nsw i32 %10, 1
%22 = mul nsw i32 %20, %19
%23 = mul nsw i32 %22, %21
%24 = icmp sgt i32 %23, %18
br i1 %24, label %25, label %7
25: ; preds = %17, %0
ret void
}