#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_MONETARY;
scalar_t__ atof(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *malloc(int);
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 = malloc(201);
  if (setlocale(LC_MONETARY, argv[1]) == NULL) {
    fprintf(stderr, "setlocale(LC_MONETARY, \"%s\"): %m\n", argv[1]);
    exit(2);
  }
  if (strfmon(s, 200, 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    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc9,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1080 <setlocale@plt>
cmp    $0x0,%rax
jne    11fb <main+0x6b>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe14(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
cvtsi2sd %rax,%xmm0
mov    $0xc8,%esi
call   10a0 <strfmon@plt>
cmp    $0xffffffff,%eax
jne    1252 <main+0xc2>
lea    0xddf(%rip),%rdi
call   1090 <perror@plt>
mov    $0x3,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12fd <main+0x16d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1050 <strcmp@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    %rax,%r10
lea    0xda7(%rip),%rax
lea    0xd9a(%rip),%rdi
cmp    $0x0,%r10
cmovne %rdi,%rax
lea    0xd40(%rip),%rdi
mov    %rax,(%rsp)
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    $0xc9,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rsi
call   1080 <setlocale@plt>
test   %rax,%rax
je     120c <main+0x7c>
mov    0x10(%rbx),%r15
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
cvtsi2sd %rax,%xmm0
mov    %r14,%rdi
mov    $0xc8,%esi
mov    %r15,%rdx
call   10a0 <strfmon@plt>
cmp    $0xffffffff,%eax
je     122f <main+0x9f>
mov    0x20(%rbx),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1245 <main+0xb5>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xde0(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
lea    0xdec(%rip),%rdi
call   1090 <perror@plt>
mov    $0x3,%edi
call   10b0 <exit@plt>
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%r12
mov    0x18(%rbx),%r13
mov    0x20(%rbx),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe11(%rip),%rax
lea    0xe04(%rip),%rcx
cmove  %rax,%rcx
mov    %rcx,(%rsp)
lea    0xdaa(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %r14,%r8
mov    %rbx,%r9
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i8* @malloc(i32 201)
store i8* %7, i8** %6
%8 = load i32, i32* @LC_MONETARY
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @setlocale(i32 %8, i8* %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 2)
unreachable
21: ; preds = %2
%22 = load i8*, i8** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i64 @atof(i8* %28)
%30 = sitofp i64 %29 to double
%31 = call i32 @strfmon(i8* %22, i32 200, i8* %25, double %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %21
%34 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 3)
unreachable
36: ; preds = %21
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 4
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %37, i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %67
43: ; preds = %36
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = load i8*, i8** %6
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 4
%56 = load i8*, i8** %55
%57 = load i8*, i8** %6
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 4
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %57, i8* %60)
%62 = icmp ne i64 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, 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)
%65 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %49, i8* %52, i8* %53, i8* %56, i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %36
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 = tail call dereferenceable_or_null(201) i8* @malloc(i32 201)
%4 = load i32, i32* @LC_MONETARY
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @setlocale(i32 %4, i8* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %5
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 2)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i64 @atof(i8* %18)
%20 = sitofp i64 %19 to double
%21 = tail call i32 @strfmon(i8* %3, i32 200, i8* %16, double %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %14
%24 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = tail call i32 @exit(i32 3)
unreachable
26: ; preds = %14
%27 = getelementptr inbounds i8*, i8** %1, i64 4
%28 = load i8*, i8** %27
%29 = tail call i64 @strcmp(i8* %3, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %41, label %31
31: ; preds = %26
%32 = load i8*, i8** %5
%33 = load i8*, i8** %15
%34 = load i8*, i8** %17
%35 = load i8*, i8** %27
%36 = tail call i64 @strcmp(i8* %3, i8* %35)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, 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)
%39 = tail call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %33, i8* %34, i8* %3, i8* %35, i8* %38)
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %26
ret i32 0
}