#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 EXIT_SUCCESS;
int /*<<< orphan*/ checkInput(int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int number, sum, reversed, lastFirst, secondThird;
  int a, b, c, d;
  printf("Enter nuber: ");
  checkInput(&number);
  a = (number / 1000) % 10;
  b = (number / 100) % 10;
  c = (number / 10) % 10;
  d = number % 10;
  sum = a + b + c + d;
  reversed = (d * 1000) + (c * 100) + (b * 10) + a;
  lastFirst = (d * 1000) + (a * 100) + (b * 10) + c;
  secondThird = (a * 1000) + (c * 100) + (b * 10) + d;
  printf("Sum is: %d\n", sum);
  printf("The number in reversed order: %d\n", reversed);
  printf("Last digit in the first position: %d\n", lastFirst);
  printf("Exchanges the second and the third digits: %d\n", secondThird);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1040 <checkInput@plt>
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0xc(%rbp)
imul   $0x3e8,-0x28(%rbp),%eax
imul   $0x64,-0x24(%rbp),%ecx
add    %ecx,%eax
imul   $0xa,-0x20(%rbp),%ecx
add    %ecx,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0x3e8,-0x28(%rbp),%eax
imul   $0x64,-0x1c(%rbp),%ecx
add    %ecx,%eax
imul   $0xa,-0x20(%rbp),%ecx
add    %ecx,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
imul   $0x3e8,-0x1c(%rbp),%eax
imul   $0x64,-0x24(%rbp),%ecx
add    %ecx,%eax
imul   $0xa,-0x20(%rbp),%ecx
add    %ecx,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rdi
call   1040 <checkInput@plt>
movslq 0xc(%rsp),%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
movslq %ecx,%r8
imul   $0x66666667,%r8,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%r8d
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdx
add    %esi,%edx
movslq %edx,%rdx
imul   $0x66666667,%rdx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%edx
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rdi
mov    %rdi,%rbp
shr    $0x3f,%rbp
sar    $0x22,%rdi
add    %ebp,%edi
add    %edi,%edi
lea    (%rdi,%rdi,4),%ebp
mov    %esi,%edi
sub    %ebp,%edi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%eax
lea    (%rdx,%rax,1),%esi
add    %r8d,%esi
add    %edi,%esi
imul   $0x3e8,%eax,%ecx
imul   $0x64,%edi,%ebx
add    %edx,%edx
lea    (%rdx,%rdx,4),%ebp
add    %ebp,%ebx
lea    (%rbx,%rcx,1),%r14d
add    %r8d,%r14d
imul   $0x64,%r8d,%edx
add    %ecx,%ebp
add    %edi,%ebp
add    %edx,%ebp
imul   $0x3e8,%r8d,%ecx
add    %eax,%ebx
add    %ecx,%ebx
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdec(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter nuber: \00"
@.str.1 = [12 x i8] c"Sum is: %d\0A\00"
@.str.2 = [34 x i8] c"The number in reversed order: %d\0A\00"
@.str.3 = [38 x i8] c"Last digit in the first position: %d\0A\00"
@.str.4 = [47 x i8] c"Exchanges the second and the third digits: %d\0A\00"
@EXIT_SUCCESS = global i32 0
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
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @checkInput(i32* %2)
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 1000
%15 = srem i32 %14, 10
store i32 %15, i32* %7
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 100
%18 = srem i32 %17, 10
store i32 %18, i32* %8
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 10
%21 = srem i32 %20, 10
store i32 %21, i32* %9
%22 = load i32, i32* %2
%23 = srem i32 %22, 10
store i32 %23, i32* %10
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = add nsw i32 %24, %25
%27 = load i32, i32* %9
%28 = add nsw i32 %26, %27
%29 = load i32, i32* %10
%30 = add nsw i32 %28, %29
store i32 %30, i32* %3
%31 = load i32, i32* %10
%32 = mul nsw i32 %31, 1000
%33 = load i32, i32* %9
%34 = mul nsw i32 %33, 100
%35 = add nsw i32 %32, %34
%36 = load i32, i32* %8
%37 = mul nsw i32 %36, 10
%38 = add nsw i32 %35, %37
%39 = load i32, i32* %7
%40 = add nsw i32 %38, %39
store i32 %40, i32* %4
%41 = load i32, i32* %10
%42 = mul nsw i32 %41, 1000
%43 = load i32, i32* %7
%44 = mul nsw i32 %43, 100
%45 = add nsw i32 %42, %44
%46 = load i32, i32* %8
%47 = mul nsw i32 %46, 10
%48 = add nsw i32 %45, %47
%49 = load i32, i32* %9
%50 = add nsw i32 %48, %49
store i32 %50, i32* %5
%51 = load i32, i32* %7
%52 = mul nsw i32 %51, 1000
%53 = load i32, i32* %9
%54 = mul nsw i32 %53, 100
%55 = add nsw i32 %52, %54
%56 = load i32, i32* %8
%57 = mul nsw i32 %56, 10
%58 = add nsw i32 %55, %57
%59 = load i32, i32* %10
%60 = add nsw i32 %58, %59
store i32 %60, i32* %6
%61 = load i32, i32* %3
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %4
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %5
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %6
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%69 = load i32, i32* @EXIT_SUCCESS
ret i32 %69
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter nuber: \00"
@.str.1 = [12 x i8] c"Sum is: %d\0A\00"
@.str.2 = [34 x i8] c"The number in reversed order: %d\0A\00"
@.str.3 = [38 x i8] c"Last digit in the first position: %d\0A\00"
@.str.4 = [47 x i8] c"Exchanges the second and the third digits: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @checkInput(i32* %1)
%5 = load i32, i32* %1
%6 = sdiv i32 %5, 1000
%7 = srem i32 %6, 10
%8 = sdiv i32 %5, 100
%9 = srem i32 %8, 10
%10 = sdiv i32 %5, 10
%11 = srem i32 %10, 10
%12 = srem i32 %5, 10
%13 = add nsw i32 %9, %12
%14 = add nsw i32 %13, %7
%15 = add nsw i32 %14, %11
%16 = mul nsw i32 %12, 1000
%17 = mul nsw i32 %11, 100
%18 = mul nsw i32 %9, 10
%19 = add nsw i32 %18, %17
%20 = add nsw i32 %19, %16
%21 = add nsw i32 %20, %7
%22 = mul nsw i32 %7, 100
%23 = add nsw i32 %18, %16
%24 = add nsw i32 %23, %11
%25 = add nsw i32 %24, %22
%26 = mul nsw i32 %7, 1000
%27 = add nsw i32 %19, %12
%28 = add nsw i32 %27, %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}