#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 */
typedef char wchar_t;

/* Variables and functions */
scalar_t__ ft_wchrsize_utf8(char const);
size_t ft_wstrsize_utf8(const wchar_t *ws) {
  size_t size;
  if (!ws)
    return (0);
  size = 0;
  while (*ws != '\0') {
    size += ft_wchrsize_utf8(*ws);
    ws++;
  }
  return (size);
}


x86 assembly (clang, -O0):
<ft_wstrsize_utf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <ft_wstrsize_utf8+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1179 <ft_wstrsize_utf8+0x69>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1171 <ft_wstrsize_utf8+0x61>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <ft_wchrsize_utf8@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <ft_wstrsize_utf8+0x2c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_wstrsize_utf8>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1148 <ft_wstrsize_utf8+0x38>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1148 <ft_wstrsize_utf8+0x38>
add    $0x1,%rbx
xor    %r14d,%r14d
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <ft_wchrsize_utf8@plt>
add    %rax,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <ft_wstrsize_utf8+0x20>
jmp    114b <ft_wstrsize_utf8+0x3b>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @ft_wstrsize_utf8(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i64 0, i64* %2
br label %24
8: ; preds = %1
store i64 0, i64* %4
br label %9
9: ; preds = %14, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = call i64 @ft_wchrsize_utf8(i8 signext %16)
%18 = load i64, i64* %4
%19 = add i64 %18, %17
store i64 %19, i64* %4
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %9
22: ; preds = %9
%23 = load i64, i64* %4
store i64 %23, i64* %2
br label %24
24: ; preds = %22, %7
%25 = load i64, i64* %2
ret i64 %25
}

LLVM IR (-O2):
define i64 @ft_wstrsize_utf8(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %3, %6
%7 = phi i8 [ %13, %6 ], [ %4, %3 ]
%8 = phi i64 [ %11, %6 ], [ 0, %3 ]
%9 = phi i8* [ %12, %6 ], [ %0, %3 ]
%10 = tail call i64 @ft_wchrsize_utf8(i8 signext %7)
%11 = add i64 %10, %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %3, %1
%16 = phi i64 [ 0, %1 ], [ 0, %3 ], [ %11, %6 ]
ret i64 %16
}