#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 */
struct pbc_wmessage {
  int dummy;
};
struct pbc_env {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ pbc_wmessage_integer(struct pbc_wmessage *, char *, int,
                                        int /*<<< orphan*/);
struct pbc_wmessage *pbc_wmessage_message(struct pbc_wmessage *, char *);
struct pbc_wmessage *pbc_wmessage_new(struct pbc_env *, char *);
int /*<<< orphan*/ pbc_wmessage_string(struct pbc_wmessage *, char *, char *,
                                       int);
struct pbc_wmessage *test_wmessage(struct pbc_env *env) {
  struct pbc_wmessage *msg = pbc_wmessage_new(env, "tutorial.Person");
  pbc_wmessage_string(msg, "name", "Alice", -1);
  pbc_wmessage_integer(msg, "id", 12345, 0);
  pbc_wmessage_string(msg, "email", "alice@unkown", -1);
  struct pbc_wmessage *phone = pbc_wmessage_message(msg, "phone");
  pbc_wmessage_string(phone, "number", "87654321", -1);
  phone = pbc_wmessage_message(msg, "phone");
  pbc_wmessage_string(phone, "number", "13901234567", -1);
  pbc_wmessage_string(phone, "type", "MOBILE", -1);
  pbc_wmessage_integer(msg, "test", -123, 0);
  pbc_wmessage_integer(msg, "test", 12345, 0);
  pbc_wmessage_integer(msg, "test", 1234567, 0);
  pbc_wmessage_integer(msg, "tutorial.Ext.test", 54321, 0);
  return msg;
}


x86 assembly (clang, -O0):
<test_wmessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <pbc_wmessage_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
lea    0xea3(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
mov    $0x3039,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rdi
lea    0xe80(%rip),%rsi
lea    0xe7f(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1030 <pbc_wmessage_message@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe69(%rip),%rsi
lea    0xe69(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <pbc_wmessage_message@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe39(%rip),%rsi
lea    0xe42(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x18(%rbp),%rdi
lea    0xe39(%rip),%rsi
lea    0xe37(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
mov    $0xffffff85,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
mov    $0x3039,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rdi
lea    0xe08(%rip),%rsi
mov    $0x12d687,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rdi
lea    0xde4(%rip),%rsi
mov    $0xd431,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_wmessage>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rsi
call   1050 <pbc_wmessage_new@plt>
mov    %rax,%rbx
lea    0xeb5(%rip),%rsi
lea    0xeb3(%rip),%rdx
mov    %rax,%rdi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3039,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
lea    0xe92(%rip),%rsi
lea    0xe91(%rip),%rdx
mov    %rbx,%rdi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
lea    0xe8a(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <pbc_wmessage_message@plt>
lea    0xe7e(%rip),%r15
lea    0xe7e(%rip),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <pbc_wmessage_message@plt>
mov    %rax,%r14
lea    0xe62(%rip),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
lea    0xe57(%rip),%rsi
lea    0xe55(%rip),%rdx
mov    %r14,%rdi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
lea    0xe55(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xffffff85,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3039,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x12d687,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
mov    $0xd431,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pbc_wmessage = type { i32 }
%struct.pbc_env = type { i32 }
@.str = [16 x i8] c"tutorial.Person\00"
@.str.1 = [5 x i8] c"name\00"
@.str.2 = [6 x i8] c"Alice\00"
@.str.3 = [3 x i8] c"id\00"
@.str.4 = [6 x i8] c"email\00"
@.str.5 = [13 x i8] c"alice@unkown\00"
@.str.6 = [6 x i8] c"phone\00"
@.str.7 = [7 x i8] c"number\00"
@.str.8 = [9 x i8] c"87654321\00"
@.str.9 = [12 x i8] c"13901234567\00"
@.str.10 = [5 x i8] c"type\00"
@.str.11 = [7 x i8] c"MOBILE\00"
@.str.12 = [5 x i8] c"test\00"
@.str.13 = [18 x i8] c"tutorial.Ext.test\00"
define %struct.pbc_wmessage* @test_wmessage(%struct.pbc_env* %0) {
%2 = alloca %struct.pbc_env*
%3 = alloca %struct.pbc_wmessage*
%4 = alloca %struct.pbc_wmessage*
store %struct.pbc_env* %0, %struct.pbc_env** %2
%5 = load %struct.pbc_env*, %struct.pbc_env** %2
%6 = call %struct.pbc_wmessage* @pbc_wmessage_new(%struct.pbc_env* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store %struct.pbc_wmessage* %6, %struct.pbc_wmessage** %3
%7 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%8 = call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%9 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%10 = call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 12345, i32 0)
%11 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%12 = call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 -1)
%13 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%14 = call %struct.pbc_wmessage* @pbc_wmessage_message(%struct.pbc_wmessage* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store %struct.pbc_wmessage* %14, %struct.pbc_wmessage** %4
%15 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %4
%16 = call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 -1)
%17 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%18 = call %struct.pbc_wmessage* @pbc_wmessage_message(%struct.pbc_wmessage* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store %struct.pbc_wmessage* %18, %struct.pbc_wmessage** %4
%19 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %4
%20 = call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 -1)
%21 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %4
%22 = call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 -1)
%23 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%24 = call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 -123, i32 0)
%25 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%26 = call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 12345, i32 0)
%27 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%28 = call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 1234567, i32 0)
%29 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%30 = call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %29, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i32 54321, i32 0)
%31 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
ret %struct.pbc_wmessage* %31
}

LLVM IR (-O2):
%struct.pbc_wmessage = type { i32 }
%struct.pbc_env = type { i32 }
@.str = [16 x i8] c"tutorial.Person\00"
@.str.1 = [5 x i8] c"name\00"
@.str.2 = [6 x i8] c"Alice\00"
@.str.3 = [3 x i8] c"id\00"
@.str.4 = [6 x i8] c"email\00"
@.str.5 = [13 x i8] c"alice@unkown\00"
@.str.6 = [6 x i8] c"phone\00"
@.str.7 = [7 x i8] c"number\00"
@.str.8 = [9 x i8] c"87654321\00"
@.str.9 = [12 x i8] c"13901234567\00"
@.str.10 = [5 x i8] c"type\00"
@.str.11 = [7 x i8] c"MOBILE\00"
@.str.12 = [5 x i8] c"test\00"
@.str.13 = [18 x i8] c"tutorial.Ext.test\00"
define %struct.pbc_wmessage* @test_wmessage(%struct.pbc_env* %0) {
%2 = tail call %struct.pbc_wmessage* @pbc_wmessage_new(%struct.pbc_env* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%4 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 12345, i32 0)
%5 = tail call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 -1)
%6 = tail call %struct.pbc_wmessage* @pbc_wmessage_message(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%7 = tail call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 -1)
%8 = tail call %struct.pbc_wmessage* @pbc_wmessage_message(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 -1)
%10 = tail call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 -1)
%11 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 -123, i32 0)
%12 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 12345, i32 0)
%13 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 1234567, i32 0)
%14 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i32 54321, i32 0)
ret %struct.pbc_wmessage* %2
}