#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int n, copy;
  int i = 0, anti = 0;
  printf("This program sums the the digits in an integer.\n");
  printf("Enter a positive integer: ");
  scanf("%d", &n);
  copy = n;
  while (copy) {
    copy /= 10;
    i++;
  }
  while (n > 0) {
    int temp = n % 10;
    n /= 10;
    anti += temp * pow(10, --i);
  }
  printf("The anti order number is : %d\n", anti);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11ac <main+0x7c>
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <main+0x56>
jmp    11b1 <main+0x81>
cmpl   $0x0,-0x14(%rbp)
jle    1203 <main+0xd3>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
add    $0xffffffff,%esi
mov    %esi,-0x1c(%rbp)
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11b1 <main+0x81>
mov    -0x20(%rbp),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
je     11f3 <main+0xb3>
mov    $0xffffffff,%ebp
mov    %ebx,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    $0x9,%ecx
add    $0x1,%ebp
cmp    $0x13,%ecx
jae    1190 <main+0x50>
test   %ebx,%ebx
jle    11f3 <main+0xb3>
xor    %r14d,%r14d
mov    $0xcccccccd,%r15d
nop
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%ebx
mov    %eax,0x4(%rsp)
mov    $0xa,%edi
mov    %ebp,%esi
call   1060 <pow@plt>
imul   %ebx,%eax
add    %eax,%r14d
mov    0x4(%rsp),%ebx
add    $0xffffffff,%ebp
test   %ebx,%ebx
jg     11c0 <main+0x80>
lea    0xe24(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"This program sums the the digits in an integer.\0A\00"
@.str.1 = [27 x i8] c"Enter a positive integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"The anti order number is : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %6
store i32 %14, i32* %7
br label %15
15: ; preds = %18, %2
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32, i32* %7
%20 = sdiv i32 %19, 10
store i32 %20, i32* %7
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
br label %15
23: ; preds = %15
br label %24
24: ; preds = %27, %23
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i32, i32* %6
%29 = srem i32 %28, 10
store i32 %29, i32* %10
%30 = load i32, i32* %6
%31 = sdiv i32 %30, 10
store i32 %31, i32* %6
%32 = load i32, i32* %10
%33 = load i32, i32* %8
%34 = add nsw i32 %33, -1
store i32 %34, i32* %8
%35 = call i32 @pow(i32 10, i32 %34)
%36 = mul nsw i32 %32, %35
%37 = load i32, i32* %9
%38 = add nsw i32 %37, %36
store i32 %38, i32* %9
br label %24
39: ; preds = %24
%40 = load i32, i32* %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"Enter a positive integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"The anti order number is : %d\0A\00"
@str = [48 x i8] c"This program sums the the digits in an integer.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %31, label %12
10: ; preds = %12
%11 = icmp sgt i32 %8, 0
br i1 %11, label %19, label %31
12: ; preds = %2, %12
%13 = phi i32 [ %15, %12 ], [ %8, %2 ]
%14 = phi i32 [ %16, %12 ], [ 0, %2 ]
%15 = sdiv i32 %13, 10
%16 = add nuw nsw i32 %14, 1
%17 = add i32 %13, 9
%18 = icmp ult i32 %17, 19
br i1 %18, label %10, label %12
19: ; preds = %10, %19
%20 = phi i32 [ %29, %19 ], [ %8, %10 ]
%21 = phi i32 [ %28, %19 ], [ 0, %10 ]
%22 = phi i32 [ %25, %19 ], [ %16, %10 ]
%23 = urem i32 %20, 10
%24 = udiv i32 %20, 10
store i32 %24, i32* %3
%25 = add nsw i32 %22, -1
%26 = call i32 @pow(i32 10, i32 %25)
%27 = mul nsw i32 %26, %23
%28 = add nsw i32 %27, %21
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 0
br i1 %30, label %19, label %31
31: ; preds = %19, %2, %10
%32 = phi i32 [ 0, %10 ], [ 0, %2 ], [ %28, %19 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %32)
ret i32 0
}