#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 atoi(char *);
char getchar();
int /*<<< orphan*/ printf(char *);
void init(int *s) {
  char c;
  char tmp[6];
  int i = 0, j = 0;
  printf("Please enter the integer numbers, and each number should have fewer "
         "than 5 digits:\n");
  while ((c = getchar()) != '\n') {
    if (c == ' ') {
      tmp[j] = '\0';
      s[i++] = atoi(tmp);
      j = 0;
      continue;
    } else {
      tmp[j++] = c;
    }
  }
  s[i++] = atoi(tmp);
  s[i] = '\0';
}


x86 assembly (clang, -O0):
<init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11c7 <init+0x97>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jne    11ae <init+0x7e>
movslq -0x18(%rbp),%rax
movb   $0x0,-0xf(%rbp,%rax,1)
lea    -0xf(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x0,-0x18(%rbp)
jmp    1156 <init+0x26>
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0xf(%rbp,%rax,1)
jmp    1156 <init+0x26>
lea    -0xf(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0x2(%rsp),%r14
xor    %r12d,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1199 <init+0x69>
cmp    $0x20,%al
je     1180 <init+0x50>
mov    %al,0x2(%rsp,%rbx,1)
add    $0x1,%rbx
jmp    1160 <init+0x30>
nopl   0x0(%rax)
mov    %ebx,%eax
movb   $0x0,0x2(%rsp,%rax,1)
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r15,%r12,4)
add    $0x1,%r12
jmp    114f <init+0x1f>
lea    0x2(%rsp),%rdi
call   1050 <atoi@plt>
mov    %r12d,%ecx
add    $0x1,%r12d
mov    %eax,(%r15,%rcx,4)
movl   $0x0,(%r15,%r12,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [84 x i8] c"Please enter the integer numbers, and each number should have fewer than 5 digits:\0A\00"
define void @init(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca [6 x i8]
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %33, %16, %1
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %34
12: ; preds = %8
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %18
store i8 0, i8* %19
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
%22 = load i32*, i32** %2
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
store i32 %21, i32* %26
store i32 0, i32* %6
br label %8
27: ; preds = %12
%28 = load i8, i8* %3
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 %31
store i8 %28, i8* %32
br label %33
33: ; preds = %27
br label %8
34: ; preds = %8
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%36 = call i32 @atoi(i8* %35)
%37 = load i32*, i32** %2
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i32, i32* %37, i64 %40
store i32 %36, i32* %41
%42 = load i32*, i32** %2
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 0, i32* %45
ret void
}

LLVM IR (-O2):
@str = [83 x i8] c"Please enter the integer numbers, and each number should have fewer than 5 digits:\00"
define void @init(i32* nocapture writeonly %0) {
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %10, %1
%6 = phi i64 [ %14, %10 ], [ 0, %1 ]
br label %7
7: ; preds = %5, %16
%8 = phi i64 [ 0, %5 ], [ %17, %16 ]
%9 = tail call signext i8 (...) @getchar()
switch i8 %9, label %16 [
i8 10, label %19
i8 32, label %10
]
10: ; preds = %7
%11 = and i64 %8, 4294967295
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 @atoi(i8* %3)
%14 = add nuw i64 %6, 1
%15 = getelementptr inbounds i32, i32* %0, i64 %6
store i32 %13, i32* %15
br label %5
16: ; preds = %7
%17 = add nuw i64 %8, 1
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %8
store i8 %9, i8* %18
br label %7
19: ; preds = %7
%20 = call i32 @atoi(i8* %3)
%21 = add i64 %6, 1
%22 = and i64 %6, 4294967295
%23 = getelementptr inbounds i32, i32* %0, i64 %22
store i32 %20, i32* %23
%24 = and i64 %21, 4294967295
%25 = getelementptr inbounds i32, i32* %0, i64 %24
store i32 0, i32* %25
ret void
}