#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() {
  int c, z;
  printf(
      "This program needs 1 initial digit(s) to make decision accordingly\n\n");
  printf("Please enter a number: ");
  scanf("%d", &z);
  while (z == 0) {
    printf("Enter new number: ");
    scanf("%d", &z);
  }
  if (z < 0)
    c = -1;
  if (z > 0)
    c = 1;
  switch (c) {
  case -1:
    printf("\nGhadre motlagh is: %d\n", z * -1);
    break;
  case 1:
    printf("\nTavane 2 is: %d\n", z * z);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1188 <main+0x68>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115b <main+0x3b>
cmpl   $0x0,-0xc(%rbp)
jge    1199 <main+0x79>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11aa <main+0x8a>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xffffffff,%eax
je     11cf <main+0xaf>
jmp    11be <main+0x9e>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11e6 <main+0xc6>
jmp    11fb <main+0xdb>
imul   $0xffffffff,-0xc(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <main+0xdb>
mov    -0xc(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jne    119d <main+0x6d>
lea    0xea8(%rip),%r14
lea    0xe9e(%rip),%r15
lea    0xc(%rsp),%rbx
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1180 <main+0x50>
test   %esi,%esi
jle    11ad <main+0x7d>
imul   %esi,%esi
lea    0xe9b(%rip),%rdi
jmp    11b6 <main+0x86>
neg    %esi
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [69 x i8] c"This program needs 1 initial digit(s) to make decision accordingly\0A\0A\00"
@.str.1 = [24 x i8] c"Please enter a number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Enter new number: \00"
@.str.4 = [24 x i8] c"\0AGhadre motlagh is: %d\0A\00"
@.str.5 = [18 x i8] c"\0ATavane 2 is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 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), i32* %3)
br label %7
13: ; preds = %7
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 -1, i32* %2
br label %17
17: ; preds = %16, %13
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 1, i32* %2
br label %21
21: ; preds = %20, %17
%22 = load i32, i32* %2
switch i32 %22, label %32 [
i32 -1, label %23
i32 1, label %27
]
23: ; preds = %21
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, -1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %32
27: ; preds = %21
%28 = load i32, i32* %3
%29 = load i32, i32* %3
%30 = mul nsw i32 %28, %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %21, %27, %23
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"Please enter a number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Enter new number: \00"
@.str.4 = [24 x i8] c"\0AGhadre motlagh is: %d\0A\00"
@.str.5 = [18 x i8] c"\0ATavane 2 is: %d\0A\00"
@str = [68 x i8] c"This program needs 1 initial digit(s) to make decision accordingly\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 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), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0, %8
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %8, label %13
13: ; preds = %8, %0
%14 = phi i32 [ %6, %0 ], [ %11, %8 ]
%15 = icmp sgt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = sub nsw i32 0, %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %22
19: ; preds = %13
%20 = mul nsw i32 %14, %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %16
ret i32 0
}