#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 _open_file();
int /*<<< orphan*/ _write_bytes(int, char const *, size_t);
int main(int argc, char *argv[]) {
  const char *string =
      "Initially intended for use inside the Bell System, AT&T licensed Unix "
      "to outside parties from the late 1970s, leading to a variety of both "
      "academic and commercial variants of Unix from vendors such as the "
      "University of California, Berkeley (BSD), Microsoft (Xenix), IBM (AIX) "
      "and Sun Microsystems (Solaris)";
  char *p = string;
  int fd = _open_file();
  size_t str_len = 0;
  do {
    ++str_len;
  } while (*(++p));
  _write_bytes(fd, string, str_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <_open_file@plt>
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
cmpb   $0x0,0x1(%rax)
jne    115b <main+0x3b>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <_write_bytes@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <_open_file@plt>
lea    0xecf(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x1(%rbx,%rcx,1)
lea    0x1(%rbx),%rbx
jne    1140 <main+0x20>
lea    0xeae(%rip),%rsi
mov    %eax,%edi
mov    %rbx,%rdx
call   1040 <_write_bytes@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [307 x i8] c"Initially intended for use inside the Bell System, AT&T licensed Unix to outside parties from the late 1970s, leading to a variety of both academic and commercial variants of Unix from vendors such as the University of California, Berkeley (BSD), Microsoft (Xenix), IBM (AIX) and Sun Microsystems (Solaris)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([307 x i8], [307 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i8*, i8** %6
store i8* %10, i8** %7
%11 = call i32 (...) @_open_file()
store i32 %11, i32* %8
store i64 0, i64* %9
br label %12
12: ; preds = %15, %2
%13 = load i64, i64* %9
%14 = add i64 %13, 1
store i64 %14, i64* %9
br label %15
15: ; preds = %12
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %7
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %12, label %20
20: ; preds = %15
%21 = load i32, i32* %8
%22 = load i8*, i8** %6
%23 = load i64, i64* %9
%24 = call i32 @_write_bytes(i32 %21, i8* %22, i64 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [307 x i8] c"Initially intended for use inside the Bell System, AT&T licensed Unix to outside parties from the late 1970s, leading to a variety of both academic and commercial variants of Unix from vendors such as the University of California, Berkeley (BSD), Microsoft (Xenix), IBM (AIX) and Sun Microsystems (Solaris)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @_open_file()
br label %4
4: ; preds = %4, %2
%5 = phi i8* [ getelementptr inbounds ([307 x i8], [307 x i8]* @.str, i64 0, i64 0), %2 ], [ %8, %4 ]
%6 = phi i64 [ 0, %2 ], [ %7, %4 ]
%7 = add i64 %6, 1
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = tail call i32 @_write_bytes(i32 %3, i8* getelementptr inbounds ([307 x i8], [307 x i8]* @.str, i64 0, i64 0), i64 %7)
ret i32 0
}