#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 pool {
  int dummy;
};

/* Variables and functions */
int pool_new_str(struct pool *, char const *);
int /*<<< orphan*/ pool_ptr(struct pool *, int);
int /*<<< orphan*/ pool_restore(struct pool *, int);
int pool_state(struct pool *);
int xml_make_attr(int, int, int, struct pool *);
int xml_make_attr_s(const char *name, const char *value, int next,
                    struct pool *p) {
  int mark, h, s;
  mark = pool_state(p);
  s = pool_new_str(p, value);
  h = xml_make_attr(pool_new_str(p, name), s, next, p);
  if (h == (-1) || !pool_ptr(p, s))
    pool_restore(p, mark);
  return h;
}


x86 assembly (clang, -O0):
<xml_make_attr_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <pool_state@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <pool_new_str@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <pool_new_str@plt>
mov    %eax,%edi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1040 <xml_make_attr@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
je     11c3 <xml_make_attr_s+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1060 <pool_ptr@plt>
cmp    $0x0,%eax
jne    11cf <xml_make_attr_s+0x7f>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <pool_restore@plt>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xml_make_attr_s>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r13
mov    %rcx,%rdi
call   1050 <pool_state@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <pool_new_str@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <pool_new_str@plt>
mov    %eax,%edi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %rbx,%rcx
call   1040 <xml_make_attr@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     11b1 <xml_make_attr_s+0x61>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1060 <pool_ptr@plt>
test   %eax,%eax
jne    11bc <xml_make_attr_s+0x6c>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1070 <pool_restore@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pool = type { i32 }
define i32 @xml_make_attr_s(i8* %0, i8* %1, i32 %2, %struct.pool* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.pool*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store %struct.pool* %3, %struct.pool** %8
%12 = load %struct.pool*, %struct.pool** %8
%13 = call i32 @pool_state(%struct.pool* %12)
store i32 %13, i32* %9
%14 = load %struct.pool*, %struct.pool** %8
%15 = load i8*, i8** %6
%16 = call i32 @pool_new_str(%struct.pool* %14, i8* %15)
store i32 %16, i32* %11
%17 = load %struct.pool*, %struct.pool** %8
%18 = load i8*, i8** %5
%19 = call i32 @pool_new_str(%struct.pool* %17, i8* %18)
%20 = load i32, i32* %11
%21 = load i32, i32* %7
%22 = load %struct.pool*, %struct.pool** %8
%23 = call i32 @xml_make_attr(i32 %19, i32 %20, i32 %21, %struct.pool* %22)
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = icmp eq i32 %24, -1
br i1 %25, label %31, label %26
26: ; preds = %4
%27 = load %struct.pool*, %struct.pool** %8
%28 = load i32, i32* %11
%29 = call i32 @pool_ptr(%struct.pool* %27, i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %26, %4
%32 = load %struct.pool*, %struct.pool** %8
%33 = load i32, i32* %9
%34 = call i32 @pool_restore(%struct.pool* %32, i32 %33)
br label %35
35: ; preds = %31, %26
%36 = load i32, i32* %10
ret i32 %36
}

LLVM IR (-O2):
%struct.pool = type { i32 }
define i32 @xml_make_attr_s(i8* %0, i8* %1, i32 %2, %struct.pool* %3) {
%5 = tail call i32 @pool_state(%struct.pool* %3)
%6 = tail call i32 @pool_new_str(%struct.pool* %3, i8* %1)
%7 = tail call i32 @pool_new_str(%struct.pool* %3, i8* %0)
%8 = tail call i32 @xml_make_attr(i32 %7, i32 %6, i32 %2, %struct.pool* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %4
%11 = tail call i32 @pool_ptr(%struct.pool* %3, i32 %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %4
%14 = tail call i32 @pool_restore(%struct.pool* %3, i32 %5)
br label %15
15: ; preds = %13, %10
ret i32 %8
}