#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 intlist2str(int, int *, char *);
int itemcount(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ str2intlist(int, char *, int *);
void test_intlist2str(void) {
  int i, n, nbc;
  char s[80];
  printf("give the number of integers : ");
  scanf("%d", &n);
  {
    int data[n];
    for (i = 0; i < n; i++) {
      printf("-> give element %d : ", i);
      scanf("%d", &data[i]);
    }
    printf("The %d numbers : ", n);
    for (i = 0; i < n; i++)
      printf(" %d", data[i]);
    printf("\n");
    nbc = intlist2str(n, data, s);
  }
  printf("The string : %s\n", s);
  {
    int ict = itemcount(s);
    int nbr[ict];
    int i;
    printf("number of items : %d\n", ict);
    str2intlist(n, s, nbr);
    printf("the %d numbers :", ict);
    for (i = 0; i < ict; i++)
      printf(" %d", nbr[i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<test_intlist2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f3 <test_intlist2str+0xa3>
mov    -0x4(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x98(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe68(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <test_intlist2str+0x5a>
mov    -0x8(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1241 <test_intlist2str+0xf1>
mov    -0x98(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    120b <test_intlist2str+0xbb>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xa9(%rbp)
call   1040 <printf@plt>
mov    -0x98(%rbp),%rsi
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    %rdx,-0xa8(%rbp)
call   1030 <intlist2str@plt>
mov    -0xa8(%rbp),%rsi
mov    %eax,%ecx
mov    -0xa9(%rbp),%al
mov    %ecx,-0xc(%rbp)
mov    -0x68(%rbp),%rcx
mov    %rcx,%rsp
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1050 <itemcount@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x74(%rbp),%esi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa0(%rbp),%rdx
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1070 <str2intlist@plt>
mov    -0x74(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1351 <test_intlist2str+0x201>
mov    -0xa0(%rbp),%rax
movslq -0x8c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    130f <test_intlist2str+0x1bf>
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_intlist2str>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    11fc <test_intlist2str+0x9c>
mov    %r15,-0x38(%rbp)
lea    0xe63(%rip),%r14
lea    0xe85(%rip),%r15
mov    %r12,%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11d0 <test_intlist2str+0x70>
mov    -0x38(%rbp),%r15
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    123b <test_intlist2str+0xdb>
lea    0xe30(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1220 <test_intlist2str+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%edi
lea    -0x90(%rbp),%r14
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <intlist2str@plt>
mov    %r15,%rsp
lea    0xde7(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1060 <itemcount@plt>
mov    %eax,%r15d
mov    %rsp,-0x38(%rbp)
mov    %eax,%r13d
mov    %rsp,%r12
lea    0xf(,%r13,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xdc0(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1080 <str2intlist@plt>
lea    0xdb7(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
jle    12f7 <test_intlist2str+0x197>
lea    0xd76(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    12e0 <test_intlist2str+0x180>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"give the number of integers : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"-> give element %d : \00"
@.str.3 = [18 x i8] c"The %d numbers : \00"
@.str.4 = [4 x i8] c" %d\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [17 x i8] c"The string : %s\0A\00"
@.str.7 = [22 x i8] c"number of items : %d\0A\00"
@.str.8 = [17 x i8] c"the %d numbers :\00"
define void @test_intlist2str() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %5
%16 = alloca i32, i64 %14
store i64 %14, i64* %6
store i32 0, i32* %1
br label %17
17: ; preds = %28, %0
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %16, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %17
31: ; preds = %17
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %32)
store i32 0, i32* %1
br label %34
34: ; preds = %44, %31
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i32, i32* %1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %16, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %1
%46 = add nsw i32 %45, 1
store i32 %46, i32* %1
br label %34
47: ; preds = %34
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* %2
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%51 = call i32 @intlist2str(i32 %49, i32* %16, i8* %50)
store i32 %51, i32* %3
%52 = load i8*, i8** %5
%53 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%56 = call i32 @itemcount(i8* %55)
store i32 %56, i32* %7
%57 = load i32, i32* %7
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %8
%60 = alloca i32, i64 %58
store i64 %58, i64* %9
%61 = load i32, i32* %7
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %2
%64 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%65 = call i32 @str2intlist(i32 %63, i8* %64, i32* %60)
%66 = load i32, i32* %7
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %66)
store i32 0, i32* %10
br label %68
68: ; preds = %78, %47
%69 = load i32, i32* %10
%70 = load i32, i32* %7
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %81
72: ; preds = %68
%73 = load i32, i32* %10
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %60, i64 %74
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %72
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
br label %68
81: ; preds = %68
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%83 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"give the number of integers : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"-> give element %d : \00"
@.str.3 = [18 x i8] c"The %d numbers : \00"
@.str.4 = [4 x i8] c" %d\00"
@.str.6 = [17 x i8] c"The string : %s\0A\00"
@.str.7 = [22 x i8] c"number of items : %d\0A\00"
@.str.8 = [17 x i8] c"the %d numbers :\00"
define void @test_intlist2str() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %0, %13
%14 = phi i64 [ %19, %13 ], [ 0, %0 ]
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %10, i64 %14
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %14, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %0
%24 = phi i32 [ %11, %0 ], [ %20, %13 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %23, %28
%29 = phi i64 [ %33, %28 ], [ 0, %23 ]
%30 = getelementptr inbounds i32, i32* %10, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = add nuw nsw i64 %29, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %28, label %37
37: ; preds = %28, %23
%38 = call i32 @putchar(i32 10)
%39 = load i32, i32* %1
%40 = call i32 @intlist2str(i32 %39, i32* %10, i8* %4)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%42 = call i32 @itemcount(i8* %4)
%43 = zext i32 %42 to i64
%44 = call i8* @llvm.stacksave()
%45 = alloca i32, i64 %43
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%47 = load i32, i32* %1
%48 = call i32 @str2intlist(i32 %47, i8* %4, i32* %45)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %42)
%50 = icmp sgt i32 %42, 0
br i1 %50, label %51, label %58
51: ; preds = %37, %51
%52 = phi i64 [ %56, %51 ], [ 0, %37 ]
%53 = getelementptr inbounds i32, i32* %45, i64 %52
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = add nuw nsw i64 %52, 1
%57 = icmp eq i64 %56, %43
br i1 %57, label %58, label %51
58: ; preds = %51, %37
%59 = call i32 @putchar(i32 10)
ret void
}