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

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
unsigned int strlen(char *);
int /*<<< orphan*/ xdr_bytes(int /*<<< orphan*/ *, char **, unsigned int *,
                             int);
int /*<<< orphan*/ xdr_u_int(int /*<<< orphan*/ *, unsigned int *);
bool_t xdr_simple_string(XDR *xdrs, char **str) {
  unsigned len;
  char *p = *str;
  len = (str) ? strlen(*str) : 0;
  if (!xdr_u_int(xdrs, &len))
    return (FALSE);
  if (len > 0) {
    if (!xdr_bytes(xdrs, &p, &len, 128))
      return (FALSE);
  }
  *str = p;
  return (TRUE);
}


x86 assembly (clang, -O0):
<xdr_simple_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116a <xdr_simple_string+0x3a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    1174 <xdr_simple_string+0x44>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    1174 <xdr_simple_string+0x44>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <xdr_u_int@plt>
cmp    $0x0,%eax
jne    11a1 <xdr_simple_string+0x71>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <xdr_simple_string+0xc7>
cmpl   $0x0,-0x1c(%rbp)
jbe    11e0 <xdr_simple_string+0xb0>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x80,%ecx
call   1040 <xdr_bytes@plt>
cmp    $0x0,%eax
jne    11db <xdr_simple_string+0xab>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <xdr_simple_string+0xc7>
jmp    11e0 <xdr_simple_string+0xb0>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr_simple_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%rbx
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %r15,%rdi
call   1050 <xdr_u_int@plt>
mov    0x2e6f(%rip),%r12
test   %eax,%eax
je     119e <xdr_simple_string+0x6e>
cmpl   $0x0,0xc(%rsp)
je     1194 <xdr_simple_string+0x64>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    $0x80,%ecx
call   1040 <xdr_bytes@plt>
test   %eax,%eax
je     119e <xdr_simple_string+0x6e>
mov    0x10(%rsp),%rbx
mov    %rbx,(%r14)
mov    0x2e4a(%rip),%r12
mov    (%r12),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdr_simple_string(i32* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
store i8* %9, i8** %7
%10 = load i8**, i8*** %5
%11 = icmp ne i8** %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = call i32 @strlen(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %12
%18 = phi i32 [ %15, %12 ], [ 0, %16 ]
store i32 %18, i32* %6
%19 = load i32*, i32** %4
%20 = call i32 @xdr_u_int(i32* %19, i32* %6)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = load i32, i32* @FALSE
store i32 %23, i32* %3
br label %38
24: ; preds = %17
%25 = load i32, i32* %6
%26 = icmp ugt i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i32*, i32** %4
%29 = call i32 @xdr_bytes(i32* %28, i8** %7, i32* %6, i32 128)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = load i32, i32* @FALSE
store i32 %32, i32* %3
br label %38
33: ; preds = %27
br label %34
34: ; preds = %33, %24
%35 = load i8*, i8** %7
%36 = load i8**, i8*** %5
store i8* %35, i8** %36
%37 = load i32, i32* @TRUE
store i32 %37, i32* %3
br label %38
38: ; preds = %34, %31, %22
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @xdr_simple_string(i32* %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = bitcast i32* %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = load i8*, i8** %1
store i8* %7, i8** %4
%8 = tail call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = call i32 @xdr_u_int(i32* %0, i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = call i32 @xdr_bytes(i32* %0, i8** %4, i32* %3, i32 128)
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i8*, i8** %4
br label %19
19: ; preds = %17, %11
%20 = phi i8* [ %18, %17 ], [ %7, %11 ]
store i8* %20, i8** %1
br label %21
21: ; preds = %14, %2, %19
%22 = phi i32* [ @TRUE, %19 ], [ @FALSE, %2 ], [ @FALSE, %14 ]
%23 = load i32, i32* %22
ret i32 %23
}