#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 snprintf(char *, int, char *, double);
int sscanf(char *, char *, float *);
scalar_t__ strcmp(char *, char *);
int test_locale() {
  float d;
  char s[64];
  int n;
  n = sscanf("5.25", "%f", &d);
  if (n != 1)
    return 1;
  if (d != 5.25)
    return 2;
  n = snprintf(s, 64, "%.1f", 3.5);
  if (n != 3)
    return 3;
  if (strcmp(s, "3.5"))
    return 4;
  return 0;
}


x86 assembly (clang, -O0):
<test_locale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xed1(%rip),%rdi
lea    0xecf(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x1,-0x54(%rbp)
je     1168 <test_locale+0x38>
movl   $0x1,-0x4(%rbp)
jmp    11fd <test_locale+0xcd>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe87(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    118e <test_locale+0x5e>
jp     118e <test_locale+0x5e>
jmp    119a <test_locale+0x6a>
movl   $0x2,-0x4(%rbp)
jmp    11fd <test_locale+0xcd>
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
lea    0xe6e(%rip),%rdx
movsd  0xe56(%rip),%xmm0
call   1030 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
je     11d0 <test_locale+0xa0>
movl   $0x3,-0x4(%rbp)
jmp    11fd <test_locale+0xcd>
lea    -0x50(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11f6 <test_locale+0xc6>
movl   $0x4,-0x4(%rbp)
jmp    11fd <test_locale+0xcd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_locale>:
sub    $0x58,%rsp
lea    0xed5(%rip),%rdi
lea    0xed3(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    116e <test_locale+0x3e>
movss  0xc(%rsp),%xmm0
mov    $0x2,%eax
ucomiss 0xe96(%rip),%xmm0
jne    116e <test_locale+0x3e>
jnp    1173 <test_locale+0x43>
add    $0x58,%rsp
ret
lea    0xe9e(%rip),%rdx
lea    0x10(%rsp),%rdi
movsd  0xe81(%rip),%xmm0
mov    $0x40,%esi
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    $0x3,%ecx
jne    116e <test_locale+0x3e>
lea    0xe79(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
shl    $0x2,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"5.25\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [5 x i8] c"%.1f\00"
@.str.3 = [4 x i8] c"3.5\00"
define i32 @test_locale() {
%1 = alloca i32
%2 = alloca float
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %26
9: ; preds = %0
%10 = load float, float* %2
%11 = fpext float %10 to double
%12 = fcmp une double %11, 5.250000e+00
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 2, i32* %1
br label %26
14: ; preds = %9
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%16 = call i32 @snprintf(i8* %15, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double 3.500000e+00)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 3, i32* %1
br label %26
20: ; preds = %14
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 4, i32* %1
br label %26
25: ; preds = %20
store i32 0, i32* %1
br label %26
26: ; preds = %25, %24, %19, %13, %8
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [5 x i8] c"5.25\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [5 x i8] c"%.1f\00"
@.str.3 = [4 x i8] c"3.5\00"
define i32 @test_locale() {
%1 = alloca float
%2 = alloca [64 x i8]
%3 = bitcast float* %1 to i8*
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %17
7: ; preds = %0
%8 = load float, float* %1
%9 = fcmp une float %8, 5.250000e+00
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = call i32 @snprintf(i8* %4, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double 3.500000e+00)
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i32 0, i32 4
br label %17
17: ; preds = %13, %10, %7, %0
%18 = phi i32 [ 1, %0 ], [ 2, %7 ], [ 3, %10 ], [ %16, %13 ]
ret i32 %18
}