#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 */
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int strlen(char *);
scalar_t__ write(int, char *, int);
void write_title(char *arg) {
  ssize_t write_return_value;
  write_return_value = write(1, "\n", 1);
  write_return_value = write(1, arg, strlen(arg));
  write_return_value = write(1, ":\n", 2);
  if (write_return_value < 0) {
    perror("Error while writing");
  }
}


x86 assembly (clang, -O0):
<write_title>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edx
lea    0xeb9(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
lea    0xe7c(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    11a9 <write_title+0x79>
lea    0xe5f(%rip),%rdi
call   1050 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_title>:
push   %rbx
mov    %rdi,%rbx
lea    0xec6(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe98(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
test   %rax,%rax
js     117e <write_title+0x4e>
pop    %rbx
ret
lea    0xe7e(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c":\0A\00"
@.str.2 = [20 x i8] c"Error while writing\00"
define void @write_title(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = call i64 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
store i64 %4, i64* %3
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = call i64 @write(i32 1, i8* %5, i32 %7)
store i64 %8, i64* %3
%9 = call i64 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
store i64 %9, i64* %3
%10 = load i64, i64* %3
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c":\0A\00"
@.str.2 = [20 x i8] c"Error while writing\00"
define void @write_title(i8* %0) {
%2 = tail call i64 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i64 @write(i32 1, i8* %0, i32 %3)
%5 = tail call i64 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
ret void
}