#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*/ assert(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *strdup(char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *get_cat_section(char *section) {
  char *cat_section;
  cat_section = strdup(section);
  assert(strlen(section) > 3 && strncmp(section, "man", 3) == 0);
  memcpy(cat_section, "cat", 3);
  return cat_section;
}


x86 assembly (clang, -O0):
<get_cat_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x11(%rbp)
jle    11a1 <get_cat_section+0x51>
mov    -0x8(%rbp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x3,%edx
call   1060 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cat_section>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    $0x4,%eax
jl     118b <get_cat_section+0x3b>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
mov    $0x3,%edx
call   1060 <memcpy@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"man\00"
@.str.1 = [4 x i8] c"cat\00"
define i8* @get_cat_section(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strdup(i8* %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 3
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%12 = icmp eq i64 %11, 0
br label %13
13: ; preds = %9, %1
%14 = phi i1 [ false, %1 ], [ %12, %9 ]
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %3
%18 = call i32 @memcpy(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%19 = load i8*, i8** %3
ret i8* %19
}

LLVM IR (-O2):
@.str = [4 x i8] c"man\00"
@.str.1 = [4 x i8] c"cat\00"
define i8* @get_cat_section(i8* %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 3
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %5, %1
%10 = phi i32 [ 0, %1 ], [ %8, %5 ]
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @memcpy(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
ret i8* %2
}