#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);
void cowsay_print_singleline(int argc, char **argv, int length) {
  int i;
  putchar(' ');
  for (i = 0; i < length + 2; i++)
    putchar('_');
  printf("\n< ");
  for (i = 0; i < argc; i++) {
    printf("%s", argv[i]);
    putchar(' ');
  }
  printf(">\n ");
  for (i = 0; i < length + 2; i++)
    putchar('-');
  putchar('\n');
}


x86 assembly (clang, -O0):
<cowsay_print_singleline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x20,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    116c <cowsay_print_singleline+0x4c>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <cowsay_print_singleline+0x23>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bf <cowsay_print_singleline+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <cowsay_print_singleline+0x61>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    11fd <cowsay_print_singleline+0xdd>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d4 <cowsay_print_singleline+0xb4>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cowsay_print_singleline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0x2(%r14),%r15d
cmp    $0xffffffff,%r14d
jl     116f <cowsay_print_singleline+0x4f>
cmp    $0x2,%r15d
mov    $0x1,%ebx
cmovge %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x5f,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1160 <cowsay_print_singleline+0x40>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11b2 <cowsay_print_singleline+0x92>
mov    %ebp,%ebp
lea    0xe7a(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x0(%r13,%rbx,8),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <cowsay_print_singleline+0x70>
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xffffffff,%r14d
jl     11ef <cowsay_print_singleline+0xcf>
cmp    $0x2,%r15d
mov    $0x1,%ebx
cmovge %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <cowsay_print_singleline+0xc0>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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_singleline(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%8 = call i32 @putchar(i8 signext 32)
store i32 0, i32* %7
br label %9
9: ; preds = %16, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = add nsw i32 %11, 2
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = call i32 @putchar(i8 signext 95)
br label %16
16: ; preds = %14
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %7
br label %9
19: ; preds = %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %21
21: ; preds = %33, %19
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 @putchar(i8 signext 32)
br label %33
33: ; preds = %25
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %21
36: ; preds = %21
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %38
38: ; preds = %45, %36
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 2
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = call i32 @putchar(i8 signext 45)
br label %45
45: ; preds = %43
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %38
48: ; preds = %38
%49 = 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_singleline(i32 %0, i8** nocapture %1, i32 %2) {
%4 = tail call i32 @putchar(i8 signext 32)
%5 = add i32 %2, 2
%6 = icmp sgt i32 %2, -2
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = call i32 @llvm.smax.i32(i32 %5, i32 1)
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %12, %9 ], [ 0, %7 ]
%11 = tail call i32 @putchar(i8 signext 95)
%12 = add nuw nsw i32 %10, 1
%13 = icmp eq i32 %12, %8
br i1 %13, label %14, label %9
14: ; preds = %9, %3
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = icmp sgt i32 %0, 0
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %25, %19 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = tail call i32 @putchar(i8 signext 32)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %18
br i1 %26, label %27, label %19
27: ; preds = %19, %14
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br i1 %6, label %29, label %36
29: ; preds = %27
%30 = call i32 @llvm.smax.i32(i32 %5, i32 1)
br label %31
31: ; preds = %29, %31
%32 = phi i32 [ %34, %31 ], [ 0, %29 ]
%33 = tail call i32 @putchar(i8 signext 45)
%34 = add nuw nsw i32 %32, 1
%35 = icmp eq i32 %34, %30
br i1 %35, label %36, label %31
36: ; preds = %31, %27
%37 = tail call i32 @putchar(i8 signext 10)
ret void
}