#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 four-digit integer number:");
  scanf("%d", &number);
  for (counter = 0; counter < 4; counter++) {
    digit = number % 10;
    number = number / 10;
    digit = (digit + 7) % 10;
    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 encrypted 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    0xf07(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1238 <main+0x118>
movslq -0xc(%rbp),%rcx
mov    %ecx,%eax
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
movslq -0xc(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edx
mov    %edx,%ecx
add    $0x7,%ecx
mov    %edx,%eax
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
neg    %edx
mov    %edx,%ecx
lea    0x7(%rax,%rcx,1),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     1225 <main+0x105>
mov    -0x28(%rbp),%rax
lea    0xe0b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1225 <main+0x105>
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1225 <main+0x105>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1225 <main+0x105>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    122a <main+0x10a>
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    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rdx
imul   $0x66666667,%rdx,%r9
mov    %r9,%rax
shr    $0x3f,%rax
sar    $0x22,%r9
add    %eax,%r9d
lea    (%r9,%r9,1),%eax
lea    (%rax,%rax,4),%r8d
imul   $0x51eb851f,%rdx,%r10
imul   $0x10624dd3,%rdx,%r11
imul   $0x68db8bad,%rdx,%rbx
sub    %r8d,%edx
add    $0x7,%dl
movsbl %dl,%edx
imul   $0x67,%edx,%esi
movzwl %si,%edi
shr    $0xa,%esi
shr    $0xf,%edi
add    %sil,%dil
movzbl %dil,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%dl
movsbl %dl,%edx
movslq %r9d,%rsi
imul   $0x66666667,%rsi,%rdi
mov    %rdi,%rcx
shr    $0x3f,%rcx
shr    $0x22,%rdi
add    %ecx,%edi
add    %edi,%edi
lea    (%rdi,%rdi,4),%ecx
sub    %ecx,%esi
mov    %r10,%rcx
shr    $0x3f,%rcx
sar    $0x25,%r10
add    %ecx,%r10d
add    $0x7,%sil
movsbl %sil,%ecx
imul   $0x67,%ecx,%esi
movzwl %si,%edi
shr    $0xa,%esi
shr    $0xf,%edi
add    %sil,%dil
movzbl %dil,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%cl
movsbl %cl,%esi
movslq %r10d,%rcx
imul   $0x66666667,%rcx,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
shr    $0x22,%rdi
add    %eax,%edi
add    %edi,%edi
lea    (%rdi,%rdi,4),%eax
sub    %eax,%ecx
mov    %r11,%rax
shr    $0x3f,%rax
sar    $0x26,%r11
add    %eax,%r11d
add    $0x7,%cl
movsbl %cl,%eax
imul   $0x67,%eax,%ecx
movzwl %cx,%edi
shr    $0xa,%ecx
shr    $0xf,%edi
add    %cl,%dil
movzbl %dil,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movsbl %al,%r8d
movslq %r11d,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
shr    $0x22,%rcx
add    %edi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x7,%al
movsbl %al,%eax
imul   $0x67,%eax,%ecx
movzwl %cx,%edi
shr    $0xa,%ecx
shr    $0xf,%edi
add    %cl,%dil
movzbl %dil,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movsbl %al,%ecx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x2c,%rbx
add    %eax,%ebx
mov    %ebx,0xc(%rsp)
lea    0xd87(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter a four-digit integer number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"The encrypted 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 ([35 x i8], [35 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 = %32, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %35
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 = add nsw i32 %19, 7
%21 = srem i32 %20, 10
store i32 %21, i32* %4
%22 = load i32, i32* %2
switch i32 %22, label %31 [
i32 0, label %23
i32 1, label %25
i32 2, label %27
i32 3, label %29
]
23: ; preds = %14
%24 = load i32, i32* %4
store i32 %24, i32* %7
br label %31
25: ; preds = %14
%26 = load i32, i32* %4
store i32 %26, i32* %8
br label %31
27: ; preds = %14
%28 = load i32, i32* %4
store i32 %28, i32* %5
br label %31
29: ; preds = %14
%30 = load i32, i32* %4
store i32 %30, i32* %6
br label %31
31: ; preds = %29, %14, %27, %25, %23
br label %32
32: ; preds = %31
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %11
35: ; preds = %11
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = load i32, i32* %6
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %37, i32 %38, i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter a four-digit integer number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"The encrypted 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 ([35 x i8], [35 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 = trunc i32 %6 to i8
%9 = add nsw i8 %8, 7
%10 = srem i8 %9, 10
%11 = sext i8 %10 to i32
%12 = srem i32 %7, 10
%13 = sdiv i32 %5, 100
%14 = trunc i32 %12 to i8
%15 = add nsw i8 %14, 7
%16 = srem i8 %15, 10
%17 = sext i8 %16 to i32
%18 = srem i32 %13, 10
%19 = sdiv i32 %5, 1000
%20 = trunc i32 %18 to i8
%21 = add nsw i8 %20, 7
%22 = srem i8 %21, 10
%23 = sext i8 %22 to i32
%24 = srem i32 %19, 10
%25 = trunc i32 %24 to i8
%26 = add nsw i8 %25, 7
%27 = srem i8 %26, 10
%28 = sext i8 %27 to i32
%29 = sdiv i32 %5, 10000
store i32 %29, i32* %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %11, i32 %28, i32 %23)
ret i32 0
}