#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 *);
int main(void) {
  int num, i, prox;
  int aux = 0;
  scanf("%d", &num);
  for (i = +1; i <= num; i++) {
    aux = aux + i;
    if (num == aux) {
      printf("SIM\n");
      i++;
      prox = aux + i;
      printf("%d\n", prox);
      if (prox + num % 4) {
        printf("SIM");
      } else {
        printf("NAO");
      }
      break;
    } else if (num == i) {
      printf("NAO");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     121b <main+0xfb>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11e4 <main+0xc4>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
add    %edx,%eax
cmp    $0x0,%eax
je     11d1 <main+0xb1>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <main+0xbf>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <main+0xfb>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1203 <main+0xe3>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <main+0xfb>
jmp    1208 <main+0xe8>
jmp    120d <main+0xed>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jle    11c7 <main+0x97>
mov    $0x2,%ebx
cmp    $0x1,%ebp
je     1181 <main+0x51>
mov    %ebp,%eax
neg    %eax
mov    $0x1,%ecx
mov    $0x2,%ebx
lea    0xe97(%rip),%rdi
lea    (%rax,%rbx,1),%edx
cmp    $0x1,%edx
je     11c0 <main+0x90>
add    %ebx,%ecx
add    $0x1,%ebx
cmp    %ecx,%ebp
jne    1170 <main+0x40>
lea    0xe83(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
add    %ebp,%ebx
lea    0xe6a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %eax,%ecx
cmp    %ecx,%ebx
lea    0xe4b(%rip),%rdi
cmovne %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"SIM\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"SIM\00"
@.str.4 = [4 x i8] c"NAO\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %7
7: ; preds = %45, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %48
11: ; preds = %7
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = add nsw i32 %12, %13
store i32 %14, i32* %5
%15 = load i32, i32* %2
%16 = load i32, i32* %5
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %11
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = add nsw i32 %22, %23
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %4
%28 = load i32, i32* %2
%29 = srem i32 %28, 4
%30 = add nsw i32 %27, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %36
34: ; preds = %18
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %48
37: ; preds = %11
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %48
43: ; preds = %37
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %7
48: ; preds = %41, %36, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.4 = [4 x i8] c"NAO\00"
@str = [4 x i8] c"SIM\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 1
br i1 %5, label %31, label %6
6: ; preds = %0
%7 = icmp eq i32 %4, 1
br i1 %7, label %10, label %20
8: ; preds = %24
%9 = add nuw i32 %22, 2
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %9, %8 ], [ 2, %6 ]
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%13 = add nuw nsw i32 %11, %4
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = srem i32 %15, 4
%17 = sub nsw i32 0, %16
%18 = icmp eq i32 %13, %17
%19 = select i1 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0)
br label %28
20: ; preds = %6, %24
%21 = phi i32 [ %26, %24 ], [ 1, %6 ]
%22 = phi i32 [ %25, %24 ], [ 1, %6 ]
%23 = icmp eq i32 %4, %22
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = add nuw nsw i32 %22, 1
%26 = add nuw nsw i32 %21, %25
%27 = icmp eq i32 %4, %26
br i1 %27, label %8, label %20
28: ; preds = %20, %10
%29 = phi i8* [ %19, %10 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %20 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %29)
br label %31
31: ; preds = %28, %0
ret i32 0
}