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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    116c <main+0x3c>
jmp    116c <main+0x3c>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x8(%rbp)
jl     113f <main+0xf>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1190 <main+0x60>
lea    0xe82(%rip),%rdi
call   1030 <puts@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
lea    0xec1(%rip),%r14
lea    0xed1(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xec8(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
js     1160 <main+0x30>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
lea    0xe7a(%rip),%rbx
nopl   (%rax)
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x4(%rsp),%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
cmp    $0x9,%rcx
jg     11a0 <main+0x70>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E9\9D\9E\E8\B4\9F\E6\95\B0:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"\E4\B8\8D\E8\A6\81\E8\BE\93\E5\85\A5\E8\B4\9F\E6\95\B0\00"
@.str.3 = [31 x i8] c"\E6\95\B4\E6\95\B0\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"
@.str.4 = [2 x i8] c".\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %11, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 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 slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %3
br label %9
9: ; preds = %8, %3
%10 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %3, label %14
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %22, %14
%17 = load i32, i32* %2
%18 = srem i32 %17, 10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 10
store i32 %21, i32* %2
br label %22
22: ; preds = %16
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 0
br i1 %24, label %16, label %25
25: ; preds = %22
%26 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E9\9D\9E\E8\B4\9F\E6\95\B0:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"\E4\B8\8D\E8\A6\81\E8\BE\93\E5\85\A5\E8\B4\9F\E6\95\B0\00"
@.str.3 = [31 x i8] c"\E6\95\B4\E6\95\B0\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"
@.str.4 = [2 x i8] c".\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32, i32* %1
br label %12
12: ; preds = %12, %9
%13 = phi i32 [ %17, %12 ], [ %11, %9 ]
%14 = srem i32 %13, 10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = sdiv i32 %16, 10
store i32 %17, i32* %1
%18 = icmp sgt i32 %16, 9
br i1 %18, label %12, label %19
19: ; preds = %12
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}