#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*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n = 0;
  do {
    printf("请输入一个正整数: ");
    scanf("%d", &n);
    if (n <= 0) {
      puts("\a请不要输入非正整数");
    }
  } while (n <= 0);
  printf("%d逆向显示的结果是: ", n);
  while (n > 0) {
    printf("%d", n % 10);
    n /= 10;
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     118a <main+0x4a>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
jmp    118f <main+0x4f>
cmpl   $0x0,-0x8(%rbp)
jle    1156 <main+0x16>
mov    -0x8(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11e2 <main+0xa2>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11aa <main+0x6a>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea9(%rip),%r14
lea    0xebd(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xeb4(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jg     119d <main+0x5d>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1170 <main+0x30>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11fe <main+0xbe>
mov    $0xcccccccd,%r14d
lea    0xe5b(%rip),%rbx
mov    %esi,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0x4(%rsp)
cmp    $0x9,%rax
jg     11c0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E6\AD\A3\E6\95\B4\E6\95\B0: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\07\E8\AF\B7\E4\B8\8D\E8\A6\81\E8\BE\93\E5\85\A5\E9\9D\9E\E6\AD\A3\E6\95\B4\E6\95\B0\00"
@.str.3 = [29 x i8] c"%d\E9\80\86\E5\90\91\E6\98\BE\E7\A4\BA\E7\9A\84\E7\BB\93\E6\9E\9C\E6\98\AF: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %11, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
br label %11
11: ; preds = %10
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 0
br i1 %13, label %3, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %20, %14
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %2
%22 = srem i32 %21, 10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = sdiv i32 %24, 10
store i32 %25, i32* %2
br label %17
26: ; preds = %17
%27 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E6\AD\A3\E6\95\B4\E6\95\B0: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\07\E8\AF\B7\E4\B8\8D\E8\A6\81\E8\BE\93\E5\85\A5\E9\9D\9E\E6\AD\A3\E6\95\B4\E6\95\B0\00"
@.str.3 = [29 x i8] c"%d\E9\80\86\E5\90\91\E6\98\BE\E7\A4\BA\E7\9A\84\E7\BB\93\E6\9E\9C\E6\98\AF: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %8, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %3, label %12
12: ; preds = %3, %8
%13 = phi i32 [ %10, %8 ], [ %6, %3 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %12, %17
%18 = phi i32 [ %22, %17 ], [ %15, %12 ]
%19 = urem i32 %18, 10
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %1
%22 = sdiv i32 %21, 10
store i32 %22, i32* %1
%23 = icmp sgt i32 %21, 9
br i1 %23, label %17, label %24
24: ; preds = %17, %12
%25 = call i32 @putchar(i8 signext 10)
ret i32 0
}