#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*/ erreur(int, int);
char *mallocBis(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
char *incrementerInputOutput(char **tab, int *id, int max, int bool_input) {
  char *str_result;
  if (*id < max)
    str_result = tab[*id];
  else if (!bool_input) {
    if (*id < 100) {
      str_result = mallocBis(sizeof(char) * 11);
      sprintf(str_result, "output_%d", *id);
    } else
      erreur(33, 1);
  } else
    erreur(23, 1);
  *id = *id + 1;
  return str_result;
}


x86 assembly (clang, -O0):
<incrementerInputOutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jge    116d <incrementerInputOutput+0x3d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <incrementerInputOutput+0xa5>
cmpl   $0x0,-0x18(%rbp)
jne    11c1 <incrementerInputOutput+0x91>
mov    -0x10(%rbp),%rax
cmpl   $0x64,(%rax)
jge    11ad <incrementerInputOutput+0x7d>
mov    $0xb,%edi
call   1040 <mallocBis@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe5d(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11bc <incrementerInputOutput+0x8c>
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <erreur@plt>
jmp    11d0 <incrementerInputOutput+0xa0>
mov    $0x17,%edi
mov    $0x1,%esi
call   1030 <erreur@plt>
jmp    11d5 <incrementerInputOutput+0xa5>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<incrementerInputOutput>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movslq (%rsi),%rax
cmp    %edx,%eax
jge    1144 <incrementerInputOutput+0x14>
mov    (%rdi,%rax,8),%rbx
jmp    1184 <incrementerInputOutput+0x54>
test   %ecx,%ecx
je     114f <incrementerInputOutput+0x1f>
mov    $0x17,%edi
jmp    117a <incrementerInputOutput+0x4a>
cmp    $0x63,%eax
jg     1175 <incrementerInputOutput+0x45>
mov    $0xb,%edi
call   1040 <mallocBis@plt>
mov    %rax,%rbx
mov    (%r14),%edx
lea    0xe95(%rip),%rsi
mov    %rax,%rdi
call   1050 <sprintf@plt>
jmp    1184 <incrementerInputOutput+0x54>
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <erreur@plt>
addl   $0x1,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"output_%d\00"
define i8* @incrementerInputOutput(i8** %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8** %0, i8*** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %4
%15 = load i8**, i8*** %5
%16 = load i32*, i32** %6
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
%20 = load i8*, i8** %19
store i8* %20, i8** %9
br label %40
21: ; preds = %4
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %21
%25 = load i32*, i32** %6
%26 = load i32, i32* %25
%27 = icmp slt i32 %26, 100
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = call i8* @mallocBis(i32 11)
store i8* %29, i8** %9
%30 = load i8*, i8** %9
%31 = load i32*, i32** %6
%32 = load i32, i32* %31
%33 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %24
%35 = call i32 @erreur(i32 33, i32 1)
br label %36
36: ; preds = %34, %28
br label %39
37: ; preds = %21
%38 = call i32 @erreur(i32 23, i32 1)
br label %39
39: ; preds = %37, %36
br label %40
40: ; preds = %39, %14
%41 = load i32*, i32** %6
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
%44 = load i32*, i32** %6
store i32 %43, i32* %44
%45 = load i8*, i8** %9
ret i8* %45
}

LLVM IR (-O2):
@.str = [10 x i8] c"output_%d\00"
define i8* @incrementerInputOutput(i8** nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, %2
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = load i8*, i8** %9
br label %23
11: ; preds = %4
%12 = icmp eq i32 %3, 0
br i1 %12, label %13, label %21
13: ; preds = %11
%14 = icmp slt i32 %5, 100
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = tail call i8* @mallocBis(i32 11)
%17 = load i32, i32* %1
%18 = tail call i32 @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %23
19: ; preds = %13
%20 = tail call i32 @erreur(i32 33, i32 1)
br label %23
21: ; preds = %11
%22 = tail call i32 @erreur(i32 23, i32 1)
br label %23
23: ; preds = %21, %19, %15, %7
%24 = phi i8* [ %10, %7 ], [ undef, %21 ], [ %16, %15 ], [ undef, %19 ]
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
ret i8* %24
}