#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*/ handle_prompt_error(int, int *);
int /*<<< orphan*/ printf(char *);
int prompt_value(char *, int *);
int *resize_tab(int *, unsigned int, unsigned int);
void do_resize(int array[], unsigned *old_size) {
  int errno = 0;
  unsigned new_size = 0;
  errno = prompt_value("\nNouvelle taille?", (int *)&new_size);
  handle_prompt_error(errno, array);
  array = resize_tab(array, *old_size, new_size);
  if (new_size > *old_size) {
    printf("Saisie des valeurs supplementaires du tableau\n");
    for (unsigned i = *old_size; i < new_size; i++) {
      errno += prompt_value("Valeur?", &array[i]);
      handle_prompt_error(errno, array);
    }
  }
  *old_size = new_size;
}


x86 assembly (clang, -O0):
<do_resize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <prompt_value@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <handle_prompt_error@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
call   1050 <resize_tab@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jbe    1202 <do_resize+0xc2>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    11fd <do_resize+0xbd>
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe69(%rip),%rdi
call   1060 <prompt_value@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <handle_prompt_error@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b7 <do_resize+0x77>
jmp    1202 <do_resize+0xc2>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_resize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
lea    0xea0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <prompt_value@plt>
mov    %eax,%r13d
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <handle_prompt_error@plt>
mov    (%r14),%esi
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
call   1050 <resize_tab@plt>
mov    %rax,%r15
mov    0x4(%rsp),%eax
cmp    (%r14),%eax
jbe    11ea <do_resize+0xaa>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%ebp
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jae    11ea <do_resize+0xaa>
lea    (%r15,%rbp,4),%rbx
lea    0xe5e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <prompt_value@plt>
add    %eax,%r13d
mov    %r13d,%edi
mov    %r15,%rsi
call   1040 <handle_prompt_error@plt>
add    $0x1,%rbp
mov    0x4(%rsp),%eax
add    $0x4,%rbx
cmp    %rax,%rbp
jb     11c0 <do_resize+0x80>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\0ANouvelle taille?\00"
@.str.1 = [47 x i8] c"Saisie des valeurs supplementaires du tableau\0A\00"
@.str.2 = [8 x i8] c"Valeur?\00"
define void @do_resize(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
store i32 0, i32* %6
%8 = call i32 @prompt_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = load i32*, i32** %3
%11 = call i32 @handle_prompt_error(i32 %9, i32* %10)
%12 = load i32*, i32** %3
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = load i32, i32* %6
%16 = call i32* @resize_tab(i32* %12, i32 %14, i32 %15)
store i32* %16, i32** %3
%17 = load i32, i32* %6
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = icmp ugt i32 %17, %19
br i1 %20, label %21, label %44
21: ; preds = %2
%22 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
store i32 %24, i32* %7
br label %25
25: ; preds = %40, %21
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp ult i32 %26, %27
br i1 %28, label %29, label %43
29: ; preds = %25
%30 = load i32*, i32** %3
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = call i32 @prompt_value(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, %34
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = load i32*, i32** %3
%39 = call i32 @handle_prompt_error(i32 %37, i32* %38)
br label %40
40: ; preds = %29
%41 = load i32, i32* %7
%42 = add i32 %41, 1
store i32 %42, i32* %7
br label %25
43: ; preds = %25
br label %44
44: ; preds = %43, %2
%45 = load i32, i32* %6
%46 = load i32*, i32** %4
store i32 %45, i32* %46
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0ANouvelle taille?\00"
@.str.2 = [8 x i8] c"Valeur?\00"
@str = [46 x i8] c"Saisie des valeurs supplementaires du tableau\00"
define void @do_resize(i32* %0, i32* nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 @prompt_value(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = call i32 @handle_prompt_error(i32 %5, i32* %0)
%7 = load i32, i32* %1
%8 = load i32, i32* %3
%9 = call i32* @resize_tab(i32* %0, i32 %7, i32 %8)
%10 = load i32, i32* %3
%11 = load i32, i32* %1
%12 = icmp ugt i32 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = load i32, i32* %3
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = zext i32 %15 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ %19, %18 ], [ %27, %20 ]
%22 = phi i32 [ %5, %18 ], [ %25, %20 ]
%23 = getelementptr inbounds i32, i32* %9, i64 %21
%24 = call i32 @prompt_value(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %23)
%25 = add nsw i32 %24, %22
%26 = call i32 @handle_prompt_error(i32 %25, i32* %9)
%27 = add nuw nsw i64 %21, 1
%28 = load i32, i32* %3
%29 = zext i32 %28 to i64
%30 = icmp ult i64 %27, %29
br i1 %30, label %20, label %31
31: ; preds = %20, %13, %2
%32 = phi i32 [ %16, %13 ], [ %10, %2 ], [ %28, %20 ]
store i32 %32, i32* %1
ret void
}