#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*/ uint64_t;
struct label {
  int dummy;
};
typedef int /*<<< orphan*/ label;

/* Variables and functions */
int create_section_label_name(char *, int, char const *, char const *);
int l_lookup(struct label *, int /*<<< orphan*/ *, char *);
int lookup_section_label(struct label *l, const char *name,
                         const char *attribute, uint64_t *value) {
  char label[255];
  int errcode;
  errcode = create_section_label_name(label, sizeof(label), name, attribute);
  if (errcode < 0)
    return errcode;
  return l_lookup(l, value, label);
}


x86 assembly (clang, -O0):
<lookup_section_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xff,%esi
call   1030 <create_section_label_name@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jge    1175 <lookup_section_label+0x55>
mov    -0x134(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <lookup_section_label+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x130(%rbp),%rdx
call   1040 <l_lookup@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup_section_label>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rcx,%r14
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0xff,%esi
call   1030 <create_section_label_name@plt>
test   %eax,%eax
js     1155 <lookup_section_label+0x35>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <l_lookup@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.label = type { i32 }
define i32 @lookup_section_label(%struct.label* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca %struct.label*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca [255 x i8]
%11 = alloca i32
store %struct.label* %0, %struct.label** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%15 = call i32 @create_section_label_name(i8* %12, i32 255, i8* %13, i8* %14)
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %4
%19 = load i32, i32* %11
store i32 %19, i32* %5
br label %25
20: ; preds = %4
%21 = load %struct.label*, %struct.label** %6
%22 = load i32*, i32** %9
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%24 = call i32 @l_lookup(%struct.label* %21, i32* %22, i8* %23)
store i32 %24, i32* %5
br label %25
25: ; preds = %20, %18
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
%struct.label = type { i32 }
define i32 @lookup_section_label(%struct.label* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%7 = call i32 @create_section_label_name(i8* %6, i32 255, i8* %1, i8* %2)
%8 = icmp slt i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = call i32 @l_lookup(%struct.label* %0, i32* %3, i8* %6)
br label %11
11: ; preds = %4, %9
%12 = phi i32 [ %10, %9 ], [ %7, %4 ]
ret i32 %12
}