#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*/ printDigits(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a;
  printf("Enter digits: ");
  scanf("%d", &a);
  if (a < 1 || a > 32767) {
    printf("Error - Number must be in the range 1 to 32767\n");
    return -1;
  }
  printDigits(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     1172 <main+0x42>
cmpl   $0x7fff,-0x8(%rbp)
jle    118a <main+0x5a>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1199 <main+0x69>
mov    -0x8(%rbp),%edi
call   1040 <printDigits@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
lea    -0x8000(%rdi),%eax
cmp    $0xffff8000,%eax
ja     1182 <main+0x42>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
call   1050 <printDigits@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter digits: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"Error - Number must be in the range 1 to 32767\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 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* %2)
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 32767
br i1 %9, label %10, label %12
10: ; preds = %7, %0
%11 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %15
12: ; preds = %7
%13 = load i32, i32* %2
%14 = call i32 @printDigits(i32 %13)
store i32 0, i32* %1
br label %15
15: ; preds = %12, %10
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter digits: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [47 x i8] c"Error - Number must be in the range 1 to 32767\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 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 = add i32 %5, -32768
%7 = icmp ult i32 %6, -32767
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 @printDigits(i32 %5)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ -1, %8 ], [ 0, %10 ]
ret i32 %13
}