#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*/ wchar_t;
struct stfl_ipool {
  int dummy;
};
struct stfl_form {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ CODESET;
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ nl_langinfo(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
struct stfl_form *stfl_create(char *);
int /*<<< orphan*/ stfl_free(struct stfl_form *);
char *stfl_get(struct stfl_form *, char *);
struct stfl_ipool *stfl_ipool_create(int /*<<< orphan*/);
int /*<<< orphan*/ stfl_ipool_destroy(struct stfl_ipool *);
int /*<<< orphan*/ stfl_ipool_flush(struct stfl_ipool *);
char *stfl_ipool_fromwc(struct stfl_ipool *, char *);
char *stfl_ipool_towc(struct stfl_ipool *, char *);
int /*<<< orphan*/ stfl_reset();
int /*<<< orphan*/ *stfl_run(struct stfl_form *, int /*<<< orphan*/);
int /*<<< orphan*/ stfl_set(struct stfl_form *, char *, char *);
scalar_t__ wcscmp(int /*<<< orphan*/ const *, char *);
int main() {
  if (!setlocale(LC_ALL, ""))
    fprintf(stderr, "WARING: Can't set locale!\n");
  struct stfl_ipool *ipool = stfl_ipool_create(nl_langinfo(CODESET));
  struct stfl_form *f = stfl_create(L"<example.stfl>");
  stfl_set(f, L"value_a", L"This is a little");
  stfl_set(f, L"value_b", stfl_ipool_towc(ipool, "test for STFL!"));
  stfl_ipool_flush(ipool);
  const wchar_t *event = 0;
  while (!event || wcscmp(event, L"ESC"))
    event = stfl_run(f, 0);
  stfl_reset();
  printf("A: %ls\n", stfl_get(f, L"value_a"));
  printf("B: %ls\n", stfl_get(f, L"value_b"));
  printf("C: %s\n", stfl_ipool_fromwc(ipool, stfl_get(f, L"value_c")));
  stfl_ipool_flush(ipool);
  stfl_free(f);
  stfl_ipool_destroy(ipool);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
call   10e0 <setlocale@plt>
cmp    $0x0,%eax
jne    1242 <main+0x42>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
call   10c0 <nl_langinfo@plt>
mov    %eax,%edi
call   10b0 <stfl_ipool_create@plt>
mov    %rax,-0x10(%rbp)
lea    0xde2(%rip),%rdi
call   1060 <stfl_create@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe0a(%rip),%rsi
lea    0xe23(%rip),%rdx
call   1090 <stfl_set@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   1120 <stfl_ipool_towc@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
lea    0xe3c(%rip),%rsi
call   1090 <stfl_set@plt>
mov    -0x10(%rbp),%rdi
call   1080 <stfl_ipool_flush@plt>
movq   $0x0,-0x20(%rbp)
mov    $0x1,%al
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x29(%rbp)
je     12e8 <main+0xe8>
mov    -0x20(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <wcscmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    12f8 <main+0xf8>
jmp    130c <main+0x10c>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1110 <stfl_run@plt>
mov    %rax,-0x20(%rbp)
jmp    12be <main+0xbe>
mov    $0x0,%al
call   1030 <stfl_reset@plt>
mov    -0x18(%rbp),%rdi
lea    0xd62(%rip),%rsi
call   1050 <stfl_get@plt>
mov    %rax,%rsi
lea    0xcfd(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xda7(%rip),%rsi
call   1050 <stfl_get@plt>
mov    %rax,%rsi
lea    0xce6(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1050 <stfl_get@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1100 <stfl_ipool_fromwc@plt>
mov    %rax,%rsi
lea    0xcbb(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <stfl_ipool_flush@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <stfl_free@plt>
mov    -0x10(%rbp),%rdi
call   10f0 <stfl_ipool_destroy@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
call   10e0 <setlocale@plt>
test   %eax,%eax
jne    1233 <main+0x33>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   10c0 <nl_langinfo@plt>
mov    %eax,%edi
call   10b0 <stfl_ipool_create@plt>
mov    %rax,%r14
lea    0xdf2(%rip),%rdi
call   1060 <stfl_create@plt>
mov    %rax,%rbx
lea    0xe1f(%rip),%rsi
lea    0xe38(%rip),%rdx
mov    %rax,%rdi
call   1090 <stfl_set@plt>
lea    0xda4(%rip),%rsi
mov    %r14,%rdi
call   1120 <stfl_ipool_towc@plt>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1090 <stfl_set@plt>
mov    %r14,%rdi
call   1080 <stfl_ipool_flush@plt>
xor    %eax,%eax
lea    0xe62(%rip),%r15
jmp    12ba <main+0xba>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %esi,%esi
call   1110 <stfl_run@plt>
test   %rax,%rax
je     12b0 <main+0xb0>
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <wcscmp@plt>
test   %rax,%rax
jne    12b0 <main+0xb0>
xor    %eax,%eax
call   1030 <stfl_reset@plt>
lea    0xda3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <stfl_get@plt>
lea    0xd3e(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xde9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <stfl_get@plt>
lea    0xd28(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xdfb(%rip),%rsi
mov    %rbx,%rdi
call   1050 <stfl_get@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1100 <stfl_ipool_fromwc@plt>
lea    0xd07(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r14,%rdi
call   1080 <stfl_ipool_flush@plt>
mov    %rbx,%rdi
call   10d0 <stfl_free@plt>
mov    %r14,%rdi
call   10f0 <stfl_ipool_destroy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stfl_ipool = type { i32 }
%struct.stfl_form = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [27 x i8] c"WARING: Can't set locale!\0A\00"
@CODESET = global i32 0
@.str.2 = [15 x i32] [i32 60, i32 101, i32 120, i32 97, i32 109, i32 112, i32 108, i32 101, i32 46, i32 115, i32 116, i32 102, i32 108, i32 62, i32 0]
@.str.3 = [8 x i32] [i32 118, i32 97, i32 108, i32 117, i32 101, i32 95, i32 97, i32 0]
@.str.4 = [17 x i32] [i32 84, i32 104, i32 105, i32 115, i32 32, i32 105, i32 115, i32 32, i32 97, i32 32, i32 108, i32 105, i32 116, i32 116, i32 108, i32 101, i32 0]
@.str.5 = [8 x i32] [i32 118, i32 97, i32 108, i32 117, i32 101, i32 95, i32 98, i32 0]
@.str.6 = [15 x i8] c"test for STFL!\00"
@.str.7 = [4 x i32] [i32 69, i32 83, i32 67, i32 0]
@.str.8 = [8 x i8] c"A: %ls\0A\00"
@.str.9 = [8 x i8] c"B: %ls\0A\00"
@.str.10 = [7 x i8] c"C: %s\0A\00"
@.str.11 = [8 x i32] [i32 118, i32 97, i32 108, i32 117, i32 101, i32 95, i32 99, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stfl_ipool*
%3 = alloca %struct.stfl_form*
%4 = alloca i32*
store i32 0, i32* %1
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* @CODESET
%13 = call i32 @nl_langinfo(i32 %12)
%14 = call %struct.stfl_ipool* @stfl_ipool_create(i32 %13)
store %struct.stfl_ipool* %14, %struct.stfl_ipool** %2
%15 = call %struct.stfl_form* @stfl_create(i8* bitcast ([15 x i32]* @.str.2 to i8*))
store %struct.stfl_form* %15, %struct.stfl_form** %3
%16 = load %struct.stfl_form*, %struct.stfl_form** %3
%17 = call i32 @stfl_set(%struct.stfl_form* %16, i8* bitcast ([8 x i32]* @.str.3 to i8*), i8* bitcast ([17 x i32]* @.str.4 to i8*))
%18 = load %struct.stfl_form*, %struct.stfl_form** %3
%19 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%20 = call i8* @stfl_ipool_towc(%struct.stfl_ipool* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @stfl_set(%struct.stfl_form* %18, i8* bitcast ([8 x i32]* @.str.5 to i8*), i8* %20)
%22 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%23 = call i32 @stfl_ipool_flush(%struct.stfl_ipool* %22)
store i32* null, i32** %4
br label %24
24: ; preds = %33, %11
%25 = load i32*, i32** %4
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32*, i32** %4
%29 = call i64 @wcscmp(i32* %28, i8* bitcast ([4 x i32]* @.str.7 to i8*))
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %27, %24
%32 = phi i1 [ true, %24 ], [ %30, %27 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load %struct.stfl_form*, %struct.stfl_form** %3
%35 = call i32* @stfl_run(%struct.stfl_form* %34, i32 0)
store i32* %35, i32** %4
br label %24
36: ; preds = %31
%37 = call i32 (...) @stfl_reset()
%38 = load %struct.stfl_form*, %struct.stfl_form** %3
%39 = call i8* @stfl_get(%struct.stfl_form* %38, i8* bitcast ([8 x i32]* @.str.3 to i8*))
%40 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %39)
%41 = load %struct.stfl_form*, %struct.stfl_form** %3
%42 = call i8* @stfl_get(%struct.stfl_form* %41, i8* bitcast ([8 x i32]* @.str.5 to i8*))
%43 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %42)
%44 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%45 = load %struct.stfl_form*, %struct.stfl_form** %3
%46 = call i8* @stfl_get(%struct.stfl_form* %45, i8* bitcast ([8 x i32]* @.str.11 to i8*))
%47 = call i8* @stfl_ipool_fromwc(%struct.stfl_ipool* %44, i8* %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %47)
%49 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%50 = call i32 @stfl_ipool_flush(%struct.stfl_ipool* %49)
%51 = load %struct.stfl_form*, %struct.stfl_form** %3
%52 = call i32 @stfl_free(%struct.stfl_form* %51)
%53 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%54 = call i32 @stfl_ipool_destroy(%struct.stfl_ipool* %53)
ret i32 0
}

LLVM IR (-O2):
%struct.stfl_ipool = type { i32 }
%struct.stfl_form = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [27 x i8] c"WARING: Can't set locale!\0A\00"
@CODESET = global i32 0
@.str.2 = [15 x i32] [i32 60, i32 101, i32 120, i32 97, i32 109, i32 112, i32 108, i32 101, i32 46, i32 115, i32 116, i32 102, i32 108, i32 62, i32 0]
@.str.3 = [8 x i32] [i32 118, i32 97, i32 108, i32 117, i32 101, i32 95, i32 97, i32 0]
@.str.4 = [17 x i32] [i32 84, i32 104, i32 105, i32 115, i32 32, i32 105, i32 115, i32 32, i32 97, i32 32, i32 108, i32 105, i32 116, i32 116, i32 108, i32 101, i32 0]
@.str.5 = [8 x i32] [i32 118, i32 97, i32 108, i32 117, i32 101, i32 95, i32 98, i32 0]
@.str.6 = [15 x i8] c"test for STFL!\00"
@.str.7 = [4 x i32] [i32 69, i32 83, i32 67, i32 0]
@.str.8 = [8 x i8] c"A: %ls\0A\00"
@.str.9 = [8 x i8] c"B: %ls\0A\00"
@.str.10 = [7 x i8] c"C: %s\0A\00"
@.str.11 = [8 x i32] [i32 118, i32 97, i32 108, i32 117, i32 101, i32 95, i32 99, i32 0]
define i32 @main() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i32 @setlocale(i32 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %4, %0
%8 = load i32, i32* @CODESET
%9 = tail call i32 @nl_langinfo(i32 %8)
%10 = tail call %struct.stfl_ipool* @stfl_ipool_create(i32 %9)
%11 = tail call %struct.stfl_form* @stfl_create(i8* bitcast ([15 x i32]* @.str.2 to i8*))
%12 = tail call i32 @stfl_set(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.3 to i8*), i8* bitcast ([17 x i32]* @.str.4 to i8*))
%13 = tail call i8* @stfl_ipool_towc(%struct.stfl_ipool* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%14 = tail call i32 @stfl_set(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.5 to i8*), i8* %13)
%15 = tail call i32 @stfl_ipool_flush(%struct.stfl_ipool* %10)
br label %16
16: ; preds = %22, %7
%17 = phi i32* [ null, %7 ], [ %23, %22 ]
%18 = icmp eq i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i64 @wcscmp(i32* %17, i8* bitcast ([4 x i32]* @.str.7 to i8*))
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %16, %19
%23 = tail call i32* @stfl_run(%struct.stfl_form* %11, i32 0)
br label %16
24: ; preds = %19
%25 = tail call i32 (...) @stfl_reset()
%26 = tail call i8* @stfl_get(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.3 to i8*))
%27 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %26)
%28 = tail call i8* @stfl_get(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.5 to i8*))
%29 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %28)
%30 = tail call i8* @stfl_get(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.11 to i8*))
%31 = tail call i8* @stfl_ipool_fromwc(%struct.stfl_ipool* %10, i8* %30)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %31)
%33 = tail call i32 @stfl_ipool_flush(%struct.stfl_ipool* %10)
%34 = tail call i32 @stfl_free(%struct.stfl_form* %11)
%35 = tail call i32 @stfl_ipool_destroy(%struct.stfl_ipool* %10)
ret i32 0
}