#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*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int strlen(char *);
void cowsay_print_string(char *str) {
  int i;
  int length = strlen(str);
  putchar(' ');
  for (i = 0; i < length + 2; i++)
    putchar('_');
  printf("\n< ");
  printf("%s", str);
  putchar(' ');
  printf(">\n ");
  for (i = 0; i < length + 2; i++)
    putchar('-');
  putchar('\n');
}


x86 assembly (clang, -O0):
<cowsay_print_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    $0x20,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1182 <cowsay_print_string+0x52>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1159 <cowsay_print_string+0x29>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    11ea <cowsay_print_string+0xba>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <cowsay_print_string+0x91>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cowsay_print_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    $0xffffffff,%ebx
jl     11e1 <cowsay_print_string+0xb1>
lea    0x2(%rbx),%r15d
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovge %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x5f,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1170 <cowsay_print_string+0x40>
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xffffffff,%ebx
jl     1218 <cowsay_print_string+0xe8>
cmp    $0x2,%r15d
mov    $0x1,%ebx
cmovge %r15d,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11d0 <cowsay_print_string+0xa0>
jmp    1218 <cowsay_print_string+0xe8>
lea    0xe18(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xdf6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\0A< \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c">\0A \00"
define void @cowsay_print_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = call i32 @putchar(i8 signext 32)
store i32 0, i32* %3
br label %8
8: ; preds = %15, %1
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 2
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = call i32 @putchar(i8 signext 95)
br label %15
15: ; preds = %13
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %8
18: ; preds = %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @putchar(i8 signext 32)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %24
24: ; preds = %31, %18
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 2
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = call i32 @putchar(i8 signext 45)
br label %31
31: ; preds = %29
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %24
34: ; preds = %24
%35 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\0A< \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c">\0A \00"
define void @cowsay_print_string(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @putchar(i8 signext 32)
%4 = add i32 %2, 2
%5 = icmp sgt i32 %2, -2
br i1 %5, label %6, label %25
6: ; preds = %1
%7 = call i32 @llvm.smax.i32(i32 %4, i32 1)
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %11, %8 ], [ 0, %6 ]
%10 = tail call i32 @putchar(i8 signext 95)
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, %7
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%16 = tail call i32 @putchar(i8 signext 32)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br i1 %5, label %18, label %30
18: ; preds = %13
%19 = call i32 @llvm.smax.i32(i32 %4, i32 1)
br label %20
20: ; preds = %18, %20
%21 = phi i32 [ %23, %20 ], [ 0, %18 ]
%22 = tail call i32 @putchar(i8 signext 45)
%23 = add nuw nsw i32 %21, 1
%24 = icmp eq i32 %23, %19
br i1 %24, label %30, label %20
25: ; preds = %1
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%28 = tail call i32 @putchar(i8 signext 32)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %20, %25, %13
%31 = tail call i32 @putchar(i8 signext 10)
ret void
}