#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 x, y;
  printf("Enter The Value of X: ");
  scanf("%d", &x);
  printf("USING NESTED IF \n");
  if (x > 0)
    y = 1;
  if (x == 0)
    y = 0;
  if (x < 0)
    y = -1;
  printf("Y: %d \n", y);
  printf("USING IF...ELSE \n");
  if (x > 0)
    y = 1;
  else if (x == 0)
    y = 0;
  else if (x < 0)
    y = -1;
  printf("Y: %d \n", y);
  printf("USING COND. OPP. \n");
  y = x > 0 ? 1 : (x < 0 ? -1 : 0);
  printf("Y: %d \n", y);
  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    0xed3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    116c <main+0x4c>
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    117d <main+0x5d>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    118e <main+0x6e>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11c3 <main+0xa3>
movl   $0x1,-0xc(%rbp)
jmp    11f4 <main+0xd4>
cmpl   $0x0,-0x8(%rbp)
jne    11d9 <main+0xb9>
movl   $0x0,-0xc(%rbp)
jmp    11ef <main+0xcf>
cmpl   $0x0,-0x8(%rbp)
jge    11ea <main+0xca>
movl   $0xffffffff,-0xc(%rbp)
jmp    11ef <main+0xcf>
jmp    11f4 <main+0xd4>
mov    -0xc(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    122a <main+0x10a>
mov    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123d <main+0x11d>
mov    -0x8(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
cmpl   $0x0,0x4(%rsp)
setne  %al
mov    $0xffffffff,%esi
cmovns %eax,%esi
lea    0xea3(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
xor    %esi,%esi
test   %eax,%eax
setne  %sil
neg    %esi
test   %eax,%eax
mov    $0x1,%ebp
cmovg  %ebp,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
xor    %esi,%esi
test   %eax,%eax
setne  %sil
neg    %esi
test   %eax,%eax
cmovg  %ebp,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter The Value of X: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"USING NESTED IF \0A\00"
@.str.3 = [8 x i8] c"Y: %d \0A\00"
@.str.4 = [18 x i8] c"USING IF...ELSE \0A\00"
@.str.5 = [19 x i8] c"USING COND. OPP. \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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %3
br label %10
10: ; preds = %9, %0
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 0, i32* %3
br label %14
14: ; preds = %13, %10
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 -1, i32* %3
br label %18
18: ; preds = %17, %14
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 1, i32* %3
br label %35
25: ; preds = %18
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 0, i32* %3
br label %34
29: ; preds = %25
%30 = load i32, i32* %2
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 -1, i32* %3
br label %33
33: ; preds = %32, %29
br label %34
34: ; preds = %33, %28
br label %35
35: ; preds = %34, %24
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%39 = load i32, i32* %2
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %35
br label %47
42: ; preds = %35
%43 = load i32, i32* %2
%44 = icmp slt i32 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i32 -1, i32 0
br label %47
47: ; preds = %42, %41
%48 = phi i32 [ 1, %41 ], [ %46, %42 ]
store i32 %48, i32* %3
%49 = load i32, i32* %3
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter The Value of X: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"Y: %d \0A\00"
@str = [17 x i8] c"USING NESTED IF \00"
@str.6 = [17 x i8] c"USING IF...ELSE \00"
@str.7 = [18 x i8] c"USING COND. OPP. \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i32
%9 = icmp sgt i32 %6, -1
%10 = select i1 %9, i32 %8, i32 -1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 0
%15 = sext i1 %14 to i32
%16 = icmp slt i32 %13, 1
%17 = select i1 %16, i32 %15, i32 1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
%20 = load i32, i32* %1
%21 = icmp ne i32 %20, 0
%22 = sext i1 %21 to i32
%23 = icmp slt i32 %20, 1
%24 = select i1 %23, i32 %22, i32 1
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %24)
ret i32 0
}