#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 */
scalar_t__ strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strstr(char const *, char *);
int /*<<< orphan*/ substitute(char const *, char *, char *, char *, int);
void make_latin1_forms(const char *latin1, char *nonNbsp, char *nbsp) {
  if (strchr(latin1, '_')) {
    substitute(latin1, "_", nbsp, "\xA0", 128);
    substitute(nbsp, "\xA0", nonNbsp, "_", 128);
  } else if (strstr(latin1, "\xA0")) {
    substitute(latin1, "\xA0", nonNbsp, "_", 128);
    substitute(nonNbsp, "_", nbsp, "\xA0", 128);
  } else {
    (void)strcpy(nonNbsp, latin1);
    *nbsp = 0;
  }
}


x86 assembly (clang, -O0):
<make_latin1_forms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5f,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11b3 <make_latin1_forms+0x73>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe85(%rip),%rsi
lea    0xe80(%rip),%rcx
mov    $0x80,%r8d
call   1050 <substitute@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe66(%rip),%rsi
lea    0xe5d(%rip),%rcx
mov    $0x80,%r8d
call   1050 <substitute@plt>
jmp    122d <make_latin1_forms+0xed>
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1214 <make_latin1_forms+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe26(%rip),%rsi
lea    0xe1d(%rip),%rcx
mov    $0x80,%r8d
call   1050 <substitute@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe03(%rip),%rsi
lea    0xdfe(%rip),%rcx
mov    $0x80,%r8d
call   1050 <substitute@plt>
jmp    1228 <make_latin1_forms+0xe8>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    122d <make_latin1_forms+0xed>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_latin1_forms>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x5f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1191 <make_latin1_forms+0x51>
lea    0xe98(%rip),%r12
lea    0xe93(%rip),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
mov    $0x80,%r8d
call   1050 <substitute@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
jmp    11d3 <make_latin1_forms+0x93>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11ea <make_latin1_forms+0xaa>
lea    0xe56(%rip),%r12
lea    0xe4d(%rip),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    $0x80,%r8d
call   1050 <substitute@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0x80,%r8d
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <substitute@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,(%r15)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"_\00"
@.str.1 = [2 x i8] c"\A0\00"
define void @make_latin1_forms(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = call i64 @strchr(i8* %7, i8 signext 95)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = load i8*, i8** %6
%13 = call i32 @substitute(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 128)
%14 = load i8*, i8** %6
%15 = load i8*, i8** %5
%16 = call i32 @substitute(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 128)
br label %34
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = call i32 @substitute(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 128)
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = call i32 @substitute(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 128)
br label %33
28: ; preds = %17
%29 = load i8*, i8** %5
%30 = load i8*, i8** %4
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %6
store i8 0, i8* %32
br label %33
33: ; preds = %28, %21
br label %34
34: ; preds = %33, %10
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
@.str.1 = [2 x i8] c"\A0\00"
define void @make_latin1_forms(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @strchr(i8* %0, i8 signext 95)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @substitute(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 128)
%8 = tail call i32 @substitute(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 128)
br label %17
9: ; preds = %3
%10 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @substitute(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 128)
%14 = tail call i32 @substitute(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 128)
br label %17
15: ; preds = %9
%16 = tail call i32 @strcpy(i8* %1, i8* %0)
store i8 0, i8* %2
br label %17
17: ; preds = %12, %15, %6
ret void
}