#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 sscanf(int /*<<< orphan*/, char *, char *, int *);
int nbMots(char *chaine) {
  char tampon[64];
  int compteur = 0, taille = 0;
  if (chaine)
    for (; sscanf(chaine += taille, "%63s%n", tampon, &taille) == 1;
         compteur++) {
    }
  return compteur;
}


x86 assembly (clang, -O0):
<nbMots>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1182 <nbMots+0x72>
jmp    113a <nbMots+0x2a>
mov    -0x58(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    %eax,%edi
lea    -0x50(%rbp),%rdx
lea    0xea8(%rip),%rsi
lea    -0x58(%rbp),%rcx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    117d <nbMots+0x6d>
jmp    116f <nbMots+0x5f>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    113a <nbMots+0x2a>
jmp    1182 <nbMots+0x72>
mov    -0x54(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbMots>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
movl   $0x0,0xc(%rsp)
xor    %ebp,%ebp
test   %rdi,%rdi
je     1180 <nbMots+0x70>
mov    %rdi,%rbx
lea    0xecb(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1180 <nbMots+0x70>
xor    %ebp,%ebp
lea    0xeae(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
add    $0x1,%ebp
movslq 0xc(%rsp),%rax
add    %rax,%rbx
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     1160 <nbMots+0x50>
mov    %ebp,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%63s%n\00"
define i32 @nbMots(i8* %0) {
%2 = alloca i8*
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %23
8: ; preds = %1
br label %9
9: ; preds = %19, %8
%10 = load i32, i32* %5
%11 = load i8*, i8** %2
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* %11, i64 %12
store i8* %13, i8** %2
%14 = ptrtoint i8* %13 to i32
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%16 = call i32 @sscanf(i32 %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %15, i32* %5)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %9
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %9
22: ; preds = %9
br label %23
23: ; preds = %22, %1
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [7 x i8] c"%63s%n\00"
define i32 @nbMots(i8* %0) {
%2 = alloca [64 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = icmp eq i8* %0, null
br i1 %6, label %23, label %7
7: ; preds = %1
%8 = ptrtoint i8* %0 to i64
%9 = trunc i64 %8 to i32
%10 = call i32 @sscanf(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4, i32* %3)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %23
12: ; preds = %7, %12
%13 = phi i8* [ %18, %12 ], [ %0, %7 ]
%14 = phi i32 [ %15, %12 ], [ 0, %7 ]
%15 = add nuw nsw i32 %14, 1
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
%19 = ptrtoint i8* %18 to i64
%20 = trunc i64 %19 to i32
%21 = call i32 @sscanf(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4, i32* %3)
%22 = icmp eq i32 %21, 1
br i1 %22, label %12, label %23
23: ; preds = %12, %7, %1
%24 = phi i32 [ 0, %1 ], [ 0, %7 ], [ %15, %12 ]
ret i32 %24
}