#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*/ exit(int /*<<< orphan*/);
int strlen(char *);
int write(int, char *, int);
int main() {
  char *phrase = "Some more data\n";
  char *error_text = "A write error occurred on file descriptor 1\n";
  if ((write(1, "Here is \n some data\n", 20)) != 20)
    write(2, "A write error has occurred on file descriptor 1\n", 46);
  if ((write(1, phrase, strlen(phrase))) != strlen(phrase))
    write(2, error_text, strlen(error_text));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xebf(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
lea    0xedc(%rip),%rsi
mov    $0x14,%edx
call   1030 <write@plt>
cmp    $0x14,%eax
je     118a <main+0x5a>
mov    $0x2,%edi
lea    0xed2(%rip),%rsi
mov    $0x2e,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
je     11e5 <main+0xb5>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
mov    $0x2,%edi
call   1030 <write@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xf03(%rip),%rsi
mov    $0x1,%edi
mov    $0x14,%edx
call   1030 <write@plt>
cmp    $0x14,%eax
je     1164 <main+0x34>
lea    0xefd(%rip),%rsi
mov    $0x2,%edi
mov    $0x2e,%edx
call   1030 <write@plt>
lea    0xe95(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
je     11ae <main+0x7e>
lea    0xe79(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Some more data\0A\00"
@.str.1 = [45 x i8] c"A write error occurred on file descriptor 1\0A\00"
@.str.2 = [21 x i8] c"Here is \0A some data\0A\00"
@.str.3 = [49 x i8] c"A write error has occurred on file descriptor 1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8** %3
%4 = call i32 @write(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 20)
%5 = icmp ne i32 %4, 20
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @write(i32 2, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 46)
br label %8
8: ; preds = %6, %0
%9 = load i8*, i8** %2
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @write(i32 1, i8* %9, i32 %11)
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %21
16: ; preds = %8
%17 = load i8*, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @write(i32 2, i8* %17, i32 %19)
br label %21
21: ; preds = %16, %8
%22 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [16 x i8] c"Some more data\0A\00"
@.str.1 = [45 x i8] c"A write error occurred on file descriptor 1\0A\00"
@.str.2 = [21 x i8] c"Here is \0A some data\0A\00"
@.str.3 = [49 x i8] c"A write error has occurred on file descriptor 1\0A\00"
define i32 @main() {
%1 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 20)
%2 = icmp eq i32 %1, 20
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 46)
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %5
%14 = tail call i32 @exit(i32 0)
unreachable
}