#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*/ abort();
unsigned long mgetsize(unsigned long *, unsigned long *);
char *mgetstring();
int /*<<< orphan*/ mputstring(char *);
scalar_t__ msetsize(unsigned long, unsigned long, long);
int /*<<< orphan*/ msynch();
scalar_t__ section_name(unsigned long);
scalar_t__ strcmp(char *, char *);
long section_named(void) {
  unsigned long off0, off1;
  unsigned long len;
  long delta = 0;
  msynch();
  len = mgetsize(&off0, &off1);
  msynch();
  char *str = mgetstring();
  if (strcmp(str, "name") == 0) {
    mputstring(str);
    delta += section_name(len);
  } else {
    abort();
  }
  delta += msetsize(off0, off1, delta);
  return delta;
}


x86 assembly (clang, -O0):
<section_named>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1080 <msynch@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <mgetsize@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <msynch@plt>
mov    $0x0,%al
call   1090 <mgetstring@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <section_named+0x73>
mov    -0x28(%rbp),%rdi
call   1050 <mputstring@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <section_name@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11fa <section_named+0x7a>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <msetsize@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<section_named>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1080 <msynch@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <mgetsize@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1080 <msynch@plt>
xor    %eax,%eax
call   1090 <mgetstring@plt>
mov    %rax,%rbx
lea    0xe48(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11f5 <section_named+0x75>
mov    %rbx,%rdi
call   1050 <mputstring@plt>
mov    %r14,%rdi
call   10a0 <section_name@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1060 <msetsize@plt>
add    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"name\00"
define i64 @section_named() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 0, i64* %4
%6 = call i32 (...) @msynch()
%7 = call i64 @mgetsize(i64* %1, i64* %2)
store i64 %7, i64* %3
%8 = call i32 (...) @msynch()
%9 = call i8* (...) @mgetstring()
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %0
%14 = load i8*, i8** %5
%15 = call i32 @mputstring(i8* %14)
%16 = load i64, i64* %3
%17 = call i64 @section_name(i64 %16)
%18 = load i64, i64* %4
%19 = add nsw i64 %18, %17
store i64 %19, i64* %4
br label %22
20: ; preds = %0
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %13
%23 = load i64, i64* %1
%24 = load i64, i64* %2
%25 = load i64, i64* %4
%26 = call i64 @msetsize(i64 %23, i64 %24, i64 %25)
%27 = load i64, i64* %4
%28 = add nsw i64 %27, %26
store i64 %28, i64* %4
%29 = load i64, i64* %4
ret i64 %29
}

LLVM IR (-O2):
@.str = [5 x i8] c"name\00"
define i64 @section_named() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (...) @msynch()
%6 = call i64 @mgetsize(i64* %1, i64* %2)
%7 = call i32 (...) @msynch()
%8 = call i8* (...) @mgetstring()
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %0
%12 = call i32 @mputstring(i8* %8)
%13 = call i64 @section_name(i64 %6)
%14 = load i64, i64* %1
%15 = load i64, i64* %2
%16 = call i64 @msetsize(i64 %14, i64 %15, i64 %13)
%17 = add nsw i64 %16, %13
ret i64 %17
18: ; preds = %0
%19 = call i32 (...) @abort()
unreachable
}