#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*/ sscanf(char const *, char *, char *, int *, char *);
void formaterChaineBatailleNavale(const char *chaine, int *ligne, int *colonne,
                                  int *direction) {
  int lig;
  char col, dir;
  sscanf(chaine, "%c%d %c", &col, &lig, &dir);
  *colonne = col - 'A';
  *ligne = lig - 1;
  switch (dir) {
  case 'H':
    *direction = 0;
    break;
  case 'B':
    *direction = 1;
    break;
  case 'G':
    *direction = 2;
    break;
  case 'D':
    *direction = 3;
    break;
  }
}


x86 assembly (clang, -O0):
<formaterChaineBatailleNavale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xee9(%rip),%rsi
lea    -0x25(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    -0x26(%rbp),%r8
call   1030 <sscanf@plt>
movsbl -0x25(%rbp),%ecx
add    $0xffffffbf,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
add    $0xffffffff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsbl -0x26(%rbp),%eax
add    $0xffffffbe,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x6,%eax
ja     11be <formaterChaineBatailleNavale+0xae>
mov    -0x30(%rbp),%rax
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    11be <formaterChaineBatailleNavale+0xae>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    11be <formaterChaineBatailleNavale+0xae>
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
jmp    11be <formaterChaineBatailleNavale+0xae>
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formaterChaineBatailleNavale>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
lea    0xed7(%rip),%rsi
lea    0xb(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0xa(%rsp),%r8
call   1030 <sscanf@plt>
movsbl 0xb(%rsp),%eax
add    $0xffffffbf,%eax
mov    %eax,(%rbx)
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,(%r15)
movsbl 0xa(%rsp),%eax
lea    -0x42(%rax),%ecx
cmp    $0x6,%ecx
ja     117b <formaterChaineBatailleNavale+0x6b>
mov    $0x65,%edx
bt     %ecx,%edx
jae    117b <formaterChaineBatailleNavale+0x6b>
cltq
lea    0xe97(%rip),%rcx
mov    -0x108(%rcx,%rax,4),%eax
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%c%d %c\00"
define void @formaterChaineBatailleNavale(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = load i8*, i8** %5
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %10, i32* %9, i8* %11)
%14 = load i8, i8* %10
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 65
%17 = load i32*, i32** %7
store i32 %16, i32* %17
%18 = load i32, i32* %9
%19 = sub nsw i32 %18, 1
%20 = load i32*, i32** %6
store i32 %19, i32* %20
%21 = load i8, i8* %11
%22 = sext i8 %21 to i32
switch i32 %22, label %31 [
i32 72, label %23
i32 66, label %25
i32 71, label %27
i32 68, label %29
]
23: ; preds = %4
%24 = load i32*, i32** %8
store i32 0, i32* %24
br label %31
25: ; preds = %4
%26 = load i32*, i32** %8
store i32 1, i32* %26
br label %31
27: ; preds = %4
%28 = load i32*, i32** %8
store i32 2, i32* %28
br label %31
29: ; preds = %4
%30 = load i32*, i32** %8
store i32 3, i32* %30
br label %31
31: ; preds = %4, %29, %27, %25, %23
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%c%d %c\00"
@switch.table.formaterChaineBatailleNavale = [7 x i32] [i32 1, i32 0, i32 3, i32 0, i32 0, i32 2, i32 0]
define void @formaterChaineBatailleNavale(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = bitcast i32* %5 to i8*
%9 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %6, i32* %5, i8* %7)
%10 = load i8, i8* %6
%11 = sext i8 %10 to i32
%12 = add nsw i32 %11, -65
store i32 %12, i32* %2
%13 = load i32, i32* %5
%14 = add nsw i32 %13, -1
store i32 %14, i32* %1
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = add nsw i32 %16, -66
%18 = icmp ult i32 %17, 7
br i1 %18, label %19, label %28
19: ; preds = %4
%20 = trunc i32 %17 to i8
%21 = lshr i8 101, %20
%22 = and i8 %21, 1
%23 = icmp eq i8 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = sext i32 %17 to i64
%26 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.formaterChaineBatailleNavale, i64 0, i64 %25
%27 = load i32, i32* %26
store i32 %27, i32* %3
br label %28
28: ; preds = %19, %4, %24
ret void
}