#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*/ exit(int);
int /*<<< orphan*/ printf(char *, int);
void number_char_array(int num, char *char_array) {
  int i = 0;
  char temp[20];
  int remainder = num;
  if (num == 0) {
    char_array[0] = '0';
    char_array[1] = '\0';
    return;
  }
  while (num != 0) {
    remainder = num % 10;
    temp[i] = '0' + remainder;
    num /= 10;
    i++;
  }
  if (i >= 20) {
    printf("%d>=20 出界了！", i);
    exit(1);
  }
  temp[i] = '\0';
  int j, k = 0;
  for (j = i - 1; j >= 0; j--) {
    char_array[k] = temp[j];
    k++;
  }
  char_array[k] = '\0';
}


x86 assembly (clang, -O0):
<number_char_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    115a <number_char_array+0x3a>
mov    -0x10(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    121f <number_char_array+0xff>
jmp    115f <number_char_array+0x3f>
cmpl   $0x0,-0x4(%rbp)
je     11a3 <number_char_array+0x83>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <number_char_array+0x3f>
cmpl   $0x14,-0x14(%rbp)
jl     11c6 <number_char_array+0xa6>
mov    -0x14(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
movl   $0x0,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jl     1213 <number_char_array+0xf3>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    11df <number_char_array+0xbf>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_char_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
je     11ac <number_char_array+0x8c>
mov    $0xffffffff,%ebp
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movslq %edi,%rdx
imul   $0x66666667,%rdx,%rdi
mov    %rdi,%rbx
shr    $0x3f,%rbx
sar    $0x22,%rdi
add    %ebx,%edi
lea    (%rdi,%rdi,1),%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %edx,%ecx
sub    %ebx,%ecx
add    $0x30,%cl
mov    %cl,(%rsp,%rax,1)
add    $0x1,%rax
add    $0x9,%edx
add    $0x1,%ebp
cmp    $0x12,%edx
ja     1140 <number_char_array+0x20>
lea    -0x1(%rax),%rdx
cmp    $0x13,%edx
jae    1345 <number_char_array+0x225>
mov    %eax,%ecx
movb   $0x0,(%rsp,%rcx,1)
mov    %edx,%r8d
xor    %r9d,%r9d
test   %ebp,%ebp
mov    $0x0,%ecx
cmovs  %ebp,%ecx
mov    %eax,%r11d
sub    %ecx,%r11d
cmp    $0x8,%r11d
jae    11b9 <number_char_array+0x99>
xor    %edx,%edx
jmp    1308 <number_char_array+0x1e8>
movb   $0x30,(%rsi)
mov    $0x1,%eax
jmp    1336 <number_char_array+0x216>
xor    %r10d,%r10d
cmp    $0x20,%r11d
jae    11c9 <number_char_array+0xa9>
xor    %edx,%edx
jmp    128e <number_char_array+0x16e>
mov    %r11d,%edx
and    $0xffffffe0,%edx
lea    0x10(%rsi),%rdi
lea    -0x1(%rax),%ecx
test   %ebp,%ebp
mov    $0x0,%ebx
cmovs  %ebp,%ebx
mov    %eax,%r14d
sub    %ebx,%r14d
and    $0xffffffe0,%r14d
neg    %r14
lea    (%rsp,%rcx,1),%r15
add    $0xfffffffffffffff1,%r15
pxor   %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movdqu -0x10(%r15,%rbx,1),%xmm1
movdqu (%r15,%rbx,1),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqu %xmm2,-0x10(%rdi)
movdqu %xmm1,(%rdi)
add    $0x20,%rdi
add    $0xffffffffffffffe0,%rbx
cmp    %rbx,%r14
jne    1200 <number_char_array+0xe0>
cmp    %r11,%rdx
je     1333 <number_char_array+0x213>
test   $0x18,%r11b
je     1305 <number_char_array+0x1e5>
mov    %rdx,%rdi
mov    %r11d,%edx
and    $0xfffffff8,%edx
sub    %rdx,%r8
lea    (%rsi,%rdi,1),%rbx
mov    %eax,%ecx
add    $0xffffffff,%ecx
test   %ebp,%ebp
cmovs  %ebp,%r10d
mov    %eax,%r14d
sub    %r10d,%r14d
and    $0xfffffff8,%r14d
neg    %r14
neg    %rdi
lea    (%rsp,%rcx,1),%r10
add    $0xfffffffffffffff9,%r10
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movq   (%r10,%rdi,1),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rbx)
add    $0x8,%rbx
add    $0xfffffffffffffff8,%rdi
cmp    %rdi,%r14
jne    12d0 <number_char_array+0x1b0>
cmp    %r11,%rdx
jne    1308 <number_char_array+0x1e8>
jmp    1333 <number_char_array+0x213>
sub    %rdx,%r8
test   %ebp,%ebp
cmovs  %ebp,%r9d
sub    %r9d,%eax
lea    (%rsp,%r8,1),%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rcx),%ebx
mov    %bl,(%rsi,%rdx,1)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rcx
cmp    %rdx,%rax
jne    1320 <number_char_array+0x200>
mov    %r11d,%eax
movb   $0x0,(%rsi,%rax,1)
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb4(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"%d>=20 \E5\87\BA\E7\95\8C\E4\BA\86\EF\BC\81\00"
define void @number_char_array(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [20 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%10 = load i32, i32* %3
store i32 %10, i32* %7
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 48, i8* %15
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 0, i8* %17
br label %70
18: ; preds = %2
br label %19
19: ; preds = %22, %18
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i32, i32* %3
%24 = srem i32 %23, 10
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = add nsw i32 48, %25
%27 = trunc i32 %26 to i8
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %29
store i8 %27, i8* %30
%31 = load i32, i32* %3
%32 = sdiv i32 %31, 10
store i32 %32, i32* %3
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %19
35: ; preds = %19
%36 = load i32, i32* %5
%37 = icmp sge i32 %36, 20
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %5
%40 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %35
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %44
store i8 0, i8* %45
store i32 0, i32* %9
%46 = load i32, i32* %5
%47 = sub nsw i32 %46, 1
store i32 %47, i32* %8
br label %48
48: ; preds = %62, %42
%49 = load i32, i32* %8
%50 = icmp sge i32 %49, 0
br i1 %50, label %51, label %65
51: ; preds = %48
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = load i8*, i8** %4
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 %55, i8* %59
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %62
62: ; preds = %51
%63 = load i32, i32* %8
%64 = add nsw i32 %63, -1
store i32 %64, i32* %8
br label %48
65: ; preds = %48
%66 = load i8*, i8** %4
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
store i8 0, i8* %69
br label %70
70: ; preds = %65, %13
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"%d>=20 \E5\87\BA\E7\95\8C\E4\BA\86\EF\BC\81\00"
define void @number_char_array(i32 %0, i8* nocapture writeonly %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %7
6: ; preds = %2
store i8 48, i8* %1
br label %94
7: ; preds = %2, %7
%8 = phi i64 [ %15, %7 ], [ 0, %2 ]
%9 = phi i32 [ %14, %7 ], [ %0, %2 ]
%10 = srem i32 %9, 10
%11 = trunc i32 %10 to i8
%12 = add nsw i8 %11, 48
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %8
store i8 %12, i8* %13
%14 = sdiv i32 %9, 10
%15 = add nuw i64 %8, 1
%16 = add i32 %9, 9
%17 = icmp ult i32 %16, 19
br i1 %17, label %18, label %7
18: ; preds = %7
%19 = trunc i64 %8 to i32
%20 = icmp ugt i32 %19, 18
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = trunc i64 %15 to i32
%23 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %18
%26 = and i64 %15, 4294967295
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %26
store i8 0, i8* %27
%28 = and i64 %8, 4294967295
%29 = add nuw nsw i32 %19, 1
%30 = call i32 @llvm.smin.i32(i32 %19, i32 0)
%31 = sub nuw nsw i32 %29, %30
%32 = zext i32 %31 to i64
%33 = icmp ult i32 %31, 8
br i1 %33, label %80, label %34
34: ; preds = %25
%35 = icmp ult i32 %31, 32
br i1 %35, label %62, label %36
36: ; preds = %34
%37 = and i64 %32, 4294967264
br label %38
38: ; preds = %38, %36
%39 = phi i64 [ 0, %36 ], [ %54, %38 ]
%40 = sub i64 %28, %39
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 -15
%43 = bitcast i8* %42 to <16 x i8>*
%44 = load <16 x i8>, <16 x i8>* %43
%45 = shufflevector <16 x i8> %44, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%46 = getelementptr inbounds i8, i8* %41, i64 -31
%47 = bitcast i8* %46 to <16 x i8>*
%48 = load <16 x i8>, <16 x i8>* %47
%49 = shufflevector <16 x i8> %48, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%50 = getelementptr inbounds i8, i8* %1, i64 %39
%51 = bitcast i8* %50 to <16 x i8>*
store <16 x i8> %45, <16 x i8>* %51
%52 = getelementptr inbounds i8, i8* %50, i64 16
%53 = bitcast i8* %52 to <16 x i8>*
store <16 x i8> %49, <16 x i8>* %53
%54 = add nuw i64 %39, 32
%55 = icmp eq i64 %54, %37
br i1 %55, label %56, label %38
56: ; preds = %38
%57 = icmp eq i64 %37, %32
br i1 %57, label %92, label %58
58: ; preds = %56
%59 = sub nsw i64 %28, %37
%60 = and i64 %32, 24
%61 = icmp eq i64 %60, 0
br i1 %61, label %80, label %62
62: ; preds = %34, %58
%63 = phi i64 [ %37, %58 ], [ 0, %34 ]
%64 = and i64 %32, 4294967288
%65 = sub nsw i64 %28, %64
br label %66
66: ; preds = %66, %62
%67 = phi i64 [ %63, %62 ], [ %76, %66 ]
%68 = sub i64 %28, %67
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %68
%70 = getelementptr inbounds i8, i8* %69, i64 -7
%71 = bitcast i8* %70 to <8 x i8>*
%72 = load <8 x i8>, <8 x i8>* %71
%73 = shufflevector <8 x i8> %72, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%74 = getelementptr inbounds i8, i8* %1, i64 %67
%75 = bitcast i8* %74 to <8 x i8>*
store <8 x i8> %73, <8 x i8>* %75
%76 = add nuw i64 %67, 8
%77 = icmp eq i64 %76, %64
br i1 %77, label %78, label %66
78: ; preds = %66
%79 = icmp eq i64 %64, %32
br i1 %79, label %92, label %80
80: ; preds = %25, %58, %78
%81 = phi i64 [ 0, %25 ], [ %37, %58 ], [ %64, %78 ]
%82 = phi i64 [ %28, %25 ], [ %59, %58 ], [ %65, %78 ]
br label %83
83: ; preds = %80, %83
%84 = phi i64 [ %89, %83 ], [ %81, %80 ]
%85 = phi i64 [ %90, %83 ], [ %82, %80 ]
%86 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = getelementptr inbounds i8, i8* %1, i64 %84
store i8 %87, i8* %88
%89 = add nuw nsw i64 %84, 1
%90 = add nsw i64 %85, -1
%91 = icmp eq i64 %89, %32
br i1 %91, label %92, label %83
92: ; preds = %83, %78, %56
%93 = zext i32 %31 to i64
br label %94
94: ; preds = %92, %6
%95 = phi i64 [ %93, %92 ], [ 1, %6 ]
%96 = getelementptr inbounds i8, i8* %1, i64 %95
store i8 0, i8* %96
ret void
}