#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 */
struct _buffer_circ {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ajouterBC(struct _buffer_circ *, void *);
struct _buffer_circ *newBufferCirc(int);
int /*<<< orphan*/ printf(char *, void *);
void *retirer(struct _buffer_circ *);
int /*<<< orphan*/ trace(struct _buffer_circ *);
int main() {
  int i;
  struct _buffer_circ *buff = newBufferCirc(10);
  void *elem;
  for (i = 0; i < 15; i++) {
    ajouterBC(buff, (void *)(intptr_t)(i + 1));
    trace(buff);
  }
  for (i = 0; i < 11; i++) {
    elem = retirer(buff);
    printf("li %p", elem);
    trace(buff);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1040 <newBufferCirc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xf,-0x8(%rbp)
jge    11a7 <main+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rsi
call   1050 <ajouterBC@plt>
mov    -0x10(%rbp),%rdi
call   1070 <trace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x24>
movl   $0x0,-0x8(%rbp)
cmpl   $0xb,-0x8(%rbp)
jge    11ec <main+0x9c>
mov    -0x10(%rbp),%rdi
call   1060 <retirer@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <trace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <main+0x5e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xa,%edi
call   1040 <newBufferCirc@plt>
mov    %rax,%rbx
mov    $0x1,%esi
mov    %rax,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x3,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x5,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x6,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x7,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0x9,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0xa,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0xb,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0xc,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0xd,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0xe,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <ajouterBC@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
lea    0xd55(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
mov    %rbx,%rdi
call   1060 <retirer@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <trace@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct._buffer_circ = type { i32 }
@.str = [6 x i8] c"li %p\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct._buffer_circ*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call %struct._buffer_circ* @newBufferCirc(i32 10)
store %struct._buffer_circ* %5, %struct._buffer_circ** %3
store i32 0, i32* %2
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 15
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load %struct._buffer_circ*, %struct._buffer_circ** %3
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
%15 = call i32 @ajouterBC(%struct._buffer_circ* %10, i8* %14)
%16 = load %struct._buffer_circ*, %struct._buffer_circ** %3
%17 = call i32 @trace(%struct._buffer_circ* %16)
br label %18
18: ; preds = %9
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %6
21: ; preds = %6
store i32 0, i32* %2
br label %22
22: ; preds = %32, %21
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 11
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load %struct._buffer_circ*, %struct._buffer_circ** %3
%27 = call i8* @retirer(%struct._buffer_circ* %26)
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load %struct._buffer_circ*, %struct._buffer_circ** %3
%31 = call i32 @trace(%struct._buffer_circ* %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %22
35: ; preds = %22
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
%struct._buffer_circ = type { i32 }
@.str = [6 x i8] c"li %p\00"
define i32 @main() {
%1 = tail call %struct._buffer_circ* @newBufferCirc(i32 10)
%2 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 1 to i8*))
%3 = tail call i32 @trace(%struct._buffer_circ* %1)
%4 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 2 to i8*))
%5 = tail call i32 @trace(%struct._buffer_circ* %1)
%6 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 3 to i8*))
%7 = tail call i32 @trace(%struct._buffer_circ* %1)
%8 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 4 to i8*))
%9 = tail call i32 @trace(%struct._buffer_circ* %1)
%10 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 5 to i8*))
%11 = tail call i32 @trace(%struct._buffer_circ* %1)
%12 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 6 to i8*))
%13 = tail call i32 @trace(%struct._buffer_circ* %1)
%14 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 7 to i8*))
%15 = tail call i32 @trace(%struct._buffer_circ* %1)
%16 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 8 to i8*))
%17 = tail call i32 @trace(%struct._buffer_circ* %1)
%18 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 9 to i8*))
%19 = tail call i32 @trace(%struct._buffer_circ* %1)
%20 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 10 to i8*))
%21 = tail call i32 @trace(%struct._buffer_circ* %1)
%22 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 11 to i8*))
%23 = tail call i32 @trace(%struct._buffer_circ* %1)
%24 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 12 to i8*))
%25 = tail call i32 @trace(%struct._buffer_circ* %1)
%26 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 13 to i8*))
%27 = tail call i32 @trace(%struct._buffer_circ* %1)
%28 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 14 to i8*))
%29 = tail call i32 @trace(%struct._buffer_circ* %1)
%30 = tail call i32 @ajouterBC(%struct._buffer_circ* %1, i8* inttoptr (i64 15 to i8*))
%31 = tail call i32 @trace(%struct._buffer_circ* %1)
%32 = tail call i8* @retirer(%struct._buffer_circ* %1)
%33 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = tail call i32 @trace(%struct._buffer_circ* %1)
%35 = tail call i8* @retirer(%struct._buffer_circ* %1)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = tail call i32 @trace(%struct._buffer_circ* %1)
%38 = tail call i8* @retirer(%struct._buffer_circ* %1)
%39 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = tail call i32 @trace(%struct._buffer_circ* %1)
%41 = tail call i8* @retirer(%struct._buffer_circ* %1)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %41)
%43 = tail call i32 @trace(%struct._buffer_circ* %1)
%44 = tail call i8* @retirer(%struct._buffer_circ* %1)
%45 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %44)
%46 = tail call i32 @trace(%struct._buffer_circ* %1)
%47 = tail call i8* @retirer(%struct._buffer_circ* %1)
%48 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %47)
%49 = tail call i32 @trace(%struct._buffer_circ* %1)
%50 = tail call i8* @retirer(%struct._buffer_circ* %1)
%51 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %50)
%52 = tail call i32 @trace(%struct._buffer_circ* %1)
%53 = tail call i8* @retirer(%struct._buffer_circ* %1)
%54 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %53)
%55 = tail call i32 @trace(%struct._buffer_circ* %1)
%56 = tail call i8* @retirer(%struct._buffer_circ* %1)
%57 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %56)
%58 = tail call i32 @trace(%struct._buffer_circ* %1)
%59 = tail call i8* @retirer(%struct._buffer_circ* %1)
%60 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %59)
%61 = tail call i32 @trace(%struct._buffer_circ* %1)
%62 = tail call i8* @retirer(%struct._buffer_circ* %1)
%63 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %62)
%64 = tail call i32 @trace(%struct._buffer_circ* %1)
ret i32 0
}