#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*/ XDR;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ XDR_ENCODE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ xdr_float(int /*<<< orphan*/ *, float *);
int /*<<< orphan*/ xdr_long(int /*<<< orphan*/ *, long *);
int xdr_string(int /*<<< orphan*/ *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ xdrstdio_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/);
main() {
  FILE *fp;
  XDR xdrs;
  long val1 = 10;
  float val2 = 4.456789;
  char val3s[] = "qwerty123456uvwxyz";
  char *val3;
  int r;
  val3 = malloc(20);
  strcpy(val3, val3s);
  fp = fopen("/tmp/test.xdr", "w");
  xdrstdio_create(&xdrs, fp, XDR_ENCODE);
  xdr_long(&xdrs, &val1);
  xdr_float(&xdrs, &val2);
  r = xdr_string(&xdrs, &val3, strlen(val3));
  printf("r=%d\n", r);
  free(val3);
  fclose(fp);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xa,-0x20(%rbp)
movss  0xe21(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    0xe25(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe22(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe1f(%rip),%ax
mov    %ax,-0x30(%rbp)
mov    0xe17(%rip),%al
mov    %al,-0x2e(%rbp)
mov    $0x14,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcpy@plt>
lea    0xdf3(%rip),%rdi
lea    0xdfa(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2d9d(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rdi
call   1040 <xdrstdio_create@plt>
lea    -0x14(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10c0 <xdr_long@plt>
lea    -0x14(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   10e0 <xdr_float@plt>
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%edx
lea    -0x14(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1090 <xdr_string@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
lea    0xd9e(%rip),%rdi
call   1080 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movq   $0xa,0x10(%rsp)
movl   $0x408e9e04,0x4(%rsp)
40
movaps 0xe1f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x7a7978,0x2f(%rsp)
mov    $0x14,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
lea    0x20(%rsp),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xdff(%rip),%rdi
lea    0xe06(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
mov    0x2dbe(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <xdrstdio_create@plt>
lea    0x10(%rsp),%rsi
mov    %r15,%rdi
call   10c0 <xdr_long@plt>
lea    0x4(%rsp),%rsi
mov    %r15,%rdi
call   10e0 <xdr_float@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1090 <xdr_string@plt>
lea    0xdaf(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@__const.main.val3s = [19 x i8] c"qwerty123456uvwxyz\00"
@.str = [14 x i8] c"/tmp/test.xdr\00"
@.str.1 = [2 x i8] c"w\00"
@XDR_ENCODE = global i32 0
@.str.2 = [6 x i8] c"r=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
%5 = alloca float
%6 = alloca [19 x i8]
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %1
store i64 10, i64* %4
store float 0x4011D3C080000000, float* %5
%9 = bitcast [19 x i8]* %6 to i8*
%10 = call i8* @malloc(i32 20)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = getelementptr inbounds [19 x i8], [19 x i8]* %6, i64 0, i64 0
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %2
%15 = load i32*, i32** %2
%16 = load i32, i32* @XDR_ENCODE
%17 = call i32 @xdrstdio_create(i32* %3, i32* %15, i32 %16)
%18 = call i32 @xdr_long(i32* %3, i64* %4)
%19 = call i32 @xdr_float(i32* %3, float* %5)
%20 = load i8*, i8** %7
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @xdr_string(i32* %3, i8** %7, i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
%27 = load i32*, i32** %2
%28 = call i32 @fclose(i32* %27)
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@__const.main.val3s = [19 x i8] c"qwerty123456uvwxyz\00"
@.str = [14 x i8] c"/tmp/test.xdr\00"
@.str.1 = [2 x i8] c"w\00"
@XDR_ENCODE = global i32 0
@.str.2 = [6 x i8] c"r=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca float
%4 = alloca [19 x i8]
%5 = alloca i8*
%6 = bitcast i32* %1 to i8*
%7 = bitcast i64* %2 to i8*
store i64 10, i64* %2
%8 = bitcast float* %3 to i8*
store float 0x4011D3C080000000, float* %3
%9 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%10 = bitcast i8** %5 to i8*
%11 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
store i8* %11, i8** %5
%12 = call i32 @strcpy(i8* %11, i8* %9)
%13 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @XDR_ENCODE
%15 = call i32 @xdrstdio_create(i32* %1, i32* %13, i32 %14)
%16 = call i32 @xdr_long(i32* %1, i64* %2)
%17 = call i32 @xdr_float(i32* %1, float* %3)
%18 = call i32 @strlen(i8* %11)
%19 = call i32 @xdr_string(i32* %1, i8** %5, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i8*, i8** %5
%22 = call i32 @free(i8* %21)
%23 = call i32 @fclose(i32* %13)
%24 = call i32 @exit(i32 0)
unreachable
}