#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 */
scalar_t__ isdigit(char);
struct lconv *localeconv();
int /*<<< orphan*/ memmove(char *, char *, size_t);
size_t strlen(char const *);
scalar_t__ strncmp(char *, char const *, size_t);
void _change_decimal_from_locale_to_dot(char *buffer) {
  struct lconv *locale_data = localeconv();
  const char *decimal_point = locale_data->decimal_point;
  if (decimal_point[0] != '.' || decimal_point[1] != 0) {
    size_t decimal_point_len = strlen(decimal_point);
    if (*buffer == '+' || *buffer == '-') {
      buffer++;
    }
    while (isdigit(((*buffer) & 0xff))) {
      buffer++;
    }
    if (strncmp(buffer, decimal_point, decimal_point_len) == 0) {
      *buffer = '.';
      buffer++;
      if (decimal_point_len > 1) {
        size_t rest_len = strlen(buffer + (decimal_point_len - 1));
        memmove(buffer, buffer + (decimal_point_len - 1), rest_len);
        buffer[rest_len] = 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<_change_decimal_from_locale_to_dot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <localeconv@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1193 <_change_decimal_from_locale_to_dot+0x43>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1283 <_change_decimal_from_locale_to_dot+0x133>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     11c0 <_change_decimal_from_locale_to_dot+0x70>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11cc <_change_decimal_from_locale_to_dot+0x7c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <_change_decimal_from_locale_to_dot+0x81>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
movsbl %al,%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1200 <_change_decimal_from_locale_to_dot+0xb0>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <_change_decimal_from_locale_to_dot+0x81>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    127e <_change_decimal_from_locale_to_dot+0x12e>
mov    -0x8(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x1,-0x20(%rbp)
jbe    1279 <_change_decimal_from_locale_to_dot+0x129>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
add    %rax,%rsi
mov    -0x28(%rbp),%rdx
call   1070 <memmove@plt>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    127e <_change_decimal_from_locale_to_dot+0x12e>
jmp    1283 <_change_decimal_from_locale_to_dot+0x133>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_change_decimal_from_locale_to_dot>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <localeconv@plt>
mov    (%rax),%r15
cmpb   $0x2e,(%r15)
jne    1172 <_change_decimal_from_locale_to_dot+0x22>
cmpb   $0x0,0x1(%r15)
je     11e4 <_change_decimal_from_locale_to_dot+0x94>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rax,%r14
mov    (%rbx),%al
cmp    $0x2d,%al
je     1187 <_change_decimal_from_locale_to_dot+0x37>
cmp    $0x2b,%al
jne    118b <_change_decimal_from_locale_to_dot+0x3b>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbx
nop
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isdigit@plt>
test   %rax,%rax
jne    1190 <_change_decimal_from_locale_to_dot+0x40>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11e4 <_change_decimal_from_locale_to_dot+0x94>
movb   $0x2e,(%rbx)
cmp    $0x2,%r14
jb     11e4 <_change_decimal_from_locale_to_dot+0x94>
lea    0x1(%rbx),%r15
add    %rbx,%r14
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1070 <memmove@plt>
movb   $0x0,0x1(%rbx,%r12,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.lconv = type { i8* }
define void @_change_decimal_from_locale_to_dot(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.lconv*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
%7 = call %struct.lconv* (...) @localeconv()
store %struct.lconv* %7, %struct.lconv** %3
%8 = load %struct.lconv*, %struct.lconv** %3
%9 = getelementptr inbounds %struct.lconv, %struct.lconv* %8, i32 0, i32 0
%10 = load i8*, i8** %9
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 46
br i1 %15, label %22, label %16
16: ; preds = %1
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %79
22: ; preds = %16, %1
%23 = load i8*, i8** %4
%24 = call i64 @strlen(i8* %23)
store i64 %24, i64* %5
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 43
br i1 %28, label %34, label %29
29: ; preds = %22
%30 = load i8*, i8** %2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 45
br i1 %33, label %34, label %37
34: ; preds = %29, %22
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
br label %37
37: ; preds = %34, %29
br label %38
38: ; preds = %46, %37
%39 = load i8*, i8** %2
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = and i32 %41, 255
%43 = trunc i32 %42 to i8
%44 = call i64 @isdigit(i8 signext %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %38
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %2
br label %38
49: ; preds = %38
%50 = load i8*, i8** %2
%51 = load i8*, i8** %4
%52 = load i64, i64* %5
%53 = call i64 @strncmp(i8* %50, i8* %51, i64 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %78
55: ; preds = %49
%56 = load i8*, i8** %2
store i8 46, i8* %56
%57 = load i8*, i8** %2
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %2
%59 = load i64, i64* %5
%60 = icmp ugt i64 %59, 1
br i1 %60, label %61, label %77
61: ; preds = %55
%62 = load i8*, i8** %2
%63 = load i64, i64* %5
%64 = sub i64 %63, 1
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = call i64 @strlen(i8* %65)
store i64 %66, i64* %6
%67 = load i8*, i8** %2
%68 = load i8*, i8** %2
%69 = load i64, i64* %5
%70 = sub i64 %69, 1
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i64, i64* %6
%73 = call i32 @memmove(i8* %67, i8* %71, i64 %72)
%74 = load i8*, i8** %2
%75 = load i64, i64* %6
%76 = getelementptr inbounds i8, i8* %74, i64 %75
store i8 0, i8* %76
br label %77
77: ; preds = %61, %55
br label %78
78: ; preds = %77, %49
br label %79
79: ; preds = %78, %16
ret void
}

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