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

/* Variables and functions */
int get_labeladdr(struct label *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int get_lconst(char *str, char *delim, struct label *l) {
  int addr;
  char name[80];
  if (delim - str < 1)
    return (-3);
  strncpy(name, str, delim - str);
  name[delim - str] = '\0';
  addr = get_labeladdr(l, name);
  if (addr < 0) {
    puts("Label not found");
    return (-3);
  }
  return addr;
}


x86 assembly (clang, -O0):
<get_lconst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x1,%rax
jge    1168 <get_lconst+0x38>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11ca <get_lconst+0x9a>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
movb   $0x0,-0x80(%rbp,%rax,1)
mov    -0x20(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1050 <get_labeladdr@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11c4 <get_lconst+0x94>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11ca <get_lconst+0x9a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_lconst>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%rbx
sub    %rdi,%rbx
mov    $0xfffffffd,%eax
test   %rbx,%rbx
jle    1180 <get_lconst+0x50>
mov    %rdx,%r14
mov    %rdi,%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rsp,%rbx,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <get_labeladdr@plt>
test   %eax,%eax
jns    1180 <get_lconst+0x50>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffd,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.label = type { i32 }
@.str = [16 x i8] c"Label not found\00"
define i32 @get_lconst(i8* %0, i8* %1, %struct.label* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.label*
%8 = alloca i32
%9 = alloca [80 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store %struct.label* %2, %struct.label** %7
%10 = load i8*, i8** %6
%11 = load i8*, i8** %5
%12 = ptrtoint i8* %10 to i64
%13 = ptrtoint i8* %11 to i64
%14 = sub i64 %12, %13
%15 = icmp slt i64 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -3, i32* %4
br label %42
17: ; preds = %3
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = load i8*, i8** %5
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @strncpy(i8* %18, i8* %19, i32 %25)
%27 = load i8*, i8** %6
%28 = load i8*, i8** %5
%29 = ptrtoint i8* %27 to i64
%30 = ptrtoint i8* %28 to i64
%31 = sub i64 %29, %30
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %31
store i8 0, i8* %32
%33 = load %struct.label*, %struct.label** %7
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%35 = call i32 @get_labeladdr(%struct.label* %33, i8* %34)
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %17
%39 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 -3, i32* %4
br label %42
40: ; preds = %17
%41 = load i32, i32* %8
store i32 %41, i32* %4
br label %42
42: ; preds = %40, %38, %16
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
%struct.label = type { i32 }
@.str = [16 x i8] c"Label not found\00"
define i32 @get_lconst(i8* %0, i8* %1, %struct.label* %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = ptrtoint i8* %1 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = icmp slt i64 %8, 1
br i1 %9, label %18, label %10
10: ; preds = %3
%11 = trunc i64 %8 to i32
%12 = call i32 @strncpy(i8* %5, i8* %0, i32 %11)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %8
store i8 0, i8* %13
%14 = call i32 @get_labeladdr(%struct.label* %2, i8* %5)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %10, %3, %16
%19 = phi i32 [ -3, %16 ], [ -3, %3 ], [ %14, %10 ]
ret i32 %19
}