#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ LC_MONETARY;
scalar_t__ atof(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *, char *,
                          char *);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int strfmon(char *, int, char *, double);
int main(int argc, char *argv[]) {
  char s[200];
  if (setlocale(LC_MONETARY, argv[1]) == NULL) {
    fprintf(stderr, "setlocale(LC_MONETARY, \"%s\"): %m\n", argv[1]);
    exit(2);
  }
  if (strfmon(s, sizeof(s), argv[2], (double)atof(argv[3])) == -1) {
    perror("strfmon");
    exit(3);
  }
  if (strcmp(s, argv[4]) != 0) {
    printf("Locale: \"%s\" Format: \"%s\" Value: \"%s\" Received: \"%s\" "
           "Expected: \"%s\" => %s\n",
           argv[1], argv[2], argv[3], s, argv[4],
           strcmp(s, argv[4]) != 0 ? "false" : "correct");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1070 <setlocale@plt>
cmp    $0x0,%rax
jne    11e0 <main+0x60>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe2f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
mov    -0xf0(%rbp),%rdi
mov    -0xe8(%rbp),%rdx
cvtsi2sd %rax,%xmm0
mov    $0xc8,%esi
call   1090 <strfmon@plt>
cmp    $0xffffffff,%eax
jne    1246 <main+0xc6>
lea    0xdeb(%rip),%rdi
call   1080 <perror@plt>
mov    $0x3,%edi
call   10a0 <exit@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1318 <main+0x198>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x118(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x110(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x108(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0xf8(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1050 <strcmp@plt>
mov    -0x118(%rbp),%rsi
mov    -0x110(%rbp),%rdx
mov    -0x108(%rbp),%rcx
mov    -0x100(%rbp),%r8
mov    -0xf8(%rbp),%r9
mov    %rax,%r10
lea    0xd8c(%rip),%rax
lea    0xd7f(%rip),%rdi
cmp    $0x0,%r10
cmovne %rdi,%rax
lea    0xd25(%rip),%rdi
mov    %rax,(%rsp)
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe0,%rsp
mov    %rsi,%rbx
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsi),%rsi
call   1070 <setlocale@plt>
test   %rax,%rax
je     11f9 <main+0x79>
mov    0x10(%rbx),%r14
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
cvtsi2sd %rax,%xmm0
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1090 <strfmon@plt>
cmp    $0xffffffff,%eax
je     121c <main+0x9c>
mov    0x20(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1232 <main+0xb2>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdf3(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
lea    0xdff(%rip),%rdi
call   1080 <perror@plt>
mov    $0x3,%edi
call   10a0 <exit@plt>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%r15
mov    0x18(%rbx),%r12
mov    0x20(%rbx),%rbx
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe1f(%rip),%rax
lea    0xe12(%rip),%rcx
cmove  %rax,%rcx
mov    %rcx,(%rsp)
lea    0xdb8(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbx,%r9
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@LC_MONETARY = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"setlocale(LC_MONETARY, \22%s\22): %m\0A\00"
@.str.1 = [8 x i8] c"strfmon\00"
@.str.2 = [75 x i8] c"Locale: \22%s\22 Format: \22%s\22 Value: \22%s\22 Received: \22%s\22 Expected: \22%s\22 => %s\0A\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [8 x i8] c"correct\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @LC_MONETARY
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @setlocale(i32 %7, i8* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 2)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i64 @atof(i8* %27)
%29 = sitofp i64 %28 to double
%30 = call i32 @strfmon(i8* %21, i32 200, i8* %24, double %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @exit(i32 3)
unreachable
35: ; preds = %20
%36 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 4
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %36, i8* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %66
42: ; preds = %35
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 3
%51 = load i8*, i8** %50
%52 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 4
%55 = load i8*, i8** %54
%56 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 4
%59 = load i8*, i8** %58
%60 = call i64 @strcmp(i8* %56, i8* %59)
%61 = icmp ne i64 %60, 0
%62 = zext i1 %61 to i64
%63 = select i1 %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%64 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %48, i8* %51, i8* %52, i8* %55, i8* %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@LC_MONETARY = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"setlocale(LC_MONETARY, \22%s\22): %m\0A\00"
@.str.1 = [8 x i8] c"strfmon\00"
@.str.2 = [75 x i8] c"Locale: \22%s\22 Format: \22%s\22 Value: \22%s\22 Received: \22%s\22 Expected: \22%s\22 => %s\0A\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [8 x i8] c"correct\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @LC_MONETARY
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @setlocale(i32 %5, i8* %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %6
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = tail call i32 @exit(i32 2)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i64 @atof(i8* %19)
%21 = sitofp i64 %20 to double
%22 = call i32 @strfmon(i8* %4, i32 200, i8* %17, double %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 3)
unreachable
27: ; preds = %15
%28 = getelementptr inbounds i8*, i8** %1, i64 4
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %4, i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %42, label %32
32: ; preds = %27
%33 = load i8*, i8** %6
%34 = load i8*, i8** %16
%35 = load i8*, i8** %18
%36 = load i8*, i8** %28
%37 = call i64 @strcmp(i8* %4, i8* %36)
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%40 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i8* %33, i8* %34, i8* %35, i8* %4, i8* %36, i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %27
ret i32 0
}