#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 counter, number, digit = 0;
  int first_digit, second_digit, third_digit, fourth_digit;
  printf("Enter a 4-digit encrypted integer number:");
  scanf("%d", &number);
  for (counter = 0; counter < 4; counter++) {
    digit = number % 10;
    number = number / 10;
    if (digit >= 7 && digit <= 9) {
      digit = digit - 7;
    } else {
      digit = (digit + 10) - 7;
    }
    switch (counter) {
    case 0:
      third_digit = digit;
      break;
    case 1:
      fourth_digit = digit;
      break;
    case 2:
      first_digit = digit;
      break;
    case 3:
      second_digit = digit;
    }
  }
  printf("The decrypted number is :%d%d%d%d", fourth_digit, third_digit,
         second_digit, first_digit);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    120e <main+0xee>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x7,-0x10(%rbp)
jl     11a3 <main+0x83>
cmpl   $0x9,-0x10(%rbp)
jg     11a3 <main+0x83>
mov    -0x10(%rbp),%eax
sub    $0x7,%eax
mov    %eax,-0x10(%rbp)
jmp    11af <main+0x8f>
mov    -0x10(%rbp),%eax
add    $0xa,%eax
sub    $0x7,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     11fb <main+0xdb>
mov    -0x28(%rbp),%rax
lea    0xe35(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11fb <main+0xdb>
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11fb <main+0xdb>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11fb <main+0xdb>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1200 <main+0xe0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x3b>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%r9
imul   $0x66666667,%r9,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %r9d,%esi
sub    %edx,%esi
lea    0x3(%rsi),%edi
lea    -0x7(%rsi),%edx
cmp    $0x7,%esi
cmovl  %edi,%edx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%ecx
imul   $0x51eb851f,%r9,%rdi
mov    %rdi,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdi
add    %esi,%edi
lea    0x3(%rcx),%eax
lea    -0x7(%rcx),%esi
cmp    $0x7,%ecx
cmovl  %eax,%esi
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rcx
add    %edi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
imul   $0x10624dd3,%r9,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rcx
add    %edi,%ecx
lea    0x3(%rax),%edi
lea    -0x7(%rax),%r8d
cmp    $0x7,%eax
cmovl  %edi,%r8d
movslq %ecx,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rcx
add    %edi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
lea    0x3(%rax),%edi
lea    -0x7(%rax),%ecx
cmp    $0x7,%eax
cmovl  %edi,%ecx
imul   $0x68db8bad,%r9,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x2c,%rax
add    %edi,%eax
mov    %eax,0x4(%rsp)
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [42 x i8] c"Enter a 4-digit encrypted integer number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"The decrypted number is :%d%d%d%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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 = srem i32 %5, 10
%7 = sdiv i32 %5, 10
%8 = icmp sgt i32 %6, 6
%9 = select i1 %8, i32 -7, i32 3
%10 = add nsw i32 %9, %6
%11 = srem i32 %7, 10
%12 = sdiv i32 %5, 100
%13 = icmp sgt i32 %11, 6
%14 = select i1 %13, i32 -7, i32 3
%15 = add nsw i32 %14, %11
%16 = srem i32 %12, 10
%17 = sdiv i32 %5, 1000
%18 = icmp sgt i32 %16, 6
%19 = select i1 %18, i32 -7, i32 3
%20 = add nsw i32 %19, %16
%21 = srem i32 %17, 10
%22 = icmp sgt i32 %21, 6
%23 = select i1 %22, i32 -7, i32 3
%24 = add nsw i32 %23, %21
%25 = sdiv i32 %5, 10000
store i32 %25, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %10, i32 %24, i32 %20)
ret i32 0
}