#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 /*<<< orphan*/ LC_ALL;
int check_sscanf(char *, char *, double);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int do_test(void) {
  if (setlocale(LC_ALL, "fa_IR.UTF-8") == NULL) {
    puts("cannot set fa_IR locale");
    return 1;
  }
  int r = check_sscanf("\xDB\xB3"
                       "\xd9\xab"
                       "\xDB\xB1"
                       "\xDB\xB4",
                       "%I8f", 3.14);
  r |= check_sscanf("\xDB\xB3"
                    "\xd9\xac"
                    "\xDB\xB1"
                    "\xDB\xB4"
                    "\xDB\xB5",
                    "%I'f", 3145);
  r |= check_sscanf("\xDB\xB3"
                    "\xd9\xab"
                    "\xDB\xB1"
                    "\xDB\xB4"
                    "\xDB\xB1"
                    "\xDB\xB5"
                    "\xDB\xB9",
                    "%If", 3.14159);
  r |= check_sscanf("-"
                    "\xDB\xB3"
                    "\xd9\xab"
                    "\xDB\xB1"
                    "\xDB\xB4"
                    "\xDB\xB1"
                    "\xDB\xB5",
                    "%If", -3.1415);
  r |= check_sscanf("+"
                    "\xd9\xab"
                    "\xDB\xB1"
                    "\xDB\xB4"
                    "\xDB\xB1"
                    "\xDB\xB5",
                    "%If", +.1415);
  r |= check_sscanf("\xDB\xB3"
                    "\xd9\xab"
                    "\xDB\xB1"
                    "\xDB\xB4"
                    "\xDB\xB1"
                    "\xDB\xB5"
                    "e+"
                    "\xDB\xB2",
                    "%Ie", 3.1415e+2);
  return r;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xee8(%rip),%rsi
call   1050 <setlocale@plt>
cmp    $0x0,%rax
jne    116f <do_test+0x3f>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1238 <do_test+0x108>
lea    0xede(%rip),%rdi
lea    0xee0(%rip),%rsi
movsd  0xea3(%rip),%xmm0
call   1040 <check_sscanf@plt>
mov    %eax,-0x8(%rbp)
lea    0xece(%rip),%rdi
lea    0xed2(%rip),%rsi
movsd  0xe7d(%rip),%xmm0
call   1040 <check_sscanf@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xebd(%rip),%rdi
lea    0xec5(%rip),%rsi
movsd  0xe54(%rip),%xmm0
call   1040 <check_sscanf@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xeaf(%rip),%rdi
lea    0xea4(%rip),%rsi
movsd  0xe2b(%rip),%xmm0
call   1040 <check_sscanf@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xe9c(%rip),%rdi
lea    0xe83(%rip),%rsi
movsd  0xe02(%rip),%xmm0
call   1040 <check_sscanf@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe91(%rip),%rsi
movsd  0xdd9(%rip),%xmm0
call   1040 <check_sscanf@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xee9(%rip),%rsi
call   1050 <setlocale@plt>
test   %rax,%rax
je     120a <do_test+0xda>
lea    0xef8(%rip),%rdi
lea    0xefa(%rip),%rsi
movsd  0xe95(%rip),%xmm0
call   1040 <check_sscanf@plt>
mov    %eax,%ebx
lea    0xee9(%rip),%rdi
lea    0xeed(%rip),%rsi
movsd  0xe80(%rip),%xmm0
call   1040 <check_sscanf@plt>
mov    %eax,%ebp
or     %ebx,%ebp
lea    0xeda(%rip),%rdi
lea    0xee2(%rip),%r14
movsd  0xe69(%rip),%xmm0
mov    %r14,%rsi
call   1040 <check_sscanf@plt>
mov    %eax,%r15d
lea    0xecc(%rip),%rdi
movsd  0xe57(%rip),%xmm0
mov    %r14,%rsi
call   1040 <check_sscanf@plt>
mov    %eax,%ebx
or     %r15d,%ebx
or     %ebp,%ebx
lea    0xebc(%rip),%rdi
movsd  0xe41(%rip),%xmm0
mov    %r14,%rsi
call   1040 <check_sscanf@plt>
mov    %eax,%ebp
lea    0xeaf(%rip),%rdi
lea    0xeb9(%rip),%rsi
movsd  0xe29(%rip),%xmm0
call   1040 <check_sscanf@plt>
or     %ebp,%eax
or     %ebx,%eax
jmp    121b <do_test+0xeb>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [12 x i8] c"fa_IR.UTF-8\00"
@.str.1 = [24 x i8] c"cannot set fa_IR locale\00"
@.str.2 = [9 x i8] c"\DB\B3\D9\AB\DB\B1\DB\B4\00"
@.str.3 = [5 x i8] c"%I8f\00"
@.str.4 = [11 x i8] c"\DB\B3\D9\AC\DB\B1\DB\B4\DB\B5\00"
@.str.5 = [5 x i8] c"%I'f\00"
@.str.6 = [15 x i8] c"\DB\B3\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5\DB\B9\00"
@.str.7 = [4 x i8] c"%If\00"
@.str.8 = [14 x i8] c"-\DB\B3\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5\00"
@.str.9 = [12 x i8] c"+\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5\00"
@.str.10 = [17 x i8] c"\DB\B3\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5e+\DB\B2\00"
@.str.11 = [4 x i8] c"%Ie\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @LC_ALL
%4 = call i32* @setlocale(i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %26
8: ; preds = %0
%9 = call i32 @check_sscanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double 3.140000e+00)
store i32 %9, i32* %2
%10 = call i32 @check_sscanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double 3.145000e+03)
%11 = load i32, i32* %2
%12 = or i32 %11, %10
store i32 %12, i32* %2
%13 = call i32 @check_sscanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double 3.141590e+00)
%14 = load i32, i32* %2
%15 = or i32 %14, %13
store i32 %15, i32* %2
%16 = call i32 @check_sscanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double -3.141500e+00)
%17 = load i32, i32* %2
%18 = or i32 %17, %16
store i32 %18, i32* %2
%19 = call i32 @check_sscanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double 1.415000e-01)
%20 = load i32, i32* %2
%21 = or i32 %20, %19
store i32 %21, i32* %2
%22 = call i32 @check_sscanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double 3.141500e+02)
%23 = load i32, i32* %2
%24 = or i32 %23, %22
store i32 %24, i32* %2
%25 = load i32, i32* %2
store i32 %25, i32* %1
br label %26
26: ; preds = %8, %6
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [12 x i8] c"fa_IR.UTF-8\00"
@.str.1 = [24 x i8] c"cannot set fa_IR locale\00"
@.str.2 = [9 x i8] c"\DB\B3\D9\AB\DB\B1\DB\B4\00"
@.str.3 = [5 x i8] c"%I8f\00"
@.str.4 = [11 x i8] c"\DB\B3\D9\AC\DB\B1\DB\B4\DB\B5\00"
@.str.5 = [5 x i8] c"%I'f\00"
@.str.6 = [15 x i8] c"\DB\B3\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5\DB\B9\00"
@.str.7 = [4 x i8] c"%If\00"
@.str.8 = [14 x i8] c"-\DB\B3\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5\00"
@.str.9 = [12 x i8] c"+\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5\00"
@.str.10 = [17 x i8] c"\DB\B3\D9\AB\DB\B1\DB\B4\DB\B1\DB\B5e+\DB\B2\00"
@.str.11 = [4 x i8] c"%Ie\00"
define i32 @do_test() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i32* @setlocale(i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %18
6: ; preds = %0
%7 = tail call i32 @check_sscanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double 3.140000e+00)
%8 = tail call i32 @check_sscanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double 3.145000e+03)
%9 = or i32 %8, %7
%10 = tail call i32 @check_sscanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double 3.141590e+00)
%11 = or i32 %9, %10
%12 = tail call i32 @check_sscanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double -3.141500e+00)
%13 = or i32 %11, %12
%14 = tail call i32 @check_sscanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double 1.415000e-01)
%15 = or i32 %13, %14
%16 = tail call i32 @check_sscanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double 3.141500e+02)
%17 = or i32 %15, %16
br label %18
18: ; preds = %6, %4
%19 = phi i32 [ 1, %4 ], [ %17, %6 ]
ret i32 %19
}