#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 eclate(char *, char *, char *);
int interclate(char *, char *, char *, char *, int);
void tri_externe(char nom[]) {
  int nb, n = 0, L = 1;
  nb = eclate(nom, "f1", "f2");
  while (nb > 1) {
    n = !n;
    if (n)
      nb = interclate("f1", "f2", "f3", "f4", L);
    else
      nb = interclate("f3", "f4", "f1", "f2", L);
    L = L * 2;
  }
}


x86 assembly (clang, -O0):
<tri_externe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebb(%rip),%rsi
lea    0xeb7(%rip),%rdx
call   1030 <eclate@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    11dc <tri_externe+0xbc>
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a6 <tri_externe+0x86>
mov    -0x14(%rbp),%r8d
lea    0xe7c(%rip),%rdi
lea    0xe78(%rip),%rsi
lea    0xe74(%rip),%rdx
lea    0xe70(%rip),%rcx
call   1040 <interclate@plt>
mov    %eax,-0xc(%rbp)
jmp    11ce <tri_externe+0xae>
mov    -0x14(%rbp),%r8d
lea    0xe55(%rip),%rdi
lea    0xe51(%rip),%rsi
lea    0xe41(%rip),%rdx
lea    0xe3d(%rip),%rcx
call   1040 <interclate@plt>
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <tri_externe+0x34>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tri_externe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rsi
lea    0xeca(%rip),%rdx
call   1030 <eclate@plt>
cmp    $0x2,%eax
jl     11a0 <tri_externe+0x80>
xor    %ebp,%ebp
mov    $0x1,%ebx
lea    0xeaf(%rip),%r14
lea    0xeab(%rip),%r15
lea    0xea7(%rip),%r12
lea    0xea3(%rip),%r13
jmp    118e <tri_externe+0x6e>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %ebx,%r8d
call   1040 <interclate@plt>
xor    $0x1,%ebp
add    %ebx,%ebx
cmp    $0x1,%eax
jle    11a0 <tri_externe+0x80>
test   %ebp,%ebp
jne    1170 <tri_externe+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
jmp    117c <tri_externe+0x5c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"f1\00"
@.str.1 = [3 x i8] c"f2\00"
@.str.2 = [3 x i8] c"f3\00"
@.str.3 = [3 x i8] c"f4\00"
define void @tri_externe(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 1, i32* %5
%6 = load i8*, i8** %2
%7 = call i32 @eclate(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %7, i32* %3
br label %8
8: ; preds = %24, %1
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i32, i32* %5
%20 = call i32 @interclate(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %19)
store i32 %20, i32* %3
br label %24
21: ; preds = %11
%22 = load i32, i32* %5
%23 = call i32 @interclate(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 %23, i32* %3
br label %24
24: ; preds = %21, %18
%25 = load i32, i32* %5
%26 = mul nsw i32 %25, 2
store i32 %26, i32* %5
br label %8
27: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"f1\00"
@.str.1 = [3 x i8] c"f2\00"
@.str.2 = [3 x i8] c"f3\00"
@.str.3 = [3 x i8] c"f4\00"
define void @tri_externe(i8* %0) {
%2 = tail call i32 @eclate(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp sgt i32 %2, 1
br i1 %3, label %4, label %17
4: ; preds = %1, %13
%5 = phi i32 [ %15, %13 ], [ 1, %1 ]
%6 = phi i32 [ %8, %13 ], [ 0, %1 ]
%7 = icmp eq i32 %6, 0
%8 = xor i32 %6, 1
br i1 %7, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @interclate(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %13
11: ; preds = %4
%12 = tail call i32 @interclate(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ]
%15 = shl nsw i32 %5, 1
%16 = icmp sgt i32 %14, 1
br i1 %16, label %4, label %17
17: ; preds = %13, %1
ret void
}