#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*/ memcpy(char *, char const *, int);
int utf8_char_size(char const *);
int utf8_strlen_screen(char *);
int utf8_char_size_screen(const char *string) {
  int char_size;
  char utf_char[16];
  if (!string)
    return 0;
  char_size = utf8_char_size(string);
  if (char_size == 0)
    return 0;
  memcpy(utf_char, string, char_size);
  utf_char[char_size] = '\0';
  return utf8_strlen_screen(utf_char);
}


x86 assembly (clang, -O0):
<utf8_char_size_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <utf8_char_size_screen+0x23>
movl   $0x0,-0x4(%rbp)
jmp    119a <utf8_char_size_screen+0x6a>
mov    -0x10(%rbp),%rdi
call   1050 <utf8_char_size@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1175 <utf8_char_size_screen+0x45>
movl   $0x0,-0x4(%rbp)
jmp    119a <utf8_char_size_screen+0x6a>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
call   1040 <utf8_strlen_screen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8_char_size_screen>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     116f <utf8_char_size_screen+0x3f>
mov    %rdi,%rbx
call   1050 <utf8_char_size@plt>
test   %eax,%eax
je     116f <utf8_char_size_screen+0x3f>
mov    %eax,%r14d
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <memcpy@plt>
movslq %r14d,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rbp,%rdi
call   1040 <utf8_strlen_screen@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @utf8_char_size_screen(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = tail call i32 @utf8_char_size(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = call i32 @memcpy(i8* %3, i8* %0, i32 %6)
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %10
store i8 0, i8* %11
%12 = call i32 @utf8_strlen_screen(i8* %3)
br label %13
13: ; preds = %5, %1, %8
%14 = phi i32 [ %12, %8 ], [ 0, %1 ], [ 0, %5 ]
ret i32 %14
}