#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, "LocalResourceProto");
  pbc_wmessage_integer(msg, "size", 123455432, 0);
  pbc_wmessage_integer(msg, "timestamp", 99999999, 0);
  pbc_wmessage_string(msg, "pattern", "pattern-pattern", -1);
  struct pbc_wmessage *url = pbc_wmessage_message(msg, "resource");
  pbc_wmessage_string(url, "scheme", "ftp", -1);
  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    0xea8(%rip),%rsi
mov    $0x75bc7c8,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x5f5e0ff,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
lea    0xe82(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1030 <pbc_wmessage_message@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe72(%rip),%rsi
lea    0xe72(%rip),%rdx
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_wmessage>:
push   %rbx
lea    0xeb8(%rip),%rsi
call   1050 <pbc_wmessage_new@plt>
mov    %rax,%rbx
lea    0xebc(%rip),%rsi
mov    %rax,%rdi
mov    $0x75bc7c8,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5f5e0ff,%edx
xor    %ecx,%ecx
call   1060 <pbc_wmessage_integer@plt>
lea    0xea7(%rip),%rsi
lea    0xe98(%rip),%rdx
mov    %rbx,%rdi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <pbc_wmessage_message@plt>
lea    0xe8e(%rip),%rsi
lea    0xe8e(%rip),%rdx
mov    %rax,%rdi
mov    $0xffffffff,%ecx
call   1040 <pbc_wmessage_string@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.pbc_wmessage = type { i32 }
%struct.pbc_env = type { i32 }
@.str = [19 x i8] c"LocalResourceProto\00"
@.str.1 = [5 x i8] c"size\00"
@.str.2 = [10 x i8] c"timestamp\00"
@.str.3 = [8 x i8] c"pattern\00"
@.str.4 = [16 x i8] c"pattern-pattern\00"
@.str.5 = [9 x i8] c"resource\00"
@.str.6 = [7 x i8] c"scheme\00"
@.str.7 = [4 x i8] c"ftp\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 ([19 x i8], [19 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_integer(%struct.pbc_wmessage* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 123455432, i32 0)
%9 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%10 = call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 99999999, i32 0)
%11 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
%12 = call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, 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 ([9 x i8], [9 x i8]* @.str.5, 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.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -1)
%17 = load %struct.pbc_wmessage*, %struct.pbc_wmessage** %3
ret %struct.pbc_wmessage* %17
}

LLVM IR (-O2):
%struct.pbc_wmessage = type { i32 }
%struct.pbc_env = type { i32 }
@.str = [19 x i8] c"LocalResourceProto\00"
@.str.1 = [5 x i8] c"size\00"
@.str.2 = [10 x i8] c"timestamp\00"
@.str.3 = [8 x i8] c"pattern\00"
@.str.4 = [16 x i8] c"pattern-pattern\00"
@.str.5 = [9 x i8] c"resource\00"
@.str.6 = [7 x i8] c"scheme\00"
@.str.7 = [4 x i8] c"ftp\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 ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 123455432, i32 0)
%4 = tail call i32 @pbc_wmessage_integer(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 99999999, i32 0)
%5 = tail call i32 @pbc_wmessage_string(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 -1)
%6 = tail call %struct.pbc_wmessage* @pbc_wmessage_message(%struct.pbc_wmessage* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, 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.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -1)
ret %struct.pbc_wmessage* %2
}