#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ get_key_value(char **, char **, char const *);
int /*<<< orphan*/ printf(char *, char *, char *, int, int);
int /*<<< orphan*/ write_value(char const *, char *, char *);
void attribute(int css, int num, const char *dir, const char *key_val) {
  char *key, *val;
  if (get_key_value(&key, &val, key_val))
    return;
  printf("Attribute %s=%s %x.%02x... ", key, val, css, num);
  write_value(dir, key, val);
  free(key);
  free(val);
}


x86 assembly (clang, -O0):
<attribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <get_key_value@plt>
cmp    $0x0,%rax
je     1176 <attribute+0x36>
jmp    11b4 <attribute+0x74>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <write_value@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attribute>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
mov    %rcx,%rdx
call   1040 <get_key_value@plt>
test   %rax,%rax
jne    11a2 <attribute+0x62>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
lea    0xe8c(%rip),%rdi
mov    %ebx,%ecx
mov    %ebp,%r8d
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
mov    %r14,%rdi
call   1060 <write_value@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Attribute %s=%s %x.%02x... \00"
define void @attribute(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %8
%12 = call i64 @get_key_value(i8** %9, i8** %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
br label %29
15: ; preds = %4
%16 = load i8*, i8** %9
%17 = load i8*, i8** %10
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i32 %18, i32 %19)
%21 = load i8*, i8** %7
%22 = load i8*, i8** %9
%23 = load i8*, i8** %10
%24 = call i32 @write_value(i8* %21, i8* %22, i8* %23)
%25 = load i8*, i8** %9
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %10
%28 = call i32 @free(i8* %27)
br label %29
29: ; preds = %15, %14
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Attribute %s=%s %x.%02x... \00"
define void @attribute(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = bitcast i8** %5 to i8*
%8 = bitcast i8** %6 to i8*
%9 = call i64 @get_key_value(i8** %5, i8** %6, i8* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %4
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i32 %0, i32 %1)
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = call i32 @write_value(i8* %2, i8* %15, i8* %16)
%18 = load i8*, i8** %5
%19 = call i32 @free(i8* %18)
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
br label %22
22: ; preds = %4, %11
ret void
}