#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 O_CREAT;
int O_TRUNC;
int O_WRONLY;
char a;
int open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  char a = a;
  int fd;
  if (argc < 2) {
    printf("Please you have to specify the file name.\n");
    return 1;
  } else {
    fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0666);
  }
  if (fd == -1) {
    printf("ERROR!\n");
    return -1;
  }
  for (int i = 0; i < 10000000; i++) {
    write(fd, &a, 1);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x11(%rbp),%al
mov    %al,-0x11(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116e <main+0x3e>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fa <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
mov    0x2e72(%rip),%rax
or     (%rax),%esi
mov    0x2e61(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11c0 <main+0x90>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <main+0xca>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x989680,-0x1c(%rbp)
jge    11f3 <main+0xc3>
mov    -0x18(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c7 <main+0x97>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    114a <main+0x1a>
mov    $0x1,%ebx
lea    0xebf(%rip),%rdi
jmp    11b3 <main+0x83>
mov    0x2e77(%rip),%rcx
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x8(%rsi),%rdi
mov    0x2e89(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%esi
mov    $0x1b6,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     11a7 <main+0x77>
mov    %eax,%r15d
mov    $0x989680,%ebp
lea    0x7(%rsp),%r14
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x60>
jmp    11b8 <main+0x88>
mov    $0xffffffff,%ebx
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Please you have to specify the file name.\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [8 x i8] c"ERROR!\0A\00"
@a = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8, i8* %6
store i8 %9, i8* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %40
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_WRONLY
%19 = load i32, i32* @O_CREAT
%20 = or i32 %18, %19
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = call i32 @open(i8* %17, i32 %22, i32 438)
store i32 %23, i32* %7
br label %24
24: ; preds = %14
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
29: ; preds = %24
store i32 0, i32* %8
br label %30
30: ; preds = %36, %29
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 10000000
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %7
%35 = call i32 @write(i32 %34, i8* %6, i32 1)
br label %36
36: ; preds = %33
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %30
39: ; preds = %30
store i32 1, i32* %3
br label %40
40: ; preds = %39, %27, %12
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@a = global i8 0
@str = [7 x i8] c"ERROR!\00"
@str.2 = [42 x i8] c"Please you have to specify the file name.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = icmp slt i32 %0, 2
br i1 %4, label %20, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_CREAT
%10 = or i32 %9, %8
%11 = load i32, i32* @O_TRUNC
%12 = or i32 %10, %11
%13 = tail call i32 @open(i8* %7, i32 %12, i32 438)
%14 = icmp eq i32 %13, -1
br i1 %14, label %20, label %15
15: ; preds = %5, %15
%16 = phi i32 [ %18, %15 ], [ 0, %5 ]
%17 = call i32 @write(i32 %13, i8* %3, i32 1)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, 10000000
br i1 %19, label %24, label %15
20: ; preds = %5, %2
%21 = phi i8* [ getelementptr inbounds ([42 x i8], [42 x i8]* @str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), %5 ]
%22 = phi i32 [ 1, %2 ], [ -1, %5 ]
%23 = tail call i32 @puts(i8* dereferenceable(1) %21)
br label %24
24: ; preds = %15, %20
%25 = phi i32 [ %22, %20 ], [ 1, %15 ]
ret i32 %25
}