#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_redraw();
int /*<<< orphan*/ stfl_reset();
int /*<<< orphan*/ *stfl_run(struct stfl_form *, int /*<<< orphan*/);
int /*<<< orphan*/ stfl_set(struct stfl_form *, char *, char *);
char *stfl_text(struct stfl_form *, char *);
int /*<<< orphan*/ 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 (1) {
    event = stfl_run(f, 0);
    if (event) {
      if (!wcscmp(event, L"ESC"))
        break;
      else if (!wcscmp(event, L"^L"))
        stfl_redraw();
    }
  }
  stfl_reset();
  printf("%ls", stfl_text(f, L"textedit"));
  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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
call   10f0 <setlocale@plt>
cmp    $0x0,%eax
jne    1262 <main+0x42>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   10c0 <nl_langinfo@plt>
mov    %eax,%edi
call   10b0 <stfl_ipool_create@plt>
mov    %rax,-0x10(%rbp)
lea    0xdc6(%rip),%rdi
call   1060 <stfl_create@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdee(%rip),%rsi
lea    0xe07(%rip),%rdx
call   1090 <stfl_set@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   1140 <stfl_ipool_towc@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
lea    0xe20(%rip),%rsi
call   1090 <stfl_set@plt>
mov    -0x10(%rbp),%rdi
call   1080 <stfl_ipool_flush@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1130 <stfl_run@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1340 <main+0x120>
mov    -0x20(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1040 <wcscmp@plt>
cmp    $0x0,%eax
jne    1316 <main+0xf6>
jmp    1345 <main+0x125>
mov    -0x20(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1040 <wcscmp@plt>
cmp    $0x0,%eax
jne    1336 <main+0x116>
mov    $0x0,%al
call   10e0 <stfl_redraw@plt>
jmp    133b <main+0x11b>
jmp    1340 <main+0x120>
jmp    12de <main+0xbe>
mov    $0x0,%al
call   1030 <stfl_reset@plt>
mov    -0x18(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1100 <stfl_text@plt>
mov    %rax,%rsi
lea    0xcc4(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd0e(%rip),%rsi
call   1050 <stfl_get@plt>
mov    %rax,%rsi
lea    0xca9(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd53(%rip),%rsi
call   1050 <stfl_get@plt>
mov    %rax,%rsi
lea    0xc92(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1050 <stfl_get@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
call   1120 <stfl_ipool_fromwc@plt>
mov    %rax,%rsi
lea    0xc67(%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   1110 <stfl_ipool_destroy@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
call   10f0 <setlocale@plt>
test   %eax,%eax
jne    1257 <main+0x37>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10c0 <nl_langinfo@plt>
mov    %eax,%edi
call   10b0 <stfl_ipool_create@plt>
mov    %rax,%r14
lea    0xdd2(%rip),%rdi
call   1060 <stfl_create@plt>
mov    %rax,%r13
lea    0xdff(%rip),%rsi
lea    0xe18(%rip),%rdx
mov    %rax,%rdi
call   1090 <stfl_set@plt>
lea    0xd80(%rip),%rsi
mov    %r14,%rdi
call   1140 <stfl_ipool_towc@plt>
lea    0xe3e(%rip),%rsi
mov    %r13,%rdi
mov    %rax,%rdx
call   1090 <stfl_set@plt>
mov    %r14,%rdi
call   1080 <stfl_ipool_flush@plt>
lea    0xe44(%rip),%r15
lea    0xe4d(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %esi,%esi
call   1130 <stfl_run@plt>
test   %rax,%rax
je     12d0 <main+0xb0>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <wcscmp@plt>
test   %eax,%eax
je     1309 <main+0xe9>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <wcscmp@plt>
test   %eax,%eax
jne    12d0 <main+0xb0>
xor    %eax,%eax
call   10e0 <stfl_redraw@plt>
jmp    12d0 <main+0xb0>
xor    %eax,%eax
call   1030 <stfl_reset@plt>
lea    0xe0d(%rip),%rsi
mov    %r13,%rdi
call   1100 <stfl_text@plt>
lea    0xd04(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xd4f(%rip),%rsi
mov    %r13,%rdi
call   1050 <stfl_get@plt>
lea    0xcea(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xd95(%rip),%rsi
mov    %r13,%rdi
call   1050 <stfl_get@plt>
lea    0xcd4(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0xdd7(%rip),%rsi
mov    %r13,%rdi
call   1050 <stfl_get@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1120 <stfl_ipool_fromwc@plt>
lea    0xcb3(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r14,%rdi
call   1080 <stfl_ipool_flush@plt>
mov    %r13,%rdi
call   10d0 <stfl_free@plt>
mov    %r14,%rdi
call   1110 <stfl_ipool_destroy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
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 = [3 x i32] [i32 94, i32 76, i32 0]
@.str.9 = [4 x i8] c"%ls\00"
@.str.10 = [9 x i32] [i32 116, i32 101, i32 120, i32 116, i32 101, i32 100, i32 105, i32 116, i32 0]
@.str.11 = [8 x i8] c"A: %ls\0A\00"
@.str.12 = [8 x i8] c"B: %ls\0A\00"
@.str.13 = [7 x i8] c"C: %s\0A\00"
@.str.14 = [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 = %11, %42
%25 = load %struct.stfl_form*, %struct.stfl_form** %3
%26 = call i32* @stfl_run(%struct.stfl_form* %25, i32 0)
store i32* %26, i32** %4
%27 = load i32*, i32** %4
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %42
29: ; preds = %24
%30 = load i32*, i32** %4
%31 = call i32 @wcscmp(i32* %30, i8* bitcast ([4 x i32]* @.str.7 to i8*))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29
br label %43
34: ; preds = %29
%35 = load i32*, i32** %4
%36 = call i32 @wcscmp(i32* %35, i8* bitcast ([3 x i32]* @.str.8 to i8*))
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 (...) @stfl_redraw()
br label %40
40: ; preds = %38, %34
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41, %24
br label %24
43: ; preds = %33
%44 = call i32 (...) @stfl_reset()
%45 = load %struct.stfl_form*, %struct.stfl_form** %3
%46 = call i8* @stfl_text(%struct.stfl_form* %45, i8* bitcast ([9 x i32]* @.str.10 to i8*))
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %46)
%48 = load %struct.stfl_form*, %struct.stfl_form** %3
%49 = call i8* @stfl_get(%struct.stfl_form* %48, i8* bitcast ([8 x i32]* @.str.3 to i8*))
%50 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* %49)
%51 = load %struct.stfl_form*, %struct.stfl_form** %3
%52 = call i8* @stfl_get(%struct.stfl_form* %51, i8* bitcast ([8 x i32]* @.str.5 to i8*))
%53 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i8* %52)
%54 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%55 = load %struct.stfl_form*, %struct.stfl_form** %3
%56 = call i8* @stfl_get(%struct.stfl_form* %55, i8* bitcast ([8 x i32]* @.str.14 to i8*))
%57 = call i8* @stfl_ipool_fromwc(%struct.stfl_ipool* %54, i8* %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* %57)
%59 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%60 = call i32 @stfl_ipool_flush(%struct.stfl_ipool* %59)
%61 = load %struct.stfl_form*, %struct.stfl_form** %3
%62 = call i32 @stfl_free(%struct.stfl_form* %61)
%63 = load %struct.stfl_ipool*, %struct.stfl_ipool** %2
%64 = call i32 @stfl_ipool_destroy(%struct.stfl_ipool* %63)
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 = [3 x i32] [i32 94, i32 76, i32 0]
@.str.9 = [4 x i8] c"%ls\00"
@.str.10 = [9 x i32] [i32 116, i32 101, i32 120, i32 116, i32 101, i32 100, i32 105, i32 116, i32 0]
@.str.11 = [8 x i8] c"A: %ls\0A\00"
@.str.12 = [8 x i8] c"B: %ls\0A\00"
@.str.13 = [7 x i8] c"C: %s\0A\00"
@.str.14 = [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 = %27, %7
%17 = tail call i32* @stfl_run(%struct.stfl_form* %11, i32 0)
%18 = icmp eq i32* %17, null
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = tail call i32 @wcscmp(i32* %17, i8* bitcast ([4 x i32]* @.str.7 to i8*))
%21 = icmp eq i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = tail call i32 @wcscmp(i32* %17, i8* bitcast ([3 x i32]* @.str.8 to i8*))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (...) @stfl_redraw()
br label %27
27: ; preds = %25, %22, %16
br label %16
28: ; preds = %19
%29 = tail call i32 (...) @stfl_reset()
%30 = tail call i8* @stfl_text(%struct.stfl_form* %11, i8* bitcast ([9 x i32]* @.str.10 to i8*))
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %30)
%32 = tail call i8* @stfl_get(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.3 to i8*))
%33 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* %32)
%34 = tail call i8* @stfl_get(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.5 to i8*))
%35 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i8* %34)
%36 = tail call i8* @stfl_get(%struct.stfl_form* %11, i8* bitcast ([8 x i32]* @.str.14 to i8*))
%37 = tail call i8* @stfl_ipool_fromwc(%struct.stfl_ipool* %10, i8* %36)
%38 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* %37)
%39 = tail call i32 @stfl_ipool_flush(%struct.stfl_ipool* %10)
%40 = tail call i32 @stfl_free(%struct.stfl_form* %11)
%41 = tail call i32 @stfl_ipool_destroy(%struct.stfl_ipool* %10)
ret i32 0
}