#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 lconv {
  char *decimal_point;
};

/* Variables and functions */
struct lconv *localeconv();
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
size_t strlen(char const *);
const char *wcsutil_dot_to_locale(const char *inbuf, char *outbuf) {
  struct lconv *locale_data = localeconv();
  const char *decimal_point = locale_data->decimal_point;
  if (decimal_point[0] != '.' || decimal_point[1] != 0) {
    char *out = outbuf;
    size_t decimal_point_len = strlen(decimal_point);
    for (; *inbuf; inbuf++) {
      if (*inbuf == '.') {
        memcpy(out, decimal_point, decimal_point_len);
        out += decimal_point_len;
      } else {
        *out++ = *inbuf;
      }
    }
    *out = '\0';
    return outbuf;
  } else {
    return inbuf;
  }
}


x86 assembly (clang, -O0):
<wcsutil_dot_to_locale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <localeconv@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1177 <wcsutil_dot_to_locale+0x47>
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     120c <wcsutil_dot_to_locale+0xdc>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11f8 <wcsutil_dot_to_locale+0xc8>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11cb <wcsutil_dot_to_locale+0x9b>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x38(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11e2 <wcsutil_dot_to_locale+0xb2>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    11e7 <wcsutil_dot_to_locale+0xb7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118c <wcsutil_dot_to_locale+0x5c>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1214 <wcsutil_dot_to_locale+0xe4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsutil_dot_to_locale>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r13
xor    %eax,%eax
call   1030 <localeconv@plt>
mov    (%rax),%r15
cmpb   $0x2e,(%r15)
jne    1156 <wcsutil_dot_to_locale+0x26>
cmpb   $0x0,0x1(%r15)
je     11a3 <wcsutil_dot_to_locale+0x73>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rbx
jmp    1185 <wcsutil_dot_to_locale+0x55>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
add    %r12,%rbx
add    $0x1,%r13
movzbl 0x0(%r13),%eax
cmp    $0x2e,%al
je     1170 <wcsutil_dot_to_locale+0x40>
test   %al,%al
je     119e <wcsutil_dot_to_locale+0x6e>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0x1,%r13
jmp    1185 <wcsutil_dot_to_locale+0x55>
movb   $0x0,(%rbx)
jmp    11a6 <wcsutil_dot_to_locale+0x76>
mov    %r13,%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.lconv = type { i8* }
define i8* @wcsutil_dot_to_locale(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.lconv*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = call %struct.lconv* (...) @localeconv()
store %struct.lconv* %10, %struct.lconv** %6
%11 = load %struct.lconv*, %struct.lconv** %6
%12 = getelementptr inbounds %struct.lconv, %struct.lconv* %11, i32 0, i32 0
%13 = load i8*, i8** %12
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 46
br i1 %18, label %25, label %19
19: ; preds = %2
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %58
25: ; preds = %19, %2
%26 = load i8*, i8** %5
store i8* %26, i8** %8
%27 = load i8*, i8** %7
%28 = call i64 @strlen(i8* %27)
store i64 %28, i64* %9
br label %29
29: ; preds = %52, %25
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %55
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 46
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = load i8*, i8** %8
%40 = load i8*, i8** %7
%41 = load i64, i64* %9
%42 = call i32 @memcpy(i8* %39, i8* %40, i64 %41)
%43 = load i64, i64* %9
%44 = load i8*, i8** %8
%45 = getelementptr inbounds i8, i8* %44, i64 %43
store i8* %45, i8** %8
br label %51
46: ; preds = %33
%47 = load i8*, i8** %4
%48 = load i8, i8* %47
%49 = load i8*, i8** %8
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %8
store i8 %48, i8* %49
br label %51
51: ; preds = %46, %38
br label %52
52: ; preds = %51
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %4
br label %29
55: ; preds = %29
%56 = load i8*, i8** %8
store i8 0, i8* %56
%57 = load i8*, i8** %5
store i8* %57, i8** %3
br label %60
58: ; preds = %19
%59 = load i8*, i8** %4
store i8* %59, i8** %3
br label %60
60: ; preds = %58, %55
%61 = load i8*, i8** %3
ret i8* %61
}

LLVM IR (-O2):
%struct.lconv = type { i8* }
define i8* @wcsutil_dot_to_locale(i8* %0, i8* %1) {
%3 = tail call %struct.lconv* (...) @localeconv()
%4 = getelementptr inbounds %struct.lconv, %struct.lconv* %3, i64 0, i32 0
%5 = load i8*, i8** %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 46
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %5, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %8, %2
%13 = tail call i64 @strlen(i8* %5)
br label %14
14: ; preds = %23, %12
%15 = phi i8* [ %0, %12 ], [ %25, %23 ]
%16 = phi i8* [ %1, %12 ], [ %24, %23 ]
%17 = load i8, i8* %15
switch i8 %17, label %21 [
i8 0, label %26
i8 46, label %18
]
18: ; preds = %14
%19 = tail call i32 @memcpy(i8* %16, i8* %5, i64 %13)
%20 = getelementptr inbounds i8, i8* %16, i64 %13
br label %23
21: ; preds = %14
%22 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %17, i8* %16
br label %23
23: ; preds = %18, %21
%24 = phi i8* [ %20, %18 ], [ %22, %21 ]
%25 = getelementptr inbounds i8, i8* %15, i64 1
br label %14
26: ; preds = %14
store i8 0, i8* %16
br label %27
27: ; preds = %8, %26
%28 = phi i8* [ %1, %26 ], [ %0, %8 ]
ret i8* %28
}