#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 count_tab_element(int *, unsigned int, int);
int /*<<< orphan*/ handle_prompt_error(int, int *);
int /*<<< orphan*/ printf(char *, int, int);
int prompt_value(char *, int *);
void do_count(int array[], unsigned size) {
  int errno = 0;
  int search_value = 0;
  errno = prompt_value("\nValeur a chercher?", &search_value);
  handle_prompt_error(errno, array);
  printf("La valeur %d est presente %d fois dans le tableau\n", search_value,
         count_tab_element(array, size, search_value));
}


x86 assembly (clang, -O0):
<do_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <prompt_value@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <handle_prompt_error@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <count_tab_element@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_count>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xea3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <prompt_value@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <handle_prompt_error@plt>
mov    0xc(%rsp),%ebp
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <count_tab_element@plt>
lea    0xe8b(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AValeur a chercher?\00"
@.str.1 = [51 x i8] c"La valeur %d est presente %d fois dans le tableau\0A\00"
define void @do_count(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @prompt_value(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = load i32*, i32** %3
%10 = call i32 @handle_prompt_error(i32 %8, i32* %9)
%11 = load i32, i32* %6
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = load i32, i32* %6
%15 = call i32 @count_tab_element(i32* %12, i32 %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0AValeur a chercher?\00"
@.str.1 = [51 x i8] c"La valeur %d est presente %d fois dans le tableau\0A\00"
define void @do_count(i32* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 @prompt_value(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = call i32 @handle_prompt_error(i32 %5, i32* %0)
%7 = load i32, i32* %3
%8 = call i32 @count_tab_element(i32* %0, i32 %1, i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
ret void
}