#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*/ free(char *);
int /*<<< orphan*/ respond(unsigned int, int /*<<< orphan*/, char *);
char *strchr(char *, char);
char *strdup(char const *);
void show_banner(unsigned code, const char *banner) {
  char *copy;
  char *start;
  char *end;
  if ((copy = strdup(banner)) == 0)
    return;
  start = copy;
  while ((end = strchr(start, '\n')) != 0) {
    *end = 0;
    if (end > start)
      respond(code, 0, start);
    start = end + 1;
  }
  respond(code, 0, start);
  free(copy);
}


x86 assembly (clang, -O0):
<show_banner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    116b <show_banner+0x2b>
jmp    11da <show_banner+0x9a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11c3 <show_banner+0x83>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11b2 <show_banner+0x72>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rdx
xor    %esi,%esi
call   1040 <respond@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1173 <show_banner+0x33>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rdx
xor    %esi,%esi
call   1040 <respond@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_banner>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
mov    %rsi,%rdi
call   1060 <strdup@plt>
test   %rax,%rax
je     11d3 <show_banner+0x93>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %r14,%rbx
test   %rax,%rax
je     11b4 <show_banner+0x74>
mov    %rax,%rbp
mov    %r14,%rbx
jmp    119c <show_banner+0x5c>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11b4 <show_banner+0x74>
movb   $0x0,0x0(%rbp)
cmp    %rbx,%rbp
jbe    1180 <show_banner+0x40>
mov    %r15d,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1040 <respond@plt>
jmp    1180 <show_banner+0x40>
mov    %r15d,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1040 <respond@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @show_banner(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
br label %36
12: ; preds = %2
%13 = load i8*, i8** %5
store i8* %13, i8** %6
br label %14
14: ; preds = %27, %12
%15 = load i8*, i8** %6
%16 = call i8* @strchr(i8* %15, i8 signext 10)
store i8* %16, i8** %7
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i8*, i8** %7
store i8 0, i8* %19
%20 = load i8*, i8** %7
%21 = load i8*, i8** %6
%22 = icmp ugt i8* %20, %21
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* %3
%25 = load i8*, i8** %6
%26 = call i32 @respond(i32 %24, i32 0, i8* %25)
br label %27
27: ; preds = %23, %18
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %6
br label %14
30: ; preds = %14
%31 = load i32, i32* %3
%32 = load i8*, i8** %6
%33 = call i32 @respond(i32 %31, i32 0, i8* %32)
%34 = load i8*, i8** %5
%35 = call i32 @free(i8* %34)
br label %36
36: ; preds = %30, %11
ret void
}

LLVM IR (-O2):
define void @show_banner(i32 %0, i8* nocapture %1) {
%3 = tail call i8* @strdup(i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = tail call i8* @strchr(i8* %3, i8 signext 10)
%7 = icmp eq i8* %6, null
br i1 %7, label %18, label %8
8: ; preds = %5, %14
%9 = phi i8* [ %16, %14 ], [ %6, %5 ]
%10 = phi i8* [ %15, %14 ], [ %3, %5 ]
store i8 0, i8* %9
%11 = icmp ugt i8* %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @respond(i32 %0, i32 0, i8* %10)
br label %14
14: ; preds = %12, %8
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = tail call i8* @strchr(i8* %15, i8 signext 10)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %8
18: ; preds = %14, %5
%19 = phi i8* [ %3, %5 ], [ %15, %14 ]
%20 = tail call i32 @respond(i32 %0, i32 0, i8* %19)
%21 = tail call i32 @free(i8* %3)
br label %22
22: ; preds = %2, %18
ret void
}