#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 */
char caractereClavier();
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int changeNom(char nomJ1[15], char nomJ2[15], int joueurActuel) {
  char caractere = caractereClavier();
  char c[1] = {caractere};
  if (caractere > 31 && caractere < 127) {
    if (joueurActuel == 0 && strlen(nomJ1) < 14) {
      strcat(nomJ1, c);
    } else if (joueurActuel == 1 && strlen(nomJ2) < 14) {
      strcat(nomJ2, c);
    }
  }
  if (caractere == 8) {
    if (joueurActuel == 0) {
      nomJ1[strlen(nomJ1) - 1] = (char)0;
    } else if (joueurActuel == 1) {
      nomJ2[strlen(nomJ2) - 1] = (char)0;
    }
  } else if (caractere == 13) {
    joueurActuel = joueurActuel + 1;
  }
  return joueurActuel;
}


x86 assembly (clang, -O0):
<changeNom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1040 <caractereClavier@plt>
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
mov    %al,-0x16(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x1f,%eax
jle    11ce <changeNom+0x9e>
movsbl -0x15(%rbp),%eax
cmp    $0x7f,%eax
jge    11ce <changeNom+0x9e>
cmpl   $0x0,-0x14(%rbp)
jne    119b <changeNom+0x6b>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xe,%eax
jge    119b <changeNom+0x6b>
mov    -0x8(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1050 <strcat@plt>
jmp    11c9 <changeNom+0x99>
cmpl   $0x1,-0x14(%rbp)
jne    11c4 <changeNom+0x94>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xe,%eax
jge    11c4 <changeNom+0x94>
mov    -0x10(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1050 <strcat@plt>
jmp    11c9 <changeNom+0x99>
jmp    11ce <changeNom+0x9e>
movsbl -0x15(%rbp),%eax
cmp    $0x8,%eax
jne    1240 <changeNom+0x110>
cmpl   $0x0,-0x14(%rbp)
jne    120b <changeNom+0xdb>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    123b <changeNom+0x10b>
cmpl   $0x1,-0x14(%rbp)
jne    1236 <changeNom+0x106>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    123b <changeNom+0x10b>
jmp    125b <changeNom+0x12b>
movsbl -0x15(%rbp),%eax
cmp    $0xd,%eax
jne    1256 <changeNom+0x126>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125b <changeNom+0x12b>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<changeNom>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <caractereClavier@plt>
mov    %eax,%ebx
mov    %al,0x7(%rsp)
lea    -0x20(%rbx),%eax
cmp    $0x5e,%al
ja     1188 <changeNom+0x58>
cmp    $0x1,%ebp
je     116e <changeNom+0x3e>
test   %ebp,%ebp
jne    1188 <changeNom+0x58>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
cmp    $0xe,%eax
jl     117e <changeNom+0x4e>
jmp    1188 <changeNom+0x58>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
cmp    $0xd,%eax
jg     1188 <changeNom+0x58>
lea    0x7(%rsp),%rsi
call   1050 <strcat@plt>
cmp    $0xd,%bl
je     11af <changeNom+0x7f>
cmp    $0x8,%bl
jne    11c9 <changeNom+0x99>
cmp    $0x1,%ebp
je     11b4 <changeNom+0x84>
test   %ebp,%ebp
jne    11c9 <changeNom+0x99>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
xor    %ebp,%ebp
jmp    11c9 <changeNom+0x99>
add    $0x1,%ebp
jmp    11c9 <changeNom+0x99>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @changeNom(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca [1 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = call signext i8 (...) @caractereClavier()
store i8 %9, i8* %7
%10 = getelementptr inbounds [1 x i8], [1 x i8]* %8, i64 0, i64 0
%11 = load i8, i8* %7
store i8 %11, i8* %10
%12 = load i8, i8* %7
%13 = sext i8 %12 to i32
%14 = icmp sgt i32 %13, 31
br i1 %14, label %15, label %43
15: ; preds = %3
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 127
br i1 %18, label %19, label %43
19: ; preds = %15
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = icmp slt i32 %24, 14
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = getelementptr inbounds [1 x i8], [1 x i8]* %8, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
br label %42
30: ; preds = %22, %19
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i8*, i8** %5
%35 = call i32 @strlen(i8* %34)
%36 = icmp slt i32 %35, 14
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i8*, i8** %5
%39 = getelementptr inbounds [1 x i8], [1 x i8]* %8, i64 0, i64 0
%40 = call i32 @strcat(i8* %38, i8* %39)
br label %41
41: ; preds = %37, %33, %30
br label %42
42: ; preds = %41, %26
br label %43
43: ; preds = %42, %15, %3
%44 = load i8, i8* %7
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 8
br i1 %46, label %47, label %69
47: ; preds = %43
%48 = load i32, i32* %6
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %57
50: ; preds = %47
%51 = load i8*, i8** %4
%52 = load i8*, i8** %4
%53 = call i32 @strlen(i8* %52)
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
store i8 0, i8* %56
br label %68
57: ; preds = %47
%58 = load i32, i32* %6
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %67
60: ; preds = %57
%61 = load i8*, i8** %5
%62 = load i8*, i8** %5
%63 = call i32 @strlen(i8* %62)
%64 = sub nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %61, i64 %65
store i8 0, i8* %66
br label %67
67: ; preds = %60, %57
br label %68
68: ; preds = %67, %50
br label %77
69: ; preds = %43
%70 = load i8, i8* %7
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 13
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %76
76: ; preds = %73, %69
br label %77
77: ; preds = %76, %68
%78 = load i32, i32* %6
ret i32 %78
}

LLVM IR (-O2):
define i32 @changeNom(i8* %0, i8* %1, i32 %2) {
%4 = alloca [1 x i8]
%5 = tail call signext i8 (...) @caractereClavier()
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
store i8 %5, i8* %6
%7 = add i8 %5, -32
%8 = icmp ult i8 %7, 95
br i1 %8, label %9, label %19
9: ; preds = %3
switch i32 %2, label %19 [
i32 0, label %10
i32 1, label %13
]
10: ; preds = %9
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp slt i32 %11, 14
br i1 %12, label %16, label %19
13: ; preds = %9
%14 = tail call i32 @strlen(i8* %1)
%15 = icmp slt i32 %14, 14
br i1 %15, label %16, label %19
16: ; preds = %13, %10
%17 = phi i8* [ %0, %10 ], [ %1, %13 ]
%18 = call i32 @strcat(i8* %17, i8* %6)
br label %19
19: ; preds = %16, %10, %9, %13, %3
switch i8 %5, label %33 [
i8 8, label %20
i8 13, label %31
]
20: ; preds = %19
switch i32 %2, label %33 [
i32 0, label %21
i32 1, label %26
]
21: ; preds = %20
%22 = call i32 @strlen(i8* %0)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
store i8 0, i8* %25
br label %33
26: ; preds = %20
%27 = call i32 @strlen(i8* %1)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %1, i64 %29
store i8 0, i8* %30
br label %33
31: ; preds = %19
%32 = add nsw i32 %2, 1
br label %33
33: ; preds = %19, %20, %31, %21, %26
%34 = phi i32 [ 0, %21 ], [ 1, %26 ], [ %32, %31 ], [ %2, %20 ], [ %2, %19 ]
ret i32 %34
}