#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 */
struct t_upgrade_file {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ upgrade_file_read_string(struct t_upgrade_file *, char **);
int /*<<< orphan*/ utf8_normalize(char *, char);
int upgrade_file_read_string_utf8(struct t_upgrade_file *upgrade_file,
                                  char **string) {
  if (!upgrade_file_read_string(upgrade_file, string))
    return 0;
  if (string && *string)
    utf8_normalize(*string, '?');
  return 1;
}


x86 assembly (clang, -O0):
<upgrade_file_read_string_utf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <upgrade_file_read_string@plt>
cmp    $0x0,%eax
jne    1152 <upgrade_file_read_string_utf8+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1183 <upgrade_file_read_string_utf8+0x63>
cmpq   $0x0,-0x18(%rbp)
je     117c <upgrade_file_read_string_utf8+0x5c>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     117c <upgrade_file_read_string_utf8+0x5c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3f,%esi
call   1040 <utf8_normalize@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upgrade_file_read_string_utf8>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1030 <upgrade_file_read_string@plt>
test   %eax,%eax
je     114d <upgrade_file_read_string_utf8+0x2d>
mov    $0x1,%ebp
test   %rbx,%rbx
je     114f <upgrade_file_read_string_utf8+0x2f>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     114f <upgrade_file_read_string_utf8+0x2f>
mov    $0x3f,%esi
call   1040 <utf8_normalize@plt>
jmp    114f <upgrade_file_read_string_utf8+0x2f>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.t_upgrade_file = type { i32 }
define i32 @upgrade_file_read_string_utf8(%struct.t_upgrade_file* %0, i8** %1) {
%3 = alloca i32
%4 = alloca %struct.t_upgrade_file*
%5 = alloca i8**
store %struct.t_upgrade_file* %0, %struct.t_upgrade_file** %4
store i8** %1, i8*** %5
%6 = load %struct.t_upgrade_file*, %struct.t_upgrade_file** %4
%7 = load i8**, i8*** %5
%8 = call i32 @upgrade_file_read_string(%struct.t_upgrade_file* %6, i8** %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %2
store i32 0, i32* %3
br label %23
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = icmp ne i8** %12, null
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = call i32 @utf8_normalize(i8* %20, i8 signext 63)
br label %22
22: ; preds = %18, %14, %11
store i32 1, i32* %3
br label %23
23: ; preds = %22, %10
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.t_upgrade_file = type { i32 }
define i32 @upgrade_file_read_string_utf8(%struct.t_upgrade_file* %0, i8** %1) {
%3 = tail call i32 @upgrade_file_read_string(%struct.t_upgrade_file* %0, i8** %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = icmp eq i8** %1, null
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @utf8_normalize(i8* %8, i8 signext 63)
br label %12
12: ; preds = %5, %7, %10, %2
%13 = phi i32 [ 0, %2 ], [ 1, %10 ], [ 1, %7 ], [ 1, %5 ]
ret i32 %13
}