#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 EXIT_SUCCESS;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  char buffer[512 * 64];
  int fd;
  int i;
  printf("Hello, world! 1228800\n");
  fd = open("/var/test", O_RDWR);
  if (fd) {
    printf("open success /var/test\n");
  } else {
    printf("open fail /var/test\n");
  }
  for (i = 0; i < 1228800 / 64; i++) {
    write(fd, buffer, 512 * 64);
  }
  close(fd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8014(%rbp)
cmpl   $0x0,-0x8014(%rbp)
je     119e <main+0x5e>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
jmp    11aa <main+0x6a>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x8018(%rbp)
cmpl   $0x4b00,-0x8018(%rbp)
jge    11ef <main+0xaf>
mov    -0x8014(%rbp),%edi
lea    -0x8010(%rbp),%rsi
mov    $0x8000,%edx
call   1030 <write@plt>
mov    -0x8018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8018(%rbp)
jmp    11b4 <main+0x74>
mov    -0x8014(%rbp),%edi
call   1050 <close@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
add    $0x8020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x8000,%rsp
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0xeb9(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
lea    0xe9f(%rip),%rax
lea    0xeac(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    $0x4b00,%ebp
mov    %rsp,%r14
nop
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x8000,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x50>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
add    $0x8000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Hello, world! 1228800\0A\00"
@.str.1 = [10 x i8] c"/var/test\00"
@O_RDWR = global i32 0
@.str.2 = [24 x i8] c"open success /var/test\0A\00"
@.str.3 = [21 x i8] c"open fail /var/test\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32768 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @O_RDWR
%11 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
store i32 0, i32* %8
br label %19
19: ; preds = %26, %18
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 19200
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %7
%24 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%25 = call i32 @write(i32 %23, i8* %24, i32 32768)
br label %26
26: ; preds = %22
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %19
29: ; preds = %19
%30 = load i32, i32* %7
%31 = call i32 @close(i32 %30)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"/var/test\00"
@O_RDWR = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"Hello, world! 1228800\00"
@str.4 = [20 x i8] c"open fail /var/test\00"
@str.5 = [23 x i8] c"open success /var/test\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32768 x i8]
%4 = getelementptr inbounds [32768 x i8], [32768 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* @O_RDWR
%7 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %2, %11
%12 = phi i32 [ 0, %2 ], [ %14, %11 ]
%13 = call i32 @write(i32 %7, i8* %4, i32 32768)
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, 19200
br i1 %15, label %16, label %11
16: ; preds = %11
%17 = tail call i32 @close(i32 %7)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}