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

/* Variables and functions */
int /*<<< orphan*/ kv_data(struct writer *, char const *);
int /*<<< orphan*/ kv_end(struct writer *);
int /*<<< orphan*/ kv_start(struct writer *, char const *,
                            int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(char const *, char *);
void kv_attr(struct writer *w, const char *tag, const char *descr,
             const char *value) {
  if (!strcmp(tag, "name") || !strcmp(tag, "type")) {
    kv_end(w);
    kv_start(w, value, NULL);
  } else {
    kv_start(w, tag, NULL);
    kv_data(w, value);
    kv_end(w);
  }
}


x86 assembly (clang, -O0):
<kv_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     118a <kv_attr+0x4a>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a9 <kv_attr+0x69>
mov    -0x8(%rbp),%rdi
call   1030 <kv_end@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <kv_start@plt>
jmp    11d0 <kv_attr+0x90>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <kv_start@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <kv_data@plt>
mov    -0x8(%rbp),%rdi
call   1030 <kv_end@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kv_attr>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1199 <kv_attr+0x59>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1199 <kv_attr+0x59>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <kv_start@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <kv_data@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <kv_end@plt>
mov    %r15,%rdi
call   1030 <kv_end@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <kv_start@plt>

LLVM IR (-O0):
%struct.writer = type { i32 }
@.str = [5 x i8] c"name\00"
@.str.1 = [5 x i8] c"type\00"
define void @kv_attr(%struct.writer* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca %struct.writer*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.writer* %0, %struct.writer** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %6
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i8*, i8** %6
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %12, %4
%17 = load %struct.writer*, %struct.writer** %5
%18 = call i32 @kv_end(%struct.writer* %17)
%19 = load %struct.writer*, %struct.writer** %5
%20 = load i8*, i8** %8
%21 = call i32 @kv_start(%struct.writer* %19, i8* %20, i32* null)
br label %31
22: ; preds = %12
%23 = load %struct.writer*, %struct.writer** %5
%24 = load i8*, i8** %6
%25 = call i32 @kv_start(%struct.writer* %23, i8* %24, i32* null)
%26 = load %struct.writer*, %struct.writer** %5
%27 = load i8*, i8** %8
%28 = call i32 @kv_data(%struct.writer* %26, i8* %27)
%29 = load %struct.writer*, %struct.writer** %5
%30 = call i32 @kv_end(%struct.writer* %29)
br label %31
31: ; preds = %22, %16
ret void
}

LLVM IR (-O2):
%struct.writer = type { i32 }
@.str = [5 x i8] c"name\00"
@.str.1 = [5 x i8] c"type\00"
define void @kv_attr(%struct.writer* %0, i8* %1, i8* nocapture readnone %2, i8* %3) {
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7, %4
%11 = tail call i32 @kv_end(%struct.writer* %0)
%12 = tail call i32 @kv_start(%struct.writer* %0, i8* %3, i32* null)
br label %17
13: ; preds = %7
%14 = tail call i32 @kv_start(%struct.writer* %0, i8* %1, i32* null)
%15 = tail call i32 @kv_data(%struct.writer* %0, i8* %3)
%16 = tail call i32 @kv_end(%struct.writer* %0)
br label %17
17: ; preds = %13, %10
ret void
}