#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 xml_reader {
  int dummy;
};
struct manifest_tpk {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int xml_read_attribute_copy(char const **, char const *, char **);
int set_optional_attribute(struct xml_reader *reader, const char *elem,
                           const char **attrs, struct manifest_tpk *manif,
                           char **data, const char *name) {
  int status;
  assert(!*data);
  status = xml_read_attribute_copy(attrs, name, data);
  if (status < 0)
    return -1;
  assert((status == 0) == (*data == NULL));
  return 0;
}


x86 assembly (clang, -O0):
<set_optional_attribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <xml_read_attribute_copy@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1181 <set_optional_attribute+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <set_optional_attribute+0x94>
cmpl   $0x0,-0x3c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x30(%rbp),%rcx
cmpq   $0x0,(%rcx)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_optional_attribute>:
push   %r15
push   %r14
push   %rbx
mov    %r9,%r14
mov    %r8,%rbx
mov    %rdx,%r15
xor    %edi,%edi
cmpq   $0x0,(%r8)
sete   %dil
call   1040 <assert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <xml_read_attribute_copy@plt>
test   %eax,%eax
js     1167 <set_optional_attribute+0x47>
setne  %al
cmpq   $0x0,(%rbx)
sete   %cl
xor    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
xor    %eax,%eax
jmp    116c <set_optional_attribute+0x4c>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.xml_reader = type { i32 }
%struct.manifest_tpk = type { i32 }
define i32 @set_optional_attribute(%struct.xml_reader* %0, i8* %1, i8** %2, %struct.manifest_tpk* %3, i8** %4, i8* %5) {
%7 = alloca i32
%8 = alloca %struct.xml_reader*
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca %struct.manifest_tpk*
%12 = alloca i8**
%13 = alloca i8*
%14 = alloca i32
store %struct.xml_reader* %0, %struct.xml_reader** %8
store i8* %1, i8** %9
store i8** %2, i8*** %10
store %struct.manifest_tpk* %3, %struct.manifest_tpk** %11
store i8** %4, i8*** %12
store i8* %5, i8** %13
%15 = load i8**, i8*** %12
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8**, i8*** %10
%22 = load i8*, i8** %13
%23 = load i8**, i8*** %12
%24 = call i32 @xml_read_attribute_copy(i8** %21, i8* %22, i8** %23)
store i32 %24, i32* %14
%25 = load i32, i32* %14
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %6
store i32 -1, i32* %7
br label %39
28: ; preds = %6
%29 = load i32, i32* %14
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = load i8**, i8*** %12
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
%35 = zext i1 %34 to i32
%36 = icmp eq i32 %31, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
store i32 0, i32* %7
br label %39
39: ; preds = %28, %27
%40 = load i32, i32* %7
ret i32 %40
}

LLVM IR (-O2):
%struct.xml_reader = type { i32 }
%struct.manifest_tpk = type { i32 }
define i32 @set_optional_attribute(%struct.xml_reader* nocapture readnone %0, i8* nocapture readnone %1, i8** %2, %struct.manifest_tpk* nocapture readnone %3, i8** %4, i8* %5) {
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @xml_read_attribute_copy(i8** %2, i8* %5, i8** %4)
%12 = icmp slt i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %6
%14 = icmp ne i32 %11, 0
%15 = load i8*, i8** %4
%16 = icmp eq i8* %15, null
%17 = xor i1 %14, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
br label %20
20: ; preds = %6, %13
%21 = phi i32 [ 0, %13 ], [ -1, %6 ]
ret i32 %21
}