#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*/ new_directive(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char *);
int /*<<< orphan*/ strdup(char *);
void def_section(const char *name, int attr) {
  char buf[200];
  char atts[5];
  char *d = atts;
  if (attr & 1)
    *d++ = 'R';
  if (attr & 2)
    *d++ = 'W';
  if (attr & 4)
    *d++ = 'X';
  if (attr & 8)
    *d++ = 'S';
  *d++ = 0;
  sprintf(buf, "-attr %s %s", name, atts);
  new_directive(strdup(buf));
}


x86 assembly (clang, -O0):
<def_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0xe5(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1177 <def_section+0x47>
mov    -0xf0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xf0(%rbp)
movb   $0x52,(%rax)
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     119e <def_section+0x6e>
mov    -0xf0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xf0(%rbp)
movb   $0x57,(%rax)
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11c5 <def_section+0x95>
mov    -0xf0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xf0(%rbp)
movb   $0x58,(%rax)
mov    -0xc(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ec <def_section+0xbc>
mov    -0xf0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xf0(%rbp)
movb   $0x53,(%rax)
mov    -0xf0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xf0(%rbp)
movb   $0x0,(%rax)
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    -0xe5(%rbp),%rcx
lea    0xde3(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
call   1050 <strdup@plt>
mov    %eax,%edi
call   1030 <new_directive@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<def_section>:
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%rdx
test   $0x1,%sil
jne    114e <def_section+0x1e>
lea    0xb(%rsp),%rax
test   $0x2,%sil
jne    115e <def_section+0x2e>
jmp    1165 <def_section+0x35>
lea    0xc(%rsp),%rax
movb   $0x52,0xb(%rsp)
test   $0x2,%sil
je     1165 <def_section+0x35>
movb   $0x57,(%rax)
add    $0x1,%rax
test   $0x4,%sil
jne    11ac <def_section+0x7c>
test   $0x8,%sil
je     1178 <def_section+0x48>
movb   $0x53,(%rax)
add    $0x1,%rax
movb   $0x0,(%rax)
lea    0xe7e(%rip),%rsi
lea    0x10(%rsp),%rbx
lea    0xb(%rsp),%rcx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strdup@plt>
mov    %eax,%edi
call   1030 <new_directive@plt>
add    $0xe0,%rsp
pop    %rbx
ret
movb   $0x58,(%rax)
add    $0x1,%rax
test   $0x8,%sil
jne    1171 <def_section+0x41>
jmp    1178 <def_section+0x48>

LLVM IR (-O0):
@.str = [12 x i8] c"-attr %s %s\00"
define void @def_section(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [200 x i8]
%6 = alloca [5 x i8]
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
store i8* %8, i8** %7
%9 = load i32, i32* %4
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %7
store i8 82, i8* %13
br label %15
15: ; preds = %12, %2
%16 = load i32, i32* %4
%17 = and i32 %16, 2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %7
store i8 87, i8* %20
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %4
%24 = and i32 %23, 4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
store i8 88, i8* %27
br label %29
29: ; preds = %26, %22
%30 = load i32, i32* %4
%31 = and i32 %30, 8
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
store i8 83, i8* %34
br label %36
36: ; preds = %33, %29
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %7
store i8 0, i8* %37
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%40 = load i8*, i8** %3
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%42 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %40, i8* %41)
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%44 = call i32 @strdup(i8* %43)
%45 = call i32 @new_directive(i32 %44)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"-attr %s %s\00"
define void @def_section(i8* %0, i32 %1) {
%3 = alloca [200 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = and i32 %1, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 1
store i8 82, i8* %6
br label %11
11: ; preds = %9, %2
%12 = phi i8* [ %10, %9 ], [ %6, %2 ]
%13 = and i32 %1, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %12, i64 1
store i8 87, i8* %12
br label %17
17: ; preds = %15, %11
%18 = phi i8* [ %16, %15 ], [ %12, %11 ]
%19 = and i32 %1, 4
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %18, i64 1
store i8 88, i8* %18
br label %23
23: ; preds = %21, %17
%24 = phi i8* [ %22, %21 ], [ %18, %17 ]
%25 = and i32 %1, 8
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = getelementptr inbounds i8, i8* %24, i64 1
store i8 83, i8* %24
br label %29
29: ; preds = %27, %23
%30 = phi i8* [ %28, %27 ], [ %24, %23 ]
store i8 0, i8* %30
%31 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %6)
%32 = call i32 @strdup(i8* %5)
%33 = call i32 @new_directive(i32 %32)
ret void
}